Skip to content
Contents
GuidesOpenWrt

How to block internet access for an OpenWrt subnet when WireGuard drops

First, define the protected scope. Assign devices that need network disconnection protection to a separate network zone.

First, define the protected scope. Assign devices that need network disconnection protection to a separate network zone. Under normal conditions, they can only forward traffic to the VPN zone. Remove WAN forwarding policies for this group. The router itself must connect to the WireGuard endpoint via real WAN.

Check DNS queries that clients send to OpenWrt

DNS queries sent from clients to the router count as inbound traffic. If the router receives the query and forwards it upstream via WAN, standard forwarding rule sets cannot handle this step. Use a designated resolver over a tunnel or a dedicated forwarding instance to verify IPv4, IPv6, and application-specific resolution paths. The system management interface retains wired access.

Verify Offline Protection When WAN is Online

Maintain a test request on both the protected network and the regular network. After shutting down the controlled WireGuard peer endpoint, create new IPv4, IPv6, and DNS requests for each group.

From a protected client, record which IPv4, IPv6 and DNS test requests succeed through the tunnel. Stop WireGuard on the remote node and send new requests. Check the WAN capture for any of those test packets sent without encryption. Repeat the same requests from a network explicitly allowed to connect directly as a comparison. Restore the remote node and check both existing and new connections again.

Normal network can still access the internet; the protected network's plaintext WAN shows no new requests. As soon as any traffic leakage is detected, first tighten the corresponding forwarding or DNS resolution path, then restore tunnel acceptance.

Test a working connection, a closed failover path, and recovery from the protected client. · OpenWrt 25.12.6 x86/64 (QEMU/KVM).
Check the terminal output
Test a working connection, a closed failover path, and recovery from the protected client. · OpenWrt 25.12.6 x86/64 (QEMU/KVM).
Test a working connection, a closed failover path, and recovery from the protected client. · OpenWrt 25.12.6 x86/64 (QEMU/KVM). Open the original image

Lab record

I used two OpenWrt 25.12.6 x86/64 VMs. The protected segment entered R1 on br-protected. Its IPv4 and IPv6 traffic used table 177 based on the ingress and source prefix, then went through wg_home to R2. R1 used its physical WAN to reach the peer's numeric endpoint. Dnsmasq relayed queries through R2, and the router used the main table to return replies to the LAN.

With the tunnel up, the fixture saw R2's IPv4 and IPv6. New HTTP requests and all eight UDP/TCP DNS queries failed when either end went down. An existing TCP stream stopped echoing after the local interface went down. Neither fault produced matching cleartext packets on R1 WAN. The deliberately permitted direct WAN control produced 44 such packets. Dual-stack service and DNS returned after the guard and tunnel were restored.

Place these chains in /etc/nftables.d/20-vpn-guard.nft. Find the real WAN device in l3_device and replace eth1. Include each actual uplink. The forwarding chain runs before fw4 can accept established traffic, and the output chain covers cleartext DNS from the router itself. Disable flow offloading and run fw4 check before reloading. The capture covers the listed addresses and ports on a controlled uplink.

chain protected_before_forward {
  type filter hook forward priority -10; policy accept;
  iifname "br-protected" oifname "eth1" counter drop
}
chain protect_resolver_before_output {
  type filter hook output priority -10; policy accept;
  oifname "eth1" meta l4proto { tcp, udp } th dport 53 counter drop
}

R1 WAN capture. The table shows new IPv4/IPv6 HTTP requests, eight DNS queries and packets matching the cleartext fixture filter in each phase.

R1 WAN capture. The table shows new IPv4/IPv6 HTTP requests, eight DNS queries and packets matching the cleartext fixture filter in each phase.

Reference

Related guides

Reference

Check the model, region and hardware revision on the label before selecting firmware.

Explore hardware

Comments