Sub topic 15
Troubleshooting a tunnel that will not pass traffic
This chapter assumes you know IP addressing and subnets, the idea of a routing table and default route, and the difference between TCP and UDP. It also assumes you can use a Linux command line. A tunnel that is "up" but passes no traffic usually fails in one of three places: routing, NAT, or MTU. Work through them in order, from the bottom of the stack to the top.
A layered approach
Test from the outside in. Each step rules out one class of fault.
- Can the two endpoints reach each other on their public (outer) addresses?
- Does the tunnel itself establish, for example with a recent handshake?
- Can you ping the far end's inner address?
- Can you reach a host behind the far end?
- Do small packets work while large ones fail?
Missing routes
A tunnel interface is only useful if the routing table sends traffic into it. Check what the kernel will actually do for a destination.
ip route get 10.20.0.5
ip -br addr show gre1If the output names your physical interface instead of the tunnel, the route is missing or a more specific route wins. With WireGuard, AllowedIPs also acts as an access list. Packets for a destination outside every peer's AllowedIPs are dropped. Replies from a peer whose source address is not in its AllowedIPs are dropped too. Check both directions.
NAT and firewall problems
Most tunnels need a specific port or protocol to pass between the endpoints. GRE is IP protocol 47, and ESP is IP protocol 50. Neither has a port, so a firewall that allows only TCP and UDP will block them. WireGuard uses one UDP port, 51820 by default.
A peer behind NAT must send traffic first so the NAT creates a mapping. If the tunnel works for a minute and then goes silent, the mapping probably expired. Setting PersistentKeepalive = 25 on the peer behind NAT refreshes it. You can confirm packets leave and arrive with a capture.
sudo tcpdump -ni eth0 udp port 51820
sudo wg showIn wg show, a missing latest handshake line means the handshake never completed. Suspect a wrong key, a wrong Endpoint, or a blocked port. A handshake that is recent but with a transfer counter showing received bytes of zero points to a return-path problem such as a remote firewall.
MTU black holes
Encapsulation adds headers, so the inner packet must be smaller than the physical link allows. A typical symptom is that ping and DNS work, and TLS handshakes or large downloads hang. Small packets fit, and large ones do not. The cause is often that ICMP "fragmentation needed" messages are filtered, so the sender never learns to shrink its packets.
Probe the path with the Don't Fragment bit set.
ping -M do -s 1372 10.8.0.1If this fails but a smaller -s value succeeds, lower the tunnel MTU or clamp the TCP MSS.
sudo ip link set dev wg0 mtu 1380
sudo iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtuDNS and policy
If you can ping by IP address but names fail, the fault is DNS. Check which resolver the client uses with resolvectl status. A split tunnel may send DNS queries outside the tunnel, so internal names do not resolve. A full tunnel with a resolver that is unreachable from inside the tunnel fails the same way.
Symptom summary
| Symptom | Likely cause | First check |
|---|---|---|
| No handshake | Wrong key, blocked port, bad endpoint | `wg show`, `tcpdump` |
| Works, then stops | NAT mapping expired | `PersistentKeepalive` |
| Ping works, large transfers hang | MTU black hole | `ping -M do -s` |
| IP works, names fail | DNS routing | `resolvectl status` |
| Traffic leaves via the wrong interface | Missing or wrong route | `ip route get` |
Exercise
A WireGuard client shows a recent handshake and can ping 10.8.0.1, but loading a web page through the tunnel hangs after the TLS handshake starts. What is the most likely cause, and how would you test it?
Show answer
An MTU black hole. Small packets such as ping fit, but the larger packets in the TLS exchange exceed the path MTU and are dropped, while ICMP fragmentation-needed messages are blocked. Test with ping -M do -s 1372 10.8.0.1 and smaller sizes to find the largest size that passes, then lower the tunnel MTU or clamp the TCP MSS.
Exercise
Why does a tunnel that works at first become unreachable after a few minutes of idle time when one peer is behind NAT, and what setting fixes it?
Show answer
The NAT device removes its mapping for the idle flow, so inbound packets can no longer reach the peer. Sending a keepalive periodically, such as PersistentKeepalive = 25 in WireGuard, keeps the mapping open.