This guide connects a Valheim dedicated server to X4B DDoS Protection. You supply and maintain the game server, referred to below as the backend; players connect to your X4B filtered IP. The main procedure uses a GRE tunnel and Valheim's Steam backend.
Before you start: Steam or crossplay?
Omit -crossplay for Steam-only players. With -crossplay, Valheim uses PlayFab relays; consoles require crossplay. See Iron Gate's dedicated server guide and Crossplay FAQ.
Step 1: Prepare the Valheim server
Use a maintained Windows or Linux host with administrator access for networking. Run the game under a separate, unprivileged account. Allow capacity for the world, logs and backups; monitor CPU, memory, disk space and network usage under your actual player load. An SSD is a sensible starting point. X4B clean bandwidth measures delivered traffic, so choose an allowance for normal gameplay and monitor it after launch.
Install Valheim Dedicated Server from Steam's Library > Tools. Follow the official setup instructions, including Linux dependencies. Copy start_headless_server.bat on Windows or start_server.sh on Linux before editing; updates replace the originals.
In your copy, edit the arguments on the existing server launch line. For a private Steam-only example, use:
-name "X4B Valheim" -port 2456 -world "Dedicated" -password "REPLACE_WITH_A_UNIQUE_PASSWORD" -public 0
Keep the launcher's other commands and environment settings. Replace the example password and choose your intended world. Restrict access to the launcher because it contains the password. Iron Gate's manual describes -public 0 as unlisted; it is not access control.
Start your copied launcher. Wait for Game server connected. Test with a trusted Steam player before changing the network path, limiting temporary backend access to that tester. On Linux, sudo ss -lunp helps identify the UDP listeners.
Step 2: Choose the X4B service and backend method
Use an existing active service or choose a plan on the DDoS protection page. Select a filtering location with a suitable route to both the backend and your players. Keep the backend address separate from the filtered IP that players will use.
We recommend a GRE tunnel for UDP compatibility and preservation of client source addresses. Your host and provider must support it. See Port types and the GRE/IP-in-IP setup guide for requirements and alternatives.
Reverse Proxy is an alternative when a tunnel is unavailable, subject to testing with your server build. It forwards incoming UDP but presents X4B's source address to the backend and does not route the game's outgoing connections through X4B. Test joining and any server-list behaviour separately. A working direct join does not establish that a listing advertises the filtered IP.
Step 3: Create the tunnel and add the game ports
- Open Services, find your service, and choose Action > Tunnels.
- Select Add Tunnel, choose GRE under Tunnel type, and enter your backend's public IP in Backend address. Save and verify the entry. Retain the displayed key and MTU for the backend configuration.
- Return to the service's Action > Ports page. Under Single Port, choose Add port manually if the empty state is shown; otherwise choose Add Port.
- Add both entries below. For each entry, choose UDP, select Encapsulated (NAT) as Backend method, and select your saved GRE tunnel. Keep the backend port equal to the public port. Save each entry.
| Port start | Protocol | Backend port |
|---|---|---|
| 2456 | UDP | 2456 |
| 2457 | UDP | 2457 |
Valheim uses the configured port and the next port. If you change -port, update both entries. These are UDP forwards; select the ordinary UDP protocol for this procedure. Forward only the required listeners rather than an entire DMZ. Check the installed server's manual before adding ports for plugins or future versions.
- Reload Ports and check that both entries reference the same tunnel and correct destination ports.
- Return to Tunnels, choose Action > Setup Tunnel, then Linux / BSD > Download Tunnel Script, or Microsoft Windows > Download Application. A saved port must reference the tunnel before setup is usable.
- Review and install the generated configuration using the tunnel instructions or Windows instructions. Arrange for the tunnel to start before the game server at boot.
Confirm that Valheim listens on the assigned tunnel address or on all appropriate interfaces. Replies must return through the tunnel that delivered the traffic; retain the generated routing and packet-marking rules. For Anycast, follow the Unified Tunnel requirements in the tunnel guide.
For Reverse Proxy, skip tunnel creation and installation. Add the same two UDP entries with Backend method > Reverse Proxy, your reachable Backend address, and matching Backend port values. If the backend is behind NAT, its router must forward both UDP ports to the game host. A backend behind CGNAT needs a reachable hosting or networking arrangement first.
Step 4: Secure the backend path
Keep host and provider firewalls enabled. Preserve management access and keep a recovery console available when changing rules.
- GRE: Allow IP protocol 47 between the backend and the X4B tunnel endpoints; this is an IP protocol number, not port 47. Allow the game's UDP traffic on the tunnel interface. Inner packets retain player source addresses, so an allowlist of X4B communication addresses alone will not match that game traffic. Keep game access through the backend's public interface restricted.
- Reverse Proxy: In Services > Action > IP Addresses, read the current Backend Communication IP Addresses. Allow the two backend UDP ports from those addresses in host and provider firewalls. See firewall exceptions.
Keep the outbound connectivity needed for Steam, updates and DNS. Once protected-path testing succeeds, remove temporary direct game access. Restricting game ports does not make a publicly known backend address immune to attacks on its underlying connection.
Step 5: Test the protected address
Wait for the Dashboard deployment progress to finish. Give a trusted external Steam player the filtered IP and configured game port, for example 203.0.113.20:2456. This is a documentation address; substitute your service's filtered IP. Use Valheim's Join IP option.
Confirm that the player can join, play, disconnect and reconnect. Check backend logs or packet captures to verify that the tested traffic uses the selected X4B path. Test from more than one outside network where possible, then repeat after a server reboot to verify startup ordering and persistent firewall rules.
If you later enable public listing, separately verify the address advertised and the path taken by players joining through the list. Outgoing registration can expose a backend address; review routing with support if the listing bypasses the filtered IP. Publish the filtered IP in any game hostname's DNS records.
Ongoing maintenance
Stop the server gracefully with Ctrl+C before maintenance, and wait for it to exit. Configure any service manager to permit a graceful stop. The server manual documents -savedir, automatic backups and permission files.
Back up the entire active save directory, your custom launcher and service configuration while the server is stopped, or use an application-consistent backup method. Keep dated copies off the game host and test a restore in an isolated instance. Copying only selected world files can miss data as save formats change. Automatic backups on the same disk do not cover host or disk loss.
Schedule updates with players: stop, back up, update, review changes to the supplied launcher, restart and retest the filtered address. Keep clients and server on compatible releases. Establish a working unmodified server before adding mods, then check their compatibility during each update; Iron Gate does not officially support mods. See the Valheim FAQ.
Use a unique server password and grant administrator access only to trusted players. For a private group, review the manual's permittedlist.txt behaviour before enabling its allowlist. Recheck firewall sources when X4B backend communication addresses change.
Troubleshooting
| Symptom | Checks |
|---|---|
| Server works locally but not through X4B | Confirm deployment, Steam mode, both UDP forwards, backend listeners and firewall logs. Check the selected tunnel and reply routing. |
| Direct Join IP works but the server list does not | Review visibility, registration and the advertised address separately. Confirm that listing-based joins also use X4B. |
| Some platforms cannot join | Check whether crossplay is required and review the relay-path limitation above. |
| Players disconnect or lag | Compare server resource use, packet loss and routes. For a tunnel, also review MTU; increasing bandwidth does not resolve every cause. |
| The server loads an unexpected world | Check the world argument, save location and account running the launcher before making changes. Preserve backups. |
When contacting support, include the service, filtered IP, configured ports, backend method, server version, crossplay setting, test time with timezone, and relevant logs. Remove passwords and join codes from shared evidence.
