English
简体中文繁體中文EnglishРусскийفارسی

Home › Guides › Everything through the tunnel

Everything through the tunnel

Route everything through WireGuard: AllowedIPs 0.0.0.0/0, forwarding and NAT on the server, DNS, IPv6 leaks and how to check the result.

All traffic goes through the tunnel
All traffic goes through the tunnel Thomas Bresson, CC BY 2.0

Two lines on the device

In [Interface] and [Peer]
DNS = 1.1.1.1
AllowedIPs = 0.0.0.0/0, ::/0

0.0.0.0/0 is all IPv4, ::/0 all IPv6. Leave the second out and IPv6 keeps using the old network.

The server forwards and rewrites

Add to the server's [Interface]
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
Turn forwarding on
echo 'net.ipv4.ip_forward=1' | sudo tee /etc/sysctl.d/99-wg.conf
sudo sysctl --system

The interface may not be eth0; ip route get 1.1.1.1 prints it after dev.

Check

  1. IPAny what-is-my-IP page shows the server
  2. DNSNames fail but IPs work: the DNS line is wrong
  3. IPv6Your local IPv6 still shows: ::/0 is missing
From top to bottom
AdLuoboyunNo server abroad? There are ready lines to try: 1 GB for new accounts, 24 hours, through Clash / Mihomo.See ready lines
I still want my LAN.

On Windows untick Block untunneled traffic, or replace AllowedIPs with ranges that leave the LAN out.

No internet once connected?

Usually forwarding is off or the interface name in the NAT rule is wrong.

Next letterAdd and remove devices

On the same round

Postcodes: WireGuard full tunnel, AllowedIPs 0.0.0.0/0, WireGuard no internet