Gaming & Network Optimization
Low-latency network routing with Cloudflare Warp, WireGuard, and system-level optimizations for competitive gaming on Linux.
Overview
This guide covers network-level optimizations to reduce latency, jitter, and packet loss for competitive gaming on Linux. We'll configure Cloudflare Warp as a WireGuard-based VPN with custom routing, optimize kernel network parameters, and tune system settings for minimal latency.
Prerequisites
Root access required. Tested on Arch Linux with kernel 6.11+. Cloudflare Warp registration (free) needed for WireGuard configuration.
1. Cloudflare Warp + WireGuard Setup
Register Warp Account
# Install warp-cli
pacman -S cloudflare-warp-bin
# Register (free tier)
warp-cli registration new
warp-cli registration license # Optional for WARP+
# Enable and start
systemctl enable --now warp-svc
warp-cli connect
warp-cli mode warp+dohExtract WireGuard Configuration (Advanced)
For custom routing and multi-hop configurations:
# Get WireGuard config from warp-cli
warp-cli export-wireguard-config > /etc/wireguard/warp.conf
# Or manually create with your credentials
# Private key from: warp-cli registration show
# Public key from Cloudflare endpointCustom WireGuard Config with Split Routing
[Interface]
PrivateKey = YOUR_PRIVATE_KEY
Address = 172.16.0.2/32, 2606:4700:110:8a36::2/128
DNS = 1.1.1.1, 1.0.0.1, 2606:4700:4700::1111, 2606:4700:4700::1001
MTU = 1280
# PostUp/PostDown for split routing (gaming traffic only)
PostUp = ip rule add fwmark 0x1234 table 1234; ip route add default dev %i table 1234
PostDown = ip rule del fwmark 0x1234 table 1234; ip route del default dev %i table 1234
[Peer]
PublicKey = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = engage.cloudflareclient.com:2408
PersistentKeepalive = 252. Systemd Networkd Configuration
For fine-grained routing control:
[NetDev]
Name=wg-gaming
Kind=wireguard
Description=Cloudflare Warp Gaming Tunnel
[WireGuard]
PrivateKey=YOUR_PRIVATE_KEY
ListenPort=51820
[WireGuardPeer]
PublicKey=bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=
AllowedIPs=0.0.0.0/0, ::/0
Endpoint=engage.cloudflareclient.com:2408
PersistentKeepalive=25[Match]
Name=wg-gaming
[Network]
DHCP=no
IPv6AcceptRA=no
# Custom routes for gaming servers
[Route]
Destination=162.159.192.0/24 # Cloudflare Gaming
Gateway=_dhcp4
Table=1234
[Route]
Destination=162.159.193.0/24 # Cloudflare Gaming
Gateway=_dhcp4
Table=12343. Kernel Network Optimizations
# TCP Optimizations
net.core.rmem_max = 26214400
net.core.wmem_max = 26214400
net.core.rmem_default = 1048576
net.core.wmem_default = 1048576
net.core.netdev_max_backlog = 5000
net.core.netdev_budget = 600
net.core.netdev_budget_usecs = 8000
net.core.busy_read = 50
net.core.busy_poll = 50
net.core.dev_weight = 64
net.core.dev_weight_rx_bias = 1
net.core.dev_weight_tx_bias = 1
# TCP Buffer Tuning
net.ipv4.tcp_rmem = 4096 1048576 26214400
net.ipv4.tcp_wmem = 4096 1048576 26214400
net.ipv4.tcp_adv_win_scale = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_fack = 1
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_thin_linear_timeouts = 1
net.ipv4.tcp_thin_dupack = 1
# Congestion Control - BBR for gaming
net.ipv4.tcp_congestion_control = bbr
net.core.default_qdisc = fq
# Reduce Latency
net.ipv4.tcp_low_latency = 1
net.ipv4.tcp_no_metrics_save = 1
net.ipv4.tcp_moderate_rcvbuf = 1
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_base_mss = 1024
# Queue Management - fq_codel for fairness
net.core.default_qdisc = fq_codel
# IPv6
net.ipv6.conf.all.forwarding = 1
net.ipv6.conf.default.forwarding = 1
# Disable ICMP redirects (security)
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
# ARP Optimization
net.ipv4.neigh.default.gc_thresh1 = 1024
net.ipv4.neigh.default.gc_thresh2 = 2048
net.ipv4.neigh.default.gc_thresh3 = 4096
net.ipv4.neigh.default.unres_qlen = 3
# Connection Tracking
net.netfilter.nf_conntrack_max = 1000000
net.netfilter.nf_conntrack_tcp_timeout_established = 1200
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 60
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60
# Local Port Range
net.ipv4.ip_local_port_range = 1024 65535
# TCP Keepalive
net.ipv4.tcp_keepalive_time = 60
net.ipv4.tcp_keepalive_intvl = 10
net.ipv4.tcp_keepalive_probes = 6Apply:
sysctl --system4. IRQ Affinity & CPU Isolation
Pin network interrupts to dedicated CPU cores:
[Unit]
Description=Set IRQ Affinity for Network Interfaces
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/set-irq-affinity.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target#!/bin/bash
# Find network interface IRQs
for irq in $(grep -E "(eth|enp|wlan|wlp)" /proc/interrupts | awk '{print $1}' | sed 's/://'); do
# Assign to CPU cores 4-7 (adjust based on your CPU topology)
echo 4-7 > /proc/irq/$irq/smp_affinity_list
done
# Disable irqbalance
systemctl disable --now irqbalance 2>/dev/null || truechmod +x /usr/local/bin/set-irq-affinity.sh
systemctl enable --now irq-affinity.service5. Gaming Traffic Marking with nftables
Mark gaming traffic for WireGuard routing:
#!/usr/sbin/nft -f
table inet gaming {
chain prerouting {
type filter hook prerouting priority mangle; policy accept;
# Mark Steam traffic
tcp dport { 27015-27030, 27036-27037 } meta mark set 0x1234
udp dport { 27015-27030, 27036-27037 } meta mark set 0x1234
# Mark common game ports
tcp dport { 7777, 7778, 27000-27050, 28910, 29900, 29901, 29920 } meta mark set 0x1234
udp dport { 7777, 7778, 27000-27050, 28910, 29900, 29901, 29920 } meta mark set 0x1234
# Mark Discord voice
udp dport 50000-65535 meta mark set 0x1234
# Mark Valorant / Riot Games
tcp dport 443 ip daddr 162.249.0.0/16 meta mark set 0x1234
udp dport { 50000-55000 } ip daddr 162.249.0.0/16 meta mark set 0x1234
# Mark Cloudflare Warp endpoints
ip daddr 162.159.192.0/24 meta mark set 0x1234
ip daddr 162.159.193.0/24 meta mark set 0x1234
}
chain output {
type route hook output priority mangle; policy accept;
# Mark locally generated gaming traffic
tcp sport { 27015-27030, 27036-27037 } meta mark set 0x1234
udp sport { 27015-27030, 27036-27037 } meta mark set 0x1234
}
}# Enable nftables
systemctl enable --now nftables
# Apply gaming rules
nft -f /etc/nftables.d/gaming.nft6. CPU Governor & Scheduler
# Add to GRUB_CMDLINE_LINUX_DEFAULT:
# isolcpus=4-7 nohz_full=4-7 rcu_nocbs=4-7
# (Adjust core numbers for your CPU)
# Then:
grub-mkconfig -o /boot/grub/grub.cfg[Unit]
Description=Set CPU Governor to Performance for Gaming
After=multi-user.target
[Service]
Type=oneshot
ExecStart=/usr/bin/cpupower frequency-set -g performance
ExecStart=/usr/bin/cpupower idle-set -d 1
ExecStart=/usr/bin/cpupower idle-set -d 2
RemainAfterExit=yes
[Install]
WantedBy=multi-user.targetpacman -S cpupower
systemctl enable --now cpupower-gaming.service7. NetworkManager Optimizations
[connection]
wifi.powersave = 0
wifi.scan-rand-mac-address = no
[device]
wifi.scan-rand-mac-address = no
[global]
dns=none
systemd-resolved=false# Disable WiFi powersave permanently
iw dev wlan0 set power_save off
# Verify
iw dev wlan0 get power_save8. Verify & Benchmark
# Check BBR congestion control
sysctl net.ipv4.tcp_congestion_control
# Check qdisc
tc qdisc show dev eth0
# Test latency
ping -c 10 1.1.1.1
ping -c 10 8.8.8.8
# Test with Warp
warp-cli trace 1.1.1.1
# Bufferbloat test
# Run: https://www.waveform.com/tools/bufferbloat
# Game server latency
# Example: ping -c 20 val1.eu.valve.net9. Per-Game Launch Options
Steam Launch Options
# Disable compositing for game
%command% -novid -high -threads 8 -tickrate 128 -cl_forcepreload 1 -allow_third_party_software
# For Vulkan games
VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json %command%
# With gamemode
gamemoderun %command%Lutris / Heroic Games Launcher
Enable:
- Feral GameMode
- MangoHud (Vulkan overlay)
- vkBasalt (CAS sharpening)
gpu_stats
gpu_temp
gpu_power
gpu_core_clock
gpu_mem_clock
vram
ram
cpu_stats
cpu_temp
cpu_power
core_load
fps
frametime
frame_timing
gpu_color=00FF88
cpu_color=00BFFF
ram_color=FFB300
vram_color=FF6B00
background_alpha=0.8
text_size=24
position=top-left
arch=gpu
vulkan_driver=nvidia10. Monitoring & Debugging
# Real-time network monitoring
btop
# or
nethogs -d 1
# WireGuard status
wg show
# Warp status
warp-cli status
warp-cli trace 1.1.1.1
# Latency monitoring
ping -i 0.2 -c 100 1.1.1.1 | tail -5
# Packet capture for debugging
tcpdump -i wg-gaming -nn -v port 27015Complete configuration files, scripts, and automation for this setup are available in the network-gaming-config repository.