Docker breaks KVM Bridge – Fixed!

 

I recently enabled docker on my desktop PC running Ubuntu 20.04LTS … and it ended up breaking Bridged Networking on my VirtManager/KVM Virtual Machines (NAT still works). It turns out that (1) docker sets up some broad rules in the iptables firewall (2) even directly bridged traffic in KVMs goes through the iptables firewall and (3) the rules set by docker messes up the VM traffic.
 
After some googling I fixed this with:
 
$ sudo systemctl edit docker.service
 
[Service]
ExecStartPre=/bin/sh -c “/usr/sbin/iptables -D FORWARD -p all -i br0 -j ACCEPT || true”
ExecStartPre=/usr/bin/iptables -A FORWARD -p all -i br0 -j ACCEPT
 
$ sudo reboot
 
This creates an overlay file to systemd’s docker settings, that will tweak the iptables firewall rules so that they work better with KVM. Change “br0” to your bridge device interface.
 
References: https://bbs.archlinux.org/viewtopic.php?id=233727

 

Originally created with EverNote at 20201230T021302Z

You may also like...