Threat Model for Game Servers
Before configuring defenses, understand what VPS-level protection can and cannot stop:
| Attack Type | Description | VPS-Level Defense |
|---|---|---|
| UDP amplification | Most common for game servers | Rate limiting helps |
| TCP SYN flood | Connection exhaustion | SYN cookies + sysctl |
| Application-layer | Bot spam, login brute-force | Fail2ban effective |
| Volumetric (100+ Gbps) | Saturates upstream link | Requires upstream DDoS protection |
Be honest with expectations: VPS-level protection handles targeted harassment and small-scale attacks. For large volumetric DDoS, you need upstream protection - consider RamNode's DDoS-filtered IP add-on.
UFW Hardening
Default deny incoming, then allow only what your servers need:
ufw default deny incoming
ufw default allow outgoing
# Management
ufw allow 22/tcp # SSH
ufw limit 22/tcp # Rate limit SSH (6 attempts per 30 sec)
ufw allow 80/tcp # Panel HTTP
ufw allow 443/tcp # Panel HTTPS
ufw allow 2022/tcp # Wings daemon
# Game servers
ufw allow 25565/tcp # Minecraft Java
ufw allow 19132/udp # Minecraft Bedrock
ufw allow 2456:2458/udp # Valheim
ufw allow 8211/udp # Palworld
ufw enableufw limit works for SSH but is insufficient for UDP game traffic - use iptables hashlimit for UDP ports (next section).
iptables Rate Limiting (UDP)
Per-IP UDP rate limiting prevents a single source from flooding your game ports:
# Rate limit Valheim UDP to 100 packets/sec per source IP
iptables -I INPUT -p udp --dport 2456:2458 \
-m hashlimit --hashlimit-name valheim \
--hashlimit-above 100/sec \
--hashlimit-mode srcip \
--hashlimit-burst 200 \
-j DROP
# Rate limit Palworld UDP similarly
iptables -I INPUT -p udp --dport 8211 \
-m hashlimit --hashlimit-name palworld \
--hashlimit-above 100/sec \
--hashlimit-mode srcip \
--hashlimit-burst 200 \
-j DROP
# Save rules persistently
apt install -y iptables-persistent
netfilter-persistent saveThe --hashlimit-burst allows initial bursts (important for game connections) while capping sustained traffic.
Fail2ban for Game Servers
Fail2ban is most effective for SSH, the Panel web interface, and Minecraft auth logs:
apt install -y fail2ban
# Create local config
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local[sshd]
enabled = true
port = 22
maxretry = 5
bantime = 3600
[nginx-http-auth]
enabled = true
port = http,https
filter = nginx-http-auth
logpath = /var/log/nginx/error.log
maxretry = 5
bantime = 3600systemctl restart fail2ban
fail2ban-client statusNote: fail2ban is less relevant for UDP game ports (no login handshake to detect), but critical for protecting the Panel and SSH.
Kernel / sysctl Tuning
Optimize the kernel for high-throughput UDP game traffic:
# Increase UDP receive/send buffers
net.core.rmem_max = 134217728
net.core.wmem_max = 134217728
net.core.rmem_default = 65536
net.core.netdev_max_backlog = 262144
# SYN flood protection
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 65536
net.ipv4.tcp_fin_timeout = 15
# Reverse path filtering (blocks spoofed source IPs)
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1sysctl -p /etc/sysctl.d/99-gameserver.confWhat each setting does:
- rmem_max/wmem_max - Larger UDP buffers prevent packet drops during traffic spikes
- tcp_syncookies - Protects against SYN flood attacks without consuming connection table entries
- rp_filter - Drops packets with spoofed source IPs, common in amplification attacks
- tcp_fin_timeout - Faster cleanup of dead connections frees resources sooner
Docker Network Optimization
Tune Docker networking for game server traffic:
- Set Docker network MTU to match your VPS network (usually 1500)
- Increase
net.core.netdev_max_backlogfor high-traffic containers - Per-container sysctls can be set via docker-compose or Pelican Panel environment variables
CPU Governor + IRQ Affinity
Set the CPU governor to performance mode for consistent game server responsiveness:
apt install -y cpufrequtils
cpufreq-set -g performance
# Verify
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governorFor multi-core VPS, you can pin network IRQs to specific cores to reduce interrupt overhead:
cat /proc/interrupts | grep ethThis matters for game servers with bursty packet rates - especially Valheim and Palworld during combat or base raids.
Disk I/O for Game Servers
Optimize disk I/O for NVMe SSDs:
# Set I/O scheduler to mq-deadline for NVMe
echo mq-deadline > /sys/block/nvme0n1/queue/scheduler
# Set game server processes as I/O priority
ionice -c2 -n0 -p $(pgrep -f valheim_server)
# Add noatime to game world mount points in /etc/fstab
# Reduces inode write overhead from world savesMonitoring Under Load
When you suspect an attack or performance issue:
# Monitor bandwidth in real time
nload
# or
iftop -i eth0
# Check for packet drops
cat /proc/net/softnet_stat
# UDP error statistics
netstat -s | grep -i udp
# Set up bandwidth alerting
apt install -y vnstat
vnstat -l # live traffic monitorSeries Complete
You now have a production-ready game server infrastructure: Pelican Panel for management, Minecraft with crossplay, Valheim and Palworld with auto-restart and backups, multi-game resource isolation, and DDoS protection with kernel tuning.
As your community grows, resize your VPS without reinstalling - RamNode supports live plan upgrades.
This guide is part of the Game Server Hosting series:
