Back to Blog
DNS 4 min readLast updated

Enforcing DNS Compliance with NAT Redirect — No Device Escapes the Resolver

IoT devices hardcode DNS resolvers. DNAT redirect rules intercept all port 53, 853, and 123 traffic and redirect to the Pi, regardless of the destination the device specified.

On any network with heterogeneous IoT devices, you will encounter hardcoded DNS resolvers. A cheap camera ships with 8.8.8.8 baked in. A smart TV forces 1.1.1.1. A NAS defaults to its manufacturer's DNS server in Taiwan. If your network architecture assumes all devices use the self-hosted resolver, you're wrong — and your blocklists don't apply.

The Hardcoded Resolver Problem#

DHCP can only suggest a DNS server. A device can ignore the DHCP offer and use any resolver it wants. IoT manufacturers, in particular, often hardcode resolvers to avoid the perception of a laggy bootup while waiting for DHCP. The device powers on, the bootloader immediately starts DNS queries to 8.8.8.8, and by the time DHCP has even completed, the device has already bypassed your resolver.

On a network where all DNS is supposed to flow through a self-hosted Technitium instance with custom blocklists and split-horizon zones, a hardcoded resolver is a complete bypass of your security posture.

DNAT Redirect: Intercept and Redirect#

The fix is DNAT redirect rules on the gateway. A redirect rule intercepts any outbound traffic on a specific port and rewrites the destination IP before the packet leaves the gateway. The device thinks it's querying 8.8.8.8, but the gateway rewrites the destination to the internal Pi resolver. The device receives the response and has no idea the destination was modified.

Redirect rules apply to all VLANs. A device on the Skynet VLAN attempts to query 8.8.8.8:53. The gateway's DNAT redirect intercepts the packet, rewrites the destination to the internal Pi's DNS listener, and forwards it to the Pi. The Pi responds, and the device receives the response it expected.

Port 53 (DNS), Port 853 (DoT), and Port 123 (NTP)#

Three protocols need redirect coverage.

Port 53 UDP and TCP (DNS) — the most common case. Redirect all outbound traffic on port 53 to the Pi.

Port 853 TCP (DNS over TLS) — increasingly common on modern devices. DoT provides encryption, which is good for privacy, but it also means you can't inspect the query with passive monitoring. Still, the redirect works the same way: intercept port 853, redirect to the Pi's DoT listener.

Port 123 UDP (NTP) — every device that sets its own time is a candidate for a hardcoded NTP server. A Raspberry Pi 5 runs Chrony as an NTP server. Redirect all outbound port 123 traffic to the Pi's NTP listener, and every device on the network syncs time to the Pi instead of pool.ntp.org or the manufacturer's NTP server.

The Loop Prevention Problem#

The internal Pi resolver makes outbound DNS queries (to Cloudflare and Quad9, now over DNS-over-HTTPS) and outbound NTP queries (to pool.ntp.org). If the MGMT VLAN has a DNAT redirect rule for port 53 or 123, the Pi's own queries get hairpinned back to itself, creating a loop. The queries arrive at the gateway from the MGMT subnet, the redirect rule matches, the destination gets rewritten to the Pi, and the gateway hairpins the packet back to the source VLAN.

The Pi itself needs to be excluded from redirect rules. On the MGMT VLAN, the redirect rules for port 53 and 123 are disabled. The Pi can make outbound queries to its upstream resolvers without hitting the redirect. The NTP redirect is also not configured for MGMT for this reason.

The DoT redirect has the same issue. Port 853 redirect on MGMT would hairpin the Pi's own DoT queries back to itself. It's disabled.

Verification: Confirm Redirection Works#

From any VLAN client, run nslookup google.com 8.8.8.8. Even though you've explicitly specified 8.8.8.8 as the resolver, the redirect intercepts the query and returns the response from the Pi. If the Pi has a blocklist entry for google.com, you get 127.0.0.1. If the Pi resolves it normally, you get the real IP. The device has no way to know its query was redirected.

Guest VLAN: Clean DNS, Redirected#

The Guest VLAN also has redirect rules. Guest DNS queries go to the internal Pi resolver, but the Pi does not apply the same blocklists to Guest traffic. Guest users receive clean, unadulterated DNS resolution — just routed through the local resolver for speed and consistency, not for filtering.