Quoted Strings

Virtual Machines and Docker with Network Bridging

  2024/03/04

Posted Tag: #Linux
Other Tags: #Windows, #Personal, #All

I looked for this for a long time and tried others before finding it because it was very annoying. Finding this work around allowed me to use Docker for creating and maintaining this site. Hopefully it will help somebody else. I wish I remembered where it got this from but it was a good while ago and many times wiping my computer and installing again in between.

But I use QEMU for virtual machines and I also create a network bridge to use with these virtual machines. Docker will interfere with this network bridge and here is how to correct this. My bridge name here is br10. In terminal, type sudo su for root access, then cd / and paste in these commands changing them for your bridge name of course.

cat <<EOF >/etc/iptables-br10.conf
*filter
:DOCKER-USER - [0:0]
-F DOCKER-USER
-A DOCKER-USER -i br10 -o br10 -j ACCEPT
COMMIT
EOF

cat <<EOF >/etc/systemd/system/iptables-br10.service
[Unit]
Description=Prevent docker from interfering with br10
Before=network-pre.target

[Service]
Type=oneshot
ExecStart=/sbin/iptables-restore -n /etc/iptables-br10.conf

[Install]
WantedBy=multi-user.target
EOF

systemctl enable --now iptables-br10

Now this will load the service whenever you boot stopping Docker from screwing with your network bridge.

Wish to add a comment? Your email address will never be shared with anyone. Please specify a user name for your comment or use anonymous.

Email me a comment to post it.