A Pretty Good Introduction to Virtualbox Bridged Networking Mode
The default networking mode in Virtualbox is NAT. It allows the guest machine to browse the Internet via a virtual router and that’s great for most people. But if you are looking to have more interaction between host machine and guest machine, like SSH into guest machine, visiting website developed in guest machine, allow other devices in your network to see the guest machine and enable guest machine to browse the Internet, the you can choose the bridged networking mode for your guest.
Change Networking Mode to Bridged
When the guest machine is shutoff, open the settings dialog. Click the Network tab on the left pane.
By default only adapter 1 is enabled for guest machine and the default networking mode for adapter 1 is NAT. To change networking mode to bridged, click NAT and select Bridged Adapter from the list. Click OK button to save your settings. That’s very simple.
IP Address of Guest Machine in Bridged Networking Mode
Now start your guest machine. In my case, my host is Ubuntu and guest is openSUSE. Once it’s started, open a terminal and type ifconfig command to find the IP address of guest machine. You can see that the IP address of my openSUSE guest is 192.168.1.102.
Next open a terminal on the host machine and type ifconfig command to find the IP address of host machine. You can see my Ubuntu host machine has the IP address of 192.168.1.101.
So the IP addresses of host machine and guest machine are in the same network range (192.168.1.0/24). I can ping the guest from ubuntu host.
And I can ping the host from openSUSE guest.
In bridged networking mode, the default gateway of Virtualbox guest is your home router (If you have a home network). That means your home router allocates IP address to Virtualbox guest. Enter the following command in Virtualbox guet to find out the default gateway.
ip route show
The IP address after default via is the IP address of default gateway.
Visit Host Local Web Site from the Guest
I have installed Nginx Web server on my Ubuntu host, I can visit Nginx Web server from my openSUSE guest. Just type the IP address of host machine in the browser address bar.
You can also install a Web server in the guest machine and visit it from host machine.
Other Devices on Your Network Can See the Guest Machine
My android phone is connected to my home network, and I can visit Web site of guest machine from my android phone. Type the IP address of guest machine in the android browser.
You can browse the Internet in the guest machine, SSH into the host and vice versa.
To wrap up, bridged networking mode exposes the guest machine to your local network. The virtual machine is like another physical machine on the network. In NAT mode the guest machine is protected under a virtual router and devices on your network can’t see it. In order to access guest machines, you have to setup port forwarding. In both networking modes, the guest machine can go out to the Internet.