Site icon New Generation Enterprise Linux

Stop WireGuard from leaking traffic when your tunnel interface drops

Networking & Firewalls (Nftables/Iptables/WireGuard)

Stop WireGuard from leaking traffic when your tunnel interface drops

Technical Briefing | 12/6/2026

You set up a WireGuard interface, tested connectivity, and everything looked solid. But then you noticed that when the VPN link flaps or the interface goes down, your machine doesn’t just stop talking; it routes traffic out over your default public gateway. That’s a classic kill-switch failure, and it happens because most people assume the kernel handles route cleanup better than it actually does.

Why the default routing table betrays you

The issue is that if you define a default route inside the WireGuard config, it sits in the main table. When the interface disappears, the kernel doesn’t always rip that route out fast enough, or worse, if you use dynamic routing, you end up with stale entries. I have seen this leak internal traffic to public gateways more times than I care to admit. The right way to handle this is via policy routing and nftables marks.

nft add chain inet filter output { type filter hook output priority 0; policy accept; }
nft add rule inet filter output oifname != "wg0" meta mark != 0xca fe ip daddr != 10.0.0.0/8 drop
  • Tag outgoing packets originating from your VPN-bound apps with a specific firewall mark
  • Configure your WireGuard interface to use a secondary routing table that only exists when the link is up
  • Use nftables to explicitly drop any packet not marked with your VPN tag that isn’t destined for a local management subnet

Don’t rely on the interface state alone. By forcing your traffic through a marked policy, you ensure that even if the route table gets corrupted or the interface hangs, the packets have nowhere to go but the bit bucket. Test this by manually bringing the interface down and watching your tcpdump output; if your browser can still ping 8.8.8.8, your policy isn’t holding tight enough.

Linux Admin Automation  |  © www.ngelinux.com  |  12/6/2026
0 0 votes
Article Rating
Exit mobile version