QEMU Network Problem When Run With Docker

如果 Docker 和 QEMU 同時執行時,QEMU 內部透過 tap interface bridge 到 host network 的網路會出不去

這個問題的原因是 Docker 起來之後,會將 iptables 的 packet forward 預設變成 DROP

這時可以在 Docker 起來的時候將 bridge interface 加到 iptables 規則內即可,首先編輯 systemd docker service

EDITOR=vim sudo -E systemctl edit docker

加上這一段

[Service] 
ExecStartPre=/sbin/iptables -A FORWARD -p all -i br0 -j ACCEPT 
ExecStopPost=/sbin/iptables -D FORWARD -p all -i br0 -j ACCEPT


再重啟你的 Docker 就好了

sudo systemctl stop docker 
sudo systemctl start docker 

要不然就簡單一點,將 FORWARD rule 從預設 DROP 變成 ACCEPT

[Service] 
ExecStartPre=/sbin/iptables -P FORWARD ACCEPT 

ref
[SOLVED] Docker breaks existing bridge I use for KVM/QEMU

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>