Fix the “no route to host” error when nftables blocks traffic from a bridge.

“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:

HookWhere it runsTypical use
bridgeBridge bridgeHandles packets that are forwarded between bridge ports
inputHost inputHandles packets destined for the host
forwardBridge forwardHandles 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

  1. Create a bridge

    ip link add name br0 type bridge
    ip link set dev br0 up
    
  2. Add 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 br0
    
  3. Assign IPs

    ip addr add 10.0.0.1/24 dev dummy0
    ip addr add 10.0.0.2/24 dev dummy1
    
  4. Add 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 \; }
    
  5. Ping across the bridge

    ping -c 1 10.0.0.2
    

    Success.

  6. Add a blocking rule

    nft add rule inet filter forward ip daddr 10.0.0.2 drop
    
  7. Ping again

    ping -c 1 10.0.0.2
    

    You’ll see: Destination Host Unreachable or No 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

ApproachProsConsSecurity impact
Drop on forward chainSimple, fastBlocks host traffic, no ICMP feedbackHarder to debug, but good for strict isolation
Accept on bridge hookKeeps host traffic separateRequires careful rule orderingClear separation of concerns
Separate host chainExplicit host policyMore rules to maintainEasier to audit host traffic
Logging dropsVisibilityLog volume can growUseful 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

  1. Using ip daddr on a bridge
    The ip daddr match 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. Use ether dhost for MAC‑level filtering.

  2. Missing policy accept
    If you delete the default policy and forget to add a new one, the chain defaults to drop. This can silently block all traffic.

  3. Rule order matters
    nftables evaluates rules top‑to‑bottom. A broad drop rule placed before a specific accept will override it. Keep the rule set ordered from most specific to most general.

  4. Bridge FDB aging
    If the bridge’s FDB entry ages out, the packet will flood. Ensure that the bridge’s ageing_time is appropriate for your network.


Troubleshooting checklist

StepCommandWhat to look for
1ip route showVerify route to the destination exists
2bridge fdb showEnsure the destination MAC is known
3nft list rulesetConfirm no blanket drop in forward
4tcpdump -i br0 -nObserve packet flow
5journalctl -u nftablesCheck for nftables logs
6syslogLook 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 ruleset and compare against a baseline.
  • Use stateful rules sparingly: ct state established,related accept can be useful but may open unintended paths if misconfigured.
  • Leverage bridge hook for VLAN tagging: If you use VLANs, filter on vlan vid in the bridge chain.
  • 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