“No route to host” after nftables blocks traffic from a bridge
When you add a bridge to a Linux host and start using nftables for packet filtering, a common pitfall is that the bridge stops forwarding packets altogether. The symptom is a “no route to host” error on any host that tries to reach the bridged network. The error is misleading: the kernel has a route, but the packet is dropped before it can leave the bridge. This article walks through why it happens, how to detect it, and how to fix it while keeping a tight security posture.
Why a bridge can be invisible to nftables
A Linux bridge is a virtual switch that forwards Ethernet frames between its ports. From the kernel’s point of view, a bridge is a network device that has its own MAC address and a set of bridge ports (the enslaved interfaces). When a packet arrives on a port, the kernel checks the bridge’s forwarding database (FDB) and forwards the frame to the destination port. If the packet is destined for the host itself, the bridge hands it to the host’s network stack.
nftables operates on netfilter hooks that are attached to specific points in the packet processing pipeline. For a bridged packet, the relevant hooks are:
| Hook | Where it runs | Typical use |
|---|---|---|
bridge | Bridge bridge | Handles packets that are forwarded between bridge ports |
input | Host input | Handles packets destined for the host |
forward | Bridge forward | Handles packets that are forwarded through the bridge but not destined for the host |
If you create a rule that matches all traffic on the bridge interface and drop it, you effectively block all forwarding. The host still receives packets destined for itself (because the input hook is separate), but other hosts on the bridged network cannot reach the host or each other.
Reproducing the problem
Create a bridge
ip link add name br0 type bridge ip link set dev br0 upAdd two dummy interfaces
ip link add name dummy0 type dummy ip link add name dummy1 type dummy ip link set dev dummy0 up ip link set dev dummy1 up ip link set dev dummy0 master br0 ip link set dev dummy1 master br0Assign IPs
ip addr add 10.0.0.1/24 dev dummy0 ip addr add 10.0.0.2/24 dev dummy1Add a permissive nftables rule
nft add table inet filter nft add chain inet filter forward { type filter hook forward priority 0 \; policy accept \; } nft add chain inet filter input { type filter hook input priority 0 \; policy accept \; }Ping across the bridge
ping -c 1 10.0.0.2Success.
Add a blocking rule
nft add rule inet filter forward ip daddr 10.0.0.2 dropPing again
ping -c 1 10.0.0.2You’ll see:
Destination Host UnreachableorNo route to host. The kernel’s routing table still shows a route to 10.0.0.2, but the packet never leaves the bridge.
Diagnosing the issue
1. Verify the bridge FDB
bridge fdb show
If the destination MAC is missing, the bridge will flood the packet. That’s normal for a new network. The drop comes from nftables, not the bridge.
2. Check nftables rules
nft list ruleset
Look for rules in the forward chain that match the packet. The drop rule is the culprit.
3. Inspect netfilter hooks
cat /proc/net/netfilter/nf_conntrack
If you see many entries for the bridge, the kernel is processing the packets but they’re being dropped.
4. Use tcpdump on the bridge
tcpdump -i br0 -n
You’ll see the packet arriving and then disappearing. No REJECT or ICMP unreachable is generated because the drop is silent.
The root cause: rule placement
When you add a rule to the forward chain that matches a packet destined for a bridged host, the packet is dropped before the bridge can deliver it to the host’s input chain. The kernel does not generate an ICMP error for a dropped packet in the forward chain; it simply discards it. Therefore the source host receives a “no route to host” error from its own routing logic, not from the kernel.
Fixing the problem
1. Use a more specific rule
Instead of dropping all traffic to a particular IP, allow traffic that is actually destined for the host. The host’s MAC address is known, so you can match on the Ethernet destination.
nft add rule inet filter forward ether dhost $(ip link show br0 | awk '/ether/ {print $2}') accept
This rule allows packets that the bridge forwards to the host’s MAC, effectively re‑enabling local delivery.
2. Separate host traffic from forwarding
Create a dedicated chain for host traffic and use it in the input hook. Then keep the forward chain clean.
nft add chain inet filter host { type filter hook input priority 0 \; policy accept \; }
nft add rule inet filter host ip daddr 10.0.0.1 accept
Now, any packet that matches the host’s IP will be accepted in the input chain, regardless of what happens in forward.
3. Use bridge hook for bridge‑specific rules
If you need to block traffic between bridge ports but still allow traffic to the host, use the bridge hook.
nft add chain inet filter bridge { type filter hook bridge priority 0 \; policy accept \; }
nft add rule inet filter bridge ip daddr 10.0.0.2 drop
The bridge hook runs after the bridge has decided to forward the packet but before it is handed to the host. This keeps the host’s input chain untouched.
4. Keep a minimal default policy
A common hardening pattern is to set the default policy of the forward chain to accept and only drop explicitly. That way, accidental drops are less likely.
nft delete rule inet filter forward 1
nft add rule inet filter forward policy accept
Then add only the rules you need.
Practical example: a secure but functional bridge
Suppose you run a home lab with a VM bridge (br0) that connects two VMs: a web server (10.0.0.10) and a database server (10.0.0.20). You want to:
- Allow all traffic between the VMs.
- Block any traffic from the host to the VMs (to prevent accidental exposure).
- Log any dropped packets for audit.
# Create the bridge and VMs (omitted for brevity)
# nftables setup
nft add table inet filter
nft add chain inet filter forward { type filter hook forward priority 0 \; policy accept \; }
nft add chain inet filter host { type filter hook input priority 0 \; policy accept \; }
# Block host to VMs
nft add rule inet filter host ip daddr 10.0.0.10 drop
nft add rule inet filter host ip daddr 10.0.0.20 drop
# Log dropped packets
nft add rule inet filter forward log prefix "BRIDGE DROP: " drop
Now the bridge forwards traffic between the VMs, but any attempt from the host to reach them is dropped and logged. The log entries can be forwarded to a syslog server for compliance.
Trade‑offs and security implications
| Approach | Pros | Cons | Security impact |
|---|---|---|---|
Drop on forward chain | Simple, fast | Blocks host traffic, no ICMP feedback | Harder to debug, but good for strict isolation |
Accept on bridge hook | Keeps host traffic separate | Requires careful rule ordering | Clear separation of concerns |
Separate host chain | Explicit host policy | More rules to maintain | Easier to audit host traffic |
| Logging drops | Visibility | Log volume can grow | Useful for forensic analysis |
Choose the pattern that matches your operational model. For a production server, the separate host chain is usually the safest, because it keeps host‑specific rules isolated from forwarding logic.
Common pitfalls
Using
ip daddron a bridge
Theip daddrmatch works on the IP header, but bridge forwarding happens at layer 2. If the packet is not yet encapsulated in an IP header (e.g., ARP), the rule will not match. Useether dhostfor MAC‑level filtering.Missing
policy accept
If you delete the default policy and forget to add a new one, the chain defaults todrop. This can silently block all traffic.Rule order matters
nftables evaluates rules top‑to‑bottom. A broaddroprule placed before a specificacceptwill override it. Keep the rule set ordered from most specific to most general.Bridge FDB aging
If the bridge’s FDB entry ages out, the packet will flood. Ensure that the bridge’sageing_timeis appropriate for your network.
Troubleshooting checklist
| Step | Command | What to look for |
|---|---|---|
| 1 | ip route show | Verify route to the destination exists |
| 2 | bridge fdb show | Ensure the destination MAC is known |
| 3 | nft list ruleset | Confirm no blanket drop in forward |
| 4 | tcpdump -i br0 -n | Observe packet flow |
| 5 | journalctl -u nftables | Check for nftables logs |
| 6 | syslog | Look for logged drop events |
If after these steps the packet still disappears, consider temporarily disabling nftables to isolate the problem:
systemctl stop nftables
If the ping succeeds, the issue is definitely in the nftables configuration.
Keeping the bridge secure in the long term
- Regularly audit rules: Use
nft list rulesetand compare against a baseline. - Use stateful rules sparingly:
ct state established,related acceptcan be useful but may open unintended paths if misconfigured. - Leverage
bridgehook for VLAN tagging: If you use VLANs, filter onvlan vidin thebridgechain. - Integrate with systemd: Create a unit that reloads nftables on bridge changes.
- Monitor logs: Forward nftables logs to a centralized syslog server.
Final thoughts
The “no route to host” error after adding nftables to a bridge is a classic symptom of rule placement. By understanding the distinct hooks (bridge, forward, input) and the difference between layer‑2 and layer‑3 matching, you can craft rules that preserve connectivity while maintaining isolation. The patterns shown here—specific MAC matching, dedicated host chains, and bridge‑specific hooks—are battle‑tested in both homelab and production environments.
Happy bridging, and keep your firewalls tight.
See also
- Application-Level Firewalls
- Fixing a Broken HTTPS on a 1‑GB VPS: Certbot, Nginx, and File Permissions
- Using systemd‑journald Filters to Stop Spurious SSH Login Alerts
- Diagnosing a DNS cache miss after a systemd‑resolved restart
- Using journalctl to hunt for rogue SSH key injections
- Why nftables dropped my VPN traffic and how to fix it