Flaky DNS on a Raspberry Pi Bridge – A Quick Debug Guide
Running a Pi as a network bridge can feel like a walk‑through of a maze. The bridge interface (br0) sits right between your LAN and the Pi’s Wi‑Fi or Ethernet, and if DNS starts to act up, it’s usually the bridge’s handling of UDP or some nftables rule that’s tripping up. Below is a no‑frills, coffee‑talk style walk‑through to isolate and patch the problem while keeping the bridge tight.
1. Verify the Bridge Forwarding Path
ip link show br0
cat /proc/sys/net/bridge/bridge-nf-call-iptables
cat /proc/sys/net/bridge/bridge-nf-call-ip6tables
The bridge-nf-call-iptables flag must be 1 for nftables to see traffic that passes through the bridge. If you see a 0, just flip it:
echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables
echo 1 > /proc/sys/net/bridge/bridge-nf-call-ip6tables
Make it stick:
/etc/sysctl.d/99-bridge.conf
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
2. Inspect nftables Rules for UDP 53
A blanket drop that catches every UDP packet is a classic rookie mistake. Dump the current nftables table:
nft list table inet filter
Look for something like:
ip protocol udp counter drop
If that’s there, drop the rule and add a specific allow for DNS:
nft delete rule inet filter forward 1
nft add rule inet filter forward ip protocol udp counter accept udp dport 53
If you still need a general drop, add a counter first so you can see how many packets get tossed:
nft add rule inet filter forward ip protocol udp counter drop
3. Test DNS Resolution from the Bridge
Run a quick query from the Pi itself and from a client on the bridged network:
dig @127.0.0.1 google.com
If the Pi can resolve but the clients can’t, the bridge path is at fault. If both fail, it’s probably the DNS server (e.g. systemd-resolved) that’s mis‑configured.
4. Check systemd-resolved Status
systemctl status systemd-resolved
resolvectl status
Make sure the DNS server is listening on the bridge interface:
netstat -lnp | grep :53
If you only see it bound to lo, re‑enable the service and tweak the stub listener:
systemctl restart systemd-resolved
sudo sed -i 's/#DNSStubListener=yes/DNSStubListener=yes/' /etc/systemd/resolved.conf
systemctl restart systemd-resolved
5. Capture Bridged Traffic
Still no luck? Grab a packet dump on the bridge:
tcpdump -i br0 udp port 53 -vvv -c 100
Watch for missing ACKs or retransmissions. A pattern of dropped packets usually points back to a firewall rule.
6. Harden the Bridge
Once the DNS flow is steady, lock down the bridge so you don’t end up with a soft‑open port for everything:
nft add rule inet filter forward ip protocol icmp counter accept
nft add rule inet filter forward ip protocol tcp counter accept tcp dport {22,80,443}
nft add rule inet filter forward ip protocol udp counter accept udp dport {53,123}
nft add rule inet filter forward drop
That keeps the essentials while blocking the rest.
7. Monitor Continuously
A tiny systemd unit that pings DNS every minute can be a lifesaver:
systemd-run --unit=dns-bridge-monitor.service --on-success=restart \
/usr/bin/timeout 60s dig @127.0.0.1 google.com
If the command fails, the unit restarts and logs the error – an early warning you’ll appreciate.
Links
- kernel.org – Bridge Netfilter
- docs.kernel.org – nftables
See also
- Application-Level Firewalls
- Nftables log‑filter tricks to find hidden routing loops on a bridged LAN
- When systemd‑resolved stalls: Diagnosing and fixing the 1‑second lookup delay
- Resolve DNS Cache Poisoning on Raspberry Pi with resolvectl – One‑Step Fix
- Fixing a Crashed Btrfs Subvolume After Unexpected Reboot
- When /etc/hosts Won’t Resolve: A Quick Systemd‑Resolved Fix