How do I create a wifi network bridge with qemu on OS X?

Posted by a paid nerd on Super User See other posts from Super User or by a paid nerd
Published on 2013-11-06T19:44:10Z Indexed on 2013/11/07 4:00 UTC
Read the original article Hit count: 374

Filed under:
|
|
|

I grabbed a small FreeBSD live CD and QEMU, and I'm trying to bridge my Mac OS X 10.8 wifi connection so that the guest OS is available on my LAN. However, the guest OS never gets a DHCP lease.

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:

  1. Installed TUNTAP for OS X

  2. 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
    
  3. 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)
    
  4. Started tcpdump with -I in the hopes that it enables promiscuous mode on the wifi device:

    $ sudo tcpdump -In -i en0
    
  5. 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:

freebsd

If I 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.

Any ideas?

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.

© Super User or respective owner

Related posts about osx

Related posts about networking