Sub topic 15
Troubleshooting a Tunnel That Will Not Pass Traffic
What this chapter assumes
This chapter assumes you have read the earlier chapters on encapsulation, GRE, IPsec, WireGuard and routing policy. You should be comfortable with routing tables, the difference between TCP and UDP, and a Linux shell. The examples use GRE and WireGuard, but the method applies to any tunnel.
A tunnel that "does not work" can fail in many places. Guessing wastes time. The reliable approach is to test one layer at a time, from the outside in, and to stop at the first layer that fails.
A layered method
A tunnel has two networks. The outer network carries the encapsulated packets between the two endpoints. The inner network is the one you are trying to reach through the tunnel. Most failures come from one of five causes: the outer path is blocked, the tunnel never established, a route is missing, the packet is too large, or name resolution points to the wrong place.
Step 1: check the outer path
Before looking at the tunnel, confirm that the two endpoints can reach each other on the underlay. The tunnel is only as reachable as its outer packets.
ping -c 3 198.51.100.1
ip route get 198.51.100.1ip route get shows which interface and source address the kernel will use. A common surprise is that the outer packets leave through an unexpected interface, or with an unexpected source address, so the peer does not recognise them.
Then check that the right kind of traffic is allowed. Each protocol needs different firewall rules:
| Tunnel | What the firewall must allow |
|---|---|
| GRE | IP protocol 47 (it has no ports) |
| IPsec | UDP 500 and UDP 4500 for IKE, and IP protocol 50 (ESP) when not encapsulated in UDP |
| WireGuard | The configured UDP port, 51820 by default |
| OpenVPN | UDP or TCP 1194 by default, or whatever you configured |
A ping that works proves only that ICMP passes. It says nothing about protocol 47 or UDP 51820. To see whether tunnel packets actually arrive, capture on the outer interface of the receiving host:
sudo tcpdump -ni eth0 'proto 47'
sudo tcpdump -ni eth0 'udp port 51820'If packets leave host A but never appear on host B, something between them drops them. If they appear on B but nothing comes back, the problem is on B or on the return path.
Step 2: confirm the tunnel is established
For stateless tunnels such as GRE, there is no establishment step. The interface being "up" only means it is configured locally. It does not mean the peer exists. Look at the counters instead:
ip -s link show gre1If TX packets increase and RX stays at zero, the outgoing packets are lost or the peer is not replying. If both increase, the tunnel itself works and you should look at routes.
For WireGuard, the handshake is the evidence:
sudo wg showRead the latest handshake line for each peer. If it is missing, no handshake has completed. The usual causes are:
- The endpoint address or port is wrong, or UDP is blocked.
- A public key is mistyped. WireGuard silently ignores packets from unknown keys, so there is no error message.
- The other side has no peer entry for your public key.
If the handshake is recent but transfer counters show data sent and none received, the peer is receiving your packets but dropping them or not answering. That points to AllowedIPs or a return-path problem.
For IPsec, check the security associations with your implementation's tool (for example ipsec statusall with strongSwan). Phase failures usually come from mismatched proposals (encryption or hash algorithms), wrong pre-shared keys or certificates, or incorrect traffic selectors. IKE negotiation also depends on reasonably accurate clocks when certificates are used.
Step 3: check inner routes and AllowedIPs
An established tunnel carries nothing unless the kernel sends packets into it. Ask the kernel directly:
ip route get 10.20.1.5The output should name the tunnel interface, for example dev gre1. If it names eth0, the route is missing or a more specific route wins. Remember that the longest prefix match decides, so a stray /24 on another interface beats your /16 through the tunnel.
WireGuard adds a second layer. AllowedIPs works as both a routing table and an access list:
- For outgoing packets, WireGuard picks the peer whose
AllowedIPscontains the destination. - For incoming packets, it drops anything whose inner source address is not in the sending peer's
AllowedIPs.
So if the remote subnet is missing from AllowedIPs, packets are dropped even when the Linux routing table is correct. If you use wg-quick, it adds kernel routes for you from AllowedIPs. If you configure WireGuard with plain ip commands, you must add them yourself.
Step 4: check the return path and forwarding
Traffic must travel in both directions. Typical return-path faults:
- The remote hosts have a default route that does not point back through the tunnel endpoint. They receive your request but send the reply somewhere else.
- The remote gateway does not forward packets between the tunnel and the LAN. Enable it:
sudo sysctl -w net.ipv4.ip_forward=1- Reverse path filtering (
rp_filter) drops packets that arrive on an interface the kernel would not use to reach the source. This often affects asymmetric setups. - A host firewall
FORWARDchain drops traffic from the tunnel interface.
A capture on the tunnel interface on the remote side shows quickly whether requests arrive and whether replies leave:
sudo tcpdump -ni gre1 icmpIf requests arrive and no replies appear on gre1, the fault is on the remote side. If you see replies on gre1 but they never reach the sender, look at the outer path in the reverse direction.
Step 5: find MTU black holes
The classic symptom is this: ping works, DNS works, a TLS handshake starts, and then the page hangs or a file transfer stalls. Small packets fit. Large ones do not.
Encapsulation adds a header, so the inner packet must be smaller than the outer link's MTU. For WireGuard over IPv4, the overhead is 60 bytes, which gives an inner MTU of 1420 on a standard 1500-byte link. GRE adds at least 24 bytes (20 for the outer IP header and 4 for GRE). If the inner packet exceeds the available space and the Don't Fragment bit is set, a router should send an ICMP "fragmentation needed" message. If a firewall filters that message, the sender never learns, and the packet vanishes. This is a path MTU discovery black hole.
Test it directly with Don't Fragment pings of different sizes:
ping -M do -s 1372 10.8.0.1A payload of 1372 bytes plus 8 bytes of ICMP header and 20 bytes of IP header makes a 1400-byte packet. Raise or lower -s until you find the largest size that passes. The result is your effective tunnel MTU.
Two fixes are common. First, set the tunnel interface MTU to a value that works:
sudo ip link set dev gre1 mtu 1400Second, clamp the TCP maximum segment size on the gateway, so TCP connections negotiate segments that fit:
sudo iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtuMSS clamping fixes TCP only. UDP traffic such as QUIC or DNS over large responses still depends on a correct MTU.
Step 6: consider NAT and stateful devices
NAT breaks tunnels in several ways:
- GRE has no ports, so many NAT devices cannot track more than one GRE tunnel per address.
- Native ESP also has no ports. IPsec avoids this with NAT traversal, which wraps ESP in UDP 4500.
- A NAT mapping for a UDP tunnel expires after an idle period. The first symptom is that the tunnel works, goes quiet, and then stops until the client sends something. Setting
PersistentKeepalive = 25on a WireGuard peer behind NAT keeps the mapping open. - If both ends sit behind NAT, at least one end needs a reachable endpoint, or a relay.
Step 7: check DNS
If you can reach 10.20.1.5 but not intranet.example.com, the tunnel works and name resolution does not. Check which resolver the client uses and whether it can reach the internal zone:
resolvectl status
dig @10.8.0.1 intranet.example.comIn a split tunnel, the DNS server listed in the configuration must be reachable through the tunnel, and the client must actually send internal names to it. In a full tunnel, make sure DNS is not still sent to a local resolver outside the tunnel, because that leaks queries and can return wrong answers for private names.
Quick symptom reference
| Symptom | Likely cause | First check |
|---|---|---|
| No WireGuard handshake | Blocked UDP port, wrong key or endpoint | `wg show`, `tcpdump` on outer interface |
| TX grows, RX stays zero | Peer not replying or return path broken | `tcpdump` on the remote tunnel interface |
| Ping works, large transfers stall | MTU black hole | `ping -M do -s` sweep |
| Tunnel works, then dies when idle | NAT mapping expired | Add keepalive |
| IP works, names fail | DNS not routed through tunnel | `resolvectl status` |
| One direction only | Missing return route or `rp_filter` | `ip route get` on the remote host |
Exercise
A WireGuard client shows a recent handshake and sent bytes, but received bytes stay at zero. Pings to 10.20.1.5 in the remote LAN time out. Name two likely causes and one command for each that would confirm it.
Show answer
First, the server's peer entry may not include the client's inner address in AllowedIPs, or the client's AllowedIPs may not include the remote subnet. Run sudo wg show on both sides and compare. Second, the remote host or gateway may not forward or reply, for example because net.ipv4.ip_forward is 0 or the remote host has no route back to the client's VPN subnet. Run sysctl net.ipv4.ip_forward on the gateway and sudo tcpdump -ni wg0 icmp to see whether requests arrive and replies leave.
Exercise
Small pings through a GRE tunnel succeed, but an HTTPS download stalls after the handshake. What is the likely cause, and how do you test and fix it?
Show answer
An MTU black hole is likely: large packets with the Don't Fragment bit set are dropped, and the ICMP "fragmentation needed" message is filtered. Test with ping -M do -s <size> <inner address> and find the largest size that passes. Fix it by lowering the tunnel MTU with ip link set dev gre1 mtu <value> or by clamping TCP MSS on the gateway with the TCPMSS --clamp-mss-to-pmtu iptables rule.