Quick answer
How do I enable IP forwarding for WireGuard?
To enable IP forwarding, WireGuard servers need net.ipv4.ip_forward=1 (and net.ipv6.conf.all.forwarding=1 for IPv6) into a file under /etc/sysctl.d/ on the TunnelVPS server, loaded with sysctl --system. Add a NAT rule in PostUp and PostDown of wg0.conf. The Linux default is 0, so both steps matter.
In brief
- Why: the kernel default for
net.ipv4.ip_forwardis 0, disabled. - Persist: a file in
/etc/sysctl.d/, loaded bysysctl --system. - NAT: an
iptablesMASQUERADE rule inPostUp, removed inPostDown. - IPv6 caution: forwarding changes how the kernel treats router advertisements.
What are the 4 steps to turn forwarding on?
| Step | Where | What to do |
|---|---|---|
| 1 | Server | Write the forwarding keys into /etc/sysctl.d/99-wireguard.conf. |
| 2 | Server | Load them with sysctl --system and check the values. |
| 3 | Server | Add NAT lines to PostUp and PostDown in wg0.conf, with your network interface. |
| 4 | Server | Restart wg-quick@wg0 and test a site from a device. |
Why does WireGuard need IP forwarding?
Because the server must pass packets from the wg0 interface to its internet interface, and Linux refuses by default. TunnelVPS read the kernel's ip-sysctl documentation on 16 November 2026. It describes ip_forward as forwarding packets between interfaces, with a default of 0.
The symptom of a missing setting is clear. The device shows a fresh handshake, yet no page loads. Before you enable IP forwarding, WireGuard only reaches the server itself.
How do you make the setting survive a reboot?
Put it in a file under /etc/sysctl.d/ and load it with sysctl --system. The sysctl manual lists /etc/sysctl.d/*.conf first among the folders that --system reads. A setting typed with sysctl -w alone is lost at the next boot.
The IPv6 line is only needed if the tunnel carries IPv6. The WireGuard IPv6 guide covers the addresses and the client side.
cat > /etc/sysctl.d/99-wireguard.conf <<'EOF'
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
EOF
sysctl --system
sysctl net.ipv4.ip_forward net.ipv6.conf.all.forwardingDoes IPv6 forwarding change anything else?
Yes: with forwarding on, the kernel stops accepting router advertisements unless accept_ra is set to 2. The kernel documentation states this for accept_ra. A server that gets its IPv6 address from router advertisements could lose it.
Check how the server's IPv6 is set before you enable IP forwarding for IPv6. Run ip -6 addr and ip -6 route before and after. If the default IPv6 route disappears, set accept_ra to 2 on the internet interface, or keep the tunnel IPv4-only.
Why is NAT needed as well as forwarding?
Because tunnel addresses such as 10.8.0.2 are private, and the internet cannot answer them. Even after you enable IP forwarding, WireGuard clients reach nothing without it. A MASQUERADE rule rewrites each packet to leave from the server's public IPv4. wg-quick runs PostUp after the interface comes up and PostDown after it goes down, and %i stands for the interface name.
Replace eth0 with the name shown after dev in ip route. On Debian, install iptables with apt first if the command is missing.
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADEWhat if UFW is running on the server?
UFW drops forwarded packets unless a route rule allows them. The ufw manual says route rules also need IP forwarding set in /etc/ufw/sysctl.conf, followed by ufw disable and ufw enable.
The UFW port guide gives the ufw route allow line. Inbound UDP and TCP ports are open on the server; the customer chooses the VPN port and sets the firewall. The full server config sits in the one-command install guide.
Forwarding questions
How do I check that IP forwarding is on?
Run sysctl net.ipv4.ip_forward. It prints 1 when forwarding is enabled and 0 when it is not.
Do I need to enable IP forwarding for WireGuard on the client?
No. Only the server forwards packets. A phone or laptop just sends them into the tunnel.
Can I use nftables instead of iptables?
Yes, any NAT tool works. The iptables lines are shown because they are the most common in WireGuard configs.
Is forwarding enough for a tunnel that only reaches the server?
A tunnel that only reaches the server's own address needs no forwarding and no NAT.
Does forwarding open the server to other traffic?
It lets the kernel route between interfaces. The FORWARD rule above accepts only packets coming in from wg0.
Verdict
- Forwarding plus NAT turns a WireGuard link to the server into a full VPN.
- Check IPv6 routes before turning on IPv6 forwarding.
Sources (4)
- IP Sysctl (ip_forward, forwarding, accept_ra) — kernel.org (read 2026-11-16)
- sysctl(8) manual page — Debian (read 2026-11-16)
- wg-quick(8) manual page — man7.org (read 2026-11-16)
- ufw(8) manual page — Ubuntu (read 2026-11-16)
A server to route through
Every plan has one IPv4 and an IPv6 /64. Home costs $6.37 a month on 12 months.
- Built by a person, 1 hour at most after confirmation
- Lost days credited back if a server cannot be delivered
- Pay in BTC, XMR, USDT, USDC, ETH, SOL or LTC
- DomaineGoat LLC · Panama