OPINIONATED OMARCHY
TROUBLESHOOTING CORPUS
790
RECORDS
790
AUDITED
0
UNCHECKED
2388
SOURCES
LIVE
apps-services high occasional DISPUTE

Fix KVM/libvirt bridged networking breaking when Docker starts

archendeavouroscachyosmanjarodockerlibvirtkvmnftablesdesktop
CORRECTED An auditor found the fix wrong or incomplete and rewrote it.
AUDIT NOTE

The core diagnosis (Docker sets the FORWARD policy to DROP and only permits its own interfaces) and the iptables -I FORWARD -i br0 -o br0 -j ACCEPT fix are correct, as is the "iptables": false warning. Two defects: (1) IPForward=yes is obsolete: current systemd.network(5) documents only IPv4Forwarding= and IPv6Forwarding=. IPForward= was removed and pasting it yields an ignored/warned key. (2) Setting "bridge": "br0" in /etc/docker/daemon.json hands your libvirt bridge to the Docker daemon as its default bridge (Docker then attaches containers to it and manages addressing on it). That is not a safe 'alternative' for a bridge already carrying VMs and should not be offered as one.

The cause above was not rewritten and may still contain the error described. The fix below is the corrected version.
RISK

The blunt workaround {"iptables": false} in /etc/docker/daemon.json turns off all of Docker's firewall management. Container NAT/outbound networking and port publishing will break, and containers may end up unfiltered. Prefer the FORWARD rule.

Symptom

My VMs on a br0 bridge had working networking. After installing Docker (or after a reboot where Docker now starts), the VMs get no IP or cannot reach the LAN. Stopping docker.service immediately fixes it.

Cause

Docker inserts iptables rules that set the FORWARD chain policy to DROP and only permit forwarding on its own interfaces, so traffic across your KVM bridge is dropped.

Fix

Preferred fix, unchanged:


sudo iptables -I FORWARD -i br0 -o br0 -j ACCEPT

Persist it the Arch way: save the live ruleset and enable the service that restores it:


sudo iptables-save | sudo tee /etc/iptables/iptables.rules
sudo systemctl enable --now iptables.service

(or add the equivalent accept rule to your /etc/nftables.conf forward chain and enable nftables.service).

Do **not** set "bridge": "br0" in /etc/docker/daemon.json. That makes Docker adopt and manage your libvirt bridge. If you want Docker off your bridge entirely, give it its own with "bip"/a user-defined network instead.

If forwarding is being reset under systemd-networkd, the current option names are IPv4Forwarding=yes (and IPv6Forwarding=yes) in the [Network] section of the relevant .network file. IPForward= no longer exists. Verify with sysctl net.ipv4.ip_forward and sudo iptables -S FORWARD | head.

Verify

With docker.service running, a VM on br0 gets a DHCP lease and can ping the gateway. sudo iptables -S FORWARD | head shows your ACCEPT rule ahead of Docker's DROP.

Sources

docker-breaks-kvm-libvirt-bridge