This works perfectly with VirtualBox in their "bridged" network mode, so I know it can be done. I need to get it working with QEMU because VirtualBox doesn't support the architecture that I need for this project.
Here's what I've done so far based on hours of googling:
Installed TUNTAP for OS X
Told OS X to supposedly forward all packets, even ARP: (NOTE: This doesn't appear to work.)
$ sudo sysctl -w net.inet.ip.forwarding=1 $ sudo sysctl -w net.link.ether.inet.proxyall=1 $ sudo sysctl -w net.inet.ip.fw.enable=1
Created a bridge:
$ sudo ifconfig bridge0 create $ sudo ifconfig bridge0 addm en0 addm tap0 $ sudo ifconfig bridge0 up $ ifconfig bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether ac:de:xx:xx:xx:xx Configuration: priority 0 hellotime 0 fwddelay 0 maxage 0 ipfilter disabled flags 0x2 member: en0 flags=3<LEARNING,DISCOVER> port 4 priority 0 path cost 0 member: tap0 flags=3<LEARNING,DISCOVER> port 8 priority 0 path cost 0 tap0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 ether ca:3d:xx:xx:xx:xx open (pid 88244)
-Iin the hopes that it enables promiscuous mode on the wifi device:
$ sudo tcpdump -In -i en0
Run QEMU using the bridged network instructions:
$ qemu-system-x86_64 -cdrom mfsbsd-9.2-RELEASE-amd64.iso -m 1024 \ -boot d -net nic -net tap,ifname=tap0,script=no,downscript=no
But the guest system never gets a DHCP lease:
tcpdump -ni tap0, I see lots of traffic from the wireless network. But if I
tcpdump -ni en0, I don't see any DHCP traffic from the QEMU guest OS.
Update 1: I tried
sudo defaults write "/Library/Preferences/SystemConfiguration/com.apple.Boot" "Kernel Flags" "net.inet.ip.scopedroute=0" and rebooting per this mailing list suggestion, but this didn't help. In fact, it made VirtualBox bridged mode stop working.
Update 2: Interestingly, the virtual interface on the QEMU guest only gets broadcast packets. Maybe I need to add a route somehow? Hmm...