Server security

Dedicated Valheim: securing your self-hosted server against intrusions?

August 17, 2026 · 7 min read
Illustration immersive du sujet : Valheim server security

Valheim server security has become a critical concern as Iron Gate's Viking survival phenomenon continues to draw millions of players worldwide—and unfortunately, attracts malicious actors scanning for exposed ports, exploiting vulnerable installations, and overwhelming servers with junk traffic. Whether you're running a private longhouse for friends or a public 10-slot community realm, hardening your Valheim dedicated server against intrusions, brute-force attempts, and volumetric attacks is no longer optional in 2026.

This guide walks you through kernel-level firewall architecture, stateless XDP filtering, stateful connection tracking with nftables, and practical rules to lock down UDP 2456–2458 without breaking Steam's query protocol or BepInEx mod traffic.



Why Valheim Servers Are Prime Targets for Intrusion

Valheim's dedicated server binary (valheim_server.x86_64) binds by default to UDP ports 2456 (game), 2457 (query), and optionally 2458 when using Steam's server browser. Unlike games that enforce Steam authentication at the protocol level, Valheim's peer-to-peer handshake occurs after the kernel accepts the UDP datagram—meaning every malformed packet, amplification probe, or connection flood consumes CPU cycles before the game logic can reject it.

Common attack vectors observed in 2025–2026 include:

  • UDP flood: sustained high packet-per-second streams exhausting the server's receive queue and NIC interrupt budget.
  • Amplification reflection: attackers spoofing your server IP to bounce traffic off misconfigured DNS, NTP, or memcached resolvers.
  • Port scanning and exploit probes: automated bots fingerprinting your kernel version, open services (SSH on 22, HTTP on 80), and known CVEs in outdated packages.
  • RCON brute-force (if enabled): dictionary attacks against the optional remote console on TCP 2456 when -password is weak or reused.

Because Valheim uses Unity's low-level transport and does not natively rate-limit at the socket layer, defense must happen below user-space—in the Linux networking stack itself.



Layered Defense: XDP + nftables for Valheim

Modern Valheim server security requires two complementary tiers operating at different points in the packet path:

XDP (eXpress Data Path) — Stateless L2/L3 Filtering

XDP hooks into the network driver before the kernel allocates an sk_buff structure, enabling you to XDP_DROP unwanted packets in sub-microsecond time with near-zero CPU overhead. A well-tuned XDP program can silently discard several million packets per second on a modest 4-core VPS, protecting Valheim from volumetric floods that would otherwise saturate ksoftirqd.

Typical XDP rules for Valheim:

# Block all traffic except UDP 2456–2458 and TCP 22 (SSH)
rule_type: allow_only
protocol: udp
port_range: 2456–2458

# Global rate-limit to 100k pps
max_pps: 100000

# Per-port cap to prevent single-port exhaustion
max_port_pps: 50000

# Drop micro-packets (less than 28 bytes, often malformed)
min_packet_size: 28

Because XDP is stateless, it cannot distinguish between a legitimate player's handshake and a spoofed SYN—but it can enforce coarse-grained rate-limits and protocol whitelists before the packet reaches the kernel's conntrack subsystem.

nftables — Stateful L3/L4 Connection Tracking

Once a packet passes XDP, nftables (the successor to iptables) applies stateful rules: tracking connection state (ct state new, established, related), validating TCP flags, enforcing per-source rate-limits with meter, and dynamically managing IP blacklists/whitelists.

Example ruleset in the inet pakkt table (isolated from Docker's nat chains and fail2ban's filter table):

nft add table inet pakkt
nft add chain inet pakkt input { type filter hook input priority 0 \; policy drop \; }

# Accept established/related (players already connected)
nft add rule inet pakkt input ct state established,related accept

# Rate-limit new UDP connections to 2456–2458: max 200/sec per source IP
nft add rule inet pakkt input udp dport 2456-2458 ct state new \
  meter valheim_ratelimit { ip saddr limit rate over 200/second burst 50 packets } drop

# Accept new connections within limit
nft add rule inet pakkt input udp dport 2456-2458 ct state new accept

# SSH with stricter per-IP limit
nft add rule inet pakkt input tcp dport 22 ct state new \
  meter ssh_ratelimit { ip saddr limit rate over 5/minute } drop
nft add rule inet pakkt input tcp dport 22 ct state new accept

# Drop invalid packets
nft add rule inet pakkt input ct state invalid drop

This two-tier architecture—XDP dropping floods at line-rate, nftables enforcing stateful policy—delivers Valheim server security that scales from 10-player LAN parties to 100+ slot public servers under DDoS.



Hardening the Valheim Binary and Host Environment

Kernel firewalls are necessary but not sufficient. The dedicated server process and underlying OS also require lockdown:

Run Valheim as a Non-Root User with Restricted Permissions

Never invoke valheim_server.x86_64 as root. Create a dedicated valheim service account, assign ownership of /opt/valheim, and launch via systemd with NoNewPrivileges=true, PrivateTmp=true, and ProtectSystem=strict.

[Unit]
Description=Valheim Dedicated Server
After=network.target

[Service]
Type=simple
User=valheim
WorkingDirectory=/opt/valheim
ExecStart=/opt/valheim/valheim_server.x86_64 -nographics -batchmode \
  -name "MyServer" -port 2456 -world "Dedicated" -password "ChangeMe" -public 0
Restart=on-failure
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ReadWritePaths=/opt/valheim

[Install]
WantedBy=multi-user.target

Disable Unnecessary Services and Close Unused Ports

Run ss -tuln to inventory listening sockets. If you see MySQL (3306), Postfix (25), or Apache (80/443) but don't need them for Valheim, stop and mask those units. Every open port is an additional attack surface.

Keep Kernel and Valheim Server Updated

Ensure your Linux kernel is 5.4 or higher (for stable XDP support) and apply security patches monthly. Subscribe to Iron Gate's mailing list or monitor SteamCMD changelogs to catch Valheim server updates—unpatched builds may leak memory or crash under malformed packets.

Isolate with Network Namespaces (Advanced)

For multi-tenant hosts running multiple game servers, consider launching each Valheim instance in its own network namespace with VETH pairs and dedicated XDP programs per virtual interface. This prevents one compromised server from pivoting laterally to others on the same box.



Centralized Management and Real-Time Monitoring

Manually editing XDP map entries with bpftool and crafting nftables rulesets across a fleet of Valheim servers quickly becomes unmanageable. A centralized control plane that unifies XDP and nftables configuration, synchronizes IP blacklists in real-time, and surfaces per-port metrics is essential for production deployments.

PAKKT.io provides exactly this architecture: a lightweight Go agent (under 5 MB RAM, sub-1% CPU) installed on each Valheim host that:

  • Loads a single XDP program per interface with up to 256 simultaneous rules driven by BPF maps—no kernel module recompilation.
  • Orchestrates the inet pakkt nftables table with stateful conntrack, per-IP rate-limits, and automatic blacklist/whitelist synchronization.
  • Reports per-port, per-rule packet counters and GeoIP-enriched top-talker data to a TimescaleDB backend every 30 seconds.
  • Self-updates via SHA256-verified binaries over mTLS, with garble obfuscation to resist reverse-engineering.

The web dashboard displays a real-time world map of connection origins, drill-down histograms of blocked vs. accepted traffic on UDP 2456–2458, and an audit log of every rule change. For teams managing Valheim clusters—whether for a gaming community, a hosting provider, or an esports league—this single pane of glass replaces SSH-hopping and grep-ing through journalctl.

PAKKT also integrates with Pterodactyl v1.x, enabling one-click firewall rule deployment from the game panel. Pelican and WHMCS connectors are in active development for Q2 2026.

Pricing starts at €3 per agent per month, with a 7-day free trial on your first node—orders of magnitude cheaper than outsourcing DDoS mitigation to a cloud scrubbing service, and far more transparent than opaque "gaming VPS with DDoS protection" bundles that may simply null-route your IP under attack.



Complementary Measures: Backups, Logging, and Incident Response

Even the tightest firewall cannot prevent zero-day exploits in the Valheim binary itself or social-engineering attacks that leak your server password. Prepare for post-intrusion recovery:

  • Automated world backups: rsync /opt/valheim/.config/unity3d/IronGate/Valheim/worlds/ to off-site storage every 6 hours. Test restoration monthly.
  • Immutable audit logs: forward nftables log entries and PAKKT agent telemetry to a remote syslog collector (e.g., rsyslog over TLS to a hardened log server). An attacker who gains root can erase local logs but not tamper with signed remote archives.
  • Intrusion detection: run osquery or OSSEC to baseline file integrity of /opt/valheim and alert on unexpected process launches or library injections.
  • Incident playbook: document step-by-step procedures for isolating a compromised Valheim server (remove from DNS, drain connections, snapshot disk for forensics), rotating passwords, and notifying players.

Security is not a one-time configuration but a continuous cycle of monitoring, testing, and refinement. Schedule quarterly drills where you simulate a DDoS or brute-force scenario and measure time-to-detection, time-to-mitigation, and impact on legitimate players.



Conclusion

Hardening your Valheim server in 2026 demands kernel-level defenses that operate at XDP and nftables layers, process isolation via systemd sandboxing, proactive patch management, and centralized observability across your entire fleet. By combining stateless sub-microsecond packet filtering with stateful connection tracking and per-IP rate-limits, you can absorb multi-gigabit floods, block exploit probes, and maintain sub-10ms latency for genuine players—all without vendor lock-in or opaque black-box appliances. The result: a resilient, auditable, and cost-effective security posture that scales from a 4-slot friends-only realm to a 100+ slot public community.



FAQ

Does XDP filtering break Steam's server browser queries on UDP 2457?

No. Configure your XDP allow_only rule to permit UDP 2456–2458, and Steam's A2S_INFO / A2S_PLAYER queries will pass through. The XDP program matches on destination port and protocol; it does not inspect application-layer Steam protocol fields, so legitimate query packets are indistinguishable from game traffic and both are accepted.

Can I rate-limit by bandwidth (MB/s) instead of packets-per-second in XDP?

No. The PAKKT XDP engine is stateless and operates on a per-packet basis; it cannot accumulate byte counters or enforce sliding-window rate-limits. For byte-based rate-limiting, use nftables with the limit rate … bytes/second syntax in the stateful input chain, which tracks cumulative throughput per connection or per source IP via the conntrack subsystem.

How do I whitelist my own IP so I never get rate-limited when administering the Valheim server?

Add your IP to both the XDP whitelist BPF map (so it bypasses the global max_pps cap) and an nftables set with an early accept rule. In PAKKT's dashboard, navigate to the Whitelist tab, click Add IP, and enable "Sync to XDP + nftables." The agent will atomically update both layers within 30 seconds, ensuring your SSH and game connections are never throttled even during an ongoing attack.

Protect your servers

Deploy PAKKT in 30 seconds

Dual-layer kernel protection. XDP + nftables. Driven from a central panel. 7-day free trial.