How to bridge vboxnet with Wi-Fi on OS X 10.10 "Yosemite" I am trying to bridge two interfaces on OS X 10.10 "Yosemite" but somehow this does not seem to work for virtual interfaces:



The network on Virtualbox goes over "Host Only Network"



Is there a way to overcome this? I want to bridge 192.168.56.1 with the Wi-Fi in order to make my virtual machines visible to other computers on the internet.
VirtualBox and OS X provide several (no-NAT) methods to connect your VM:

1. The VirtualBox "Bridged Adapter":

First remove bridge1 in Terminal and use a "Bridged Adapter" instead of vboxnet0 in your VM. Go to the Network settings of the respective VM -> Adapter1 -> attached to: and change the type from whatever it is now to "Bridged Adapter" then choose your Wi-Fi interface:



The VM's en0 attached to the bridged adapter has to be configured with a unique IP in the same network range as the hosts interface IP.

Example:  


My hosts en1 config: network: 192.168.1.0/24 IP: 192.168.1.2 gateway: 192.168.1.1
The VM's eth0 config: network: 192.168.1.0/24 IP: a free and unique IP-address in the range 192.168.1.3-192.168.1.254 gateway: 192.168.1.1


If you want to make the VM accessible to other computers in the WAN (internet) (e.g. a web-server) you have to forward the respective ports in the router to the VM's IP. The VM can be accessed by all other computers in the same network (192.168.1.0/24) in your LAN directly.

Finally it looks like this:

WAN &lt;---&gt; Router/Switch (&amp; port fw to VM) &lt;----&gt; Mac &lt;-------&gt; VM
           192.168.1.1                      192.168.1.2   192.168.1.130
                ¦
                ¦
             other Mac(s)
           192.168.1.3|4|5... 


2. The OS X bridge

I assume en1 is your Wi-Fi interface and eth0 is the first adapter in your (Linux-)VM. Check this with ifconfig on your VM-host. Please adapt the commands and change the interfaces below if necessary.

If you don't want to use "Bridged Adapter" but vboxnet0 do the following after starting VirtualBox:

Attach the VM adapter 1 to the "Host-only Adapter" and the "Name" vboxnet0.

On the host in Terminal enter:

sudo sysctl -w net.inet.ip.forwarding=1
sudo ifconfig bridge1 destroy #if bridge1 still exists
sudo ifconfig en1 down
sudo ifconfig vboxnet0 down
sudo ifconfig bridge1 create
sudo ifconfig bridge1 addm vboxnet0 addm en1
sudo ifconfig bridge1 192.168.1.2 netmask 255.255.255.0 up


In the VM (Linux) you have to configure an IP-address and a default route:

sudo ipconfig eth0 192.168.56.101 netmask 255.255.255.0 arp
sudo route add default gw 192.168.56.1


A configured "Network Manager" might interfere with those settings.

On the various Macs in your network you have to configure an additional static route:

sudo route -n add -net 192.168.56.0/24 192.168.1.2


On the router your have to forward ports to the VM and add a static route to 192.168.56.0/24 to make the VM accessible to other computers in the WAN (internet). 

Finally it looks like this:

WAN &lt;---&gt; Router/Switch (&amp; port fw to VM &amp; static route to 192.168.56.0/24) &lt;-----&gt; Mac &lt;----------------------&gt; VM
           192.168.1.1                                                    192.168.1.2|192.168.56.1   192.168.56.101 (&amp; default gw or static route to 192.168.1.0/24)
                ¦
                ¦
             other Mac(s)
           192.168.1.3|4|5... (&amp; static route to 192.168.56.0/24)


The bridge and the various routes (except those on the router and the default gateway of the VM) don't survive a reboot.

To roll-back all changes:

To remove bridge1 on the host do the following:

sudo ifconfig bridge1 down
sudo ifconfig bridge1 deletem en1 deletem vboxnet0
sudo ifconfig bridge1 destroy


To disable forwarding on the host do the following:

sudo sysctl -w net.inet.ip.forwarding=0


To remove static routes on the Mac enter:

sudo route -n delete -net 192.168.56.0/24 192.168.1.2


Remove the static route on the Router.



As a result one might say it's much easier and much more comfortable to use method 1.