I want to install qemu on macos and use a tap device in the vm.
Below is my step.
-
install qemu
brew install qemu
-
install tuntap, after installation, I can see tap devices in /dev/tapX
brew install tuntap
-
create a bridge
sudo ifconfig bridge0 create
-
configure ip address on bridge0
sudo ifconfig bridge0 192.168.122.1/24
-
sudo ifconfig bridge0 up
-
start my qemu vm (which is centos), and log in to the vm, mannually configure the static ip address as 192.168.122.101/24, gateway is 192.168.122.1.
sudo qemu-system-x86_64 -m 2048 -vga virtio -show-cursor -usb -device usb-tablet -drive file=centos-temp.qcow2,if=virtio -accel hvf -cpu host -net nic -net tap,ifname=tap0,script=no,downscript=no
-
after the vm starts, I can see a tap0 in the output of ifconfig, and I add tap0 to bridge0
sudo ifconfig bridge0 addm tap0
however, after theses steps, I can't ping 192.168.122.1 in my vm, and neither ping 192.168.122.101 in my mac host.
What am I doing wrong?
Best Answer
I struggled with this as well. Try the macports version of qemu instead of the one from homebrew. It includes a patch needed to get tap working properly.