# How do I enable IP forwarding for WireGuard?

> Enable IP forwarding: WireGuard needs a sysctl file for IPv4 and IPv6, sysctl --system, then NAT lines in PostUp and PostDown. 4 steps.

- URL: https://tunnelvps.com/guides/how-to-enable-ip-forwarding-for-wireguard/
- Last updated: 2026-11-16
- Publisher: TunnelVPS (https://tunnelvps.com)

Without forwarding, devices connect to the server but reach nothing beyond it. One sysctl file and two NAT lines fix that, and survive a reboot.

**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_forward` is 0, disabled.
- **Persist**: a file in `/etc/sysctl.d/`, loaded by `sysctl --system`.
- **NAT**: an `iptables` MASQUERADE rule in `PostUp`, removed in `PostDown`.
- **IPv6 caution**: forwarding changes how the kernel treats router advertisements.

## What are the 4 steps to turn forwarding on?

*Enabling IP forwarding for WireGuard on a TunnelVPS server, 4 steps, per kernel.org and sysctl(8)*

| 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](https://tunnelvps.com/guides/how-to-use-ipv6-with-wireguard/ "How do I set up WireGuard IPv6?") covers the addresses and the client side.

*Turn on forwarding for IPv4 and IPv6, then check*

```bash
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.forwarding
```

## Does 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.

*NAT lines for the [Interface] section of wg0.conf*

```ini
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 MASQUERADE
```

## What 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](https://tunnelvps.com/guides/how-to-open-the-wireguard-port-in-ufw/ "How do I open the WireGuard port in UFW?") 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](https://tunnelvps.com/help/install-wireguard-in-one-command/ "How do I install WireGuard on a TunnelVPS server?").

## 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

1. [IP Sysctl (ip_forward, forwarding, accept_ra)](https://docs.kernel.org/networking/ip-sysctl.html) — kernel.org (read 2026-11-16)
2. [sysctl(8) manual page](https://manpages.debian.org/bookworm/procps/sysctl.8.en.html) — Debian (read 2026-11-16)
3. [wg-quick(8) manual page](https://man7.org/linux/man-pages/man8/wg-quick.8.html) — man7.org (read 2026-11-16)
4. [ufw(8) manual page](https://manpages.ubuntu.com/manpages/noble/en/man8/ufw.8.html) — 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. [Order Home for 12 months](https://tunnelvps.com/app/checkout/?plan=home&term=12m&image=ubuntu-24.04&from=guides-how-to-enable-ip-forwarding-for-wireguard&lang=en) · [Open the port in UFW](https://tunnelvps.com/guides/how-to-open-the-wireguard-port-in-ufw/ "How do I open the WireGuard port in UFW?")

---

TunnelVPS: TunnelVPS rents Linux KVM servers for a personal VPN (WireGuard, Outline or AmneziaWG) in New York, Dallas, Los Angeles, London, Amsterdam and Frankfurt, paid in crypto with no ID document. 5 plans from 2 to 16 GB of RAM and 2 to 6 TB of traffic a month cost the same in all six cities; on the 12-month term each is priced at least 25% under a named comparable plan of a no-KYC crypto host, read on 16 November 2026. The operator is DomaineGoat LLC, Panama.
