Server Guide and Blog

Rock Your Linux

By

VirtualBox Bridge and Tap no Longer Needed – Built in

With recent version of VirtualBox you no longer need to create a bridge and tap to enable host networking. In the settings panel of the virtual machine, select the network tab, and make sure that its set on bridged adapter. VirtualBox automatically creates a virtual ethernet adapter, and bridges it to the network of the host machine.

Bridging to the host network is necessary for the virtual machine to get an ip address from the router. Such a configuration is needed to communicate with the machine from the outside world. Because of this feature virtual machines can server website, and other services. I use my virtual machine to host this website, a visual ftp server, a wiki, and an EyesOS server.

There are other ways to forward individual ports from the host system to the guest, but then the ports on the host machine will not be accessible on the host; they will virtually represent the guest OS thus hindering connectivity with the host machine. There may be instances where this is what is wanted and more information, including instruction, can be found on this previous post.

The following is a screenshot of the network tab in VirtualBox. It had a bridge adapter option that will autobridge the connection to an existing ethernet adapter. Bare in mind that this is the screen from a Linux install of VirtualBox and it might be different in Windows. I remember in Windows you might have the option to create a virtual ethernet adapter, and then you can bridge the connection all in VirtualBox. Nothing needs to be done manually anymore, and everything can be done from within the VirtualBox configuration panels.

Screenshot-Windows XP - Settings

Here is a screen from Windows Vista. Go to the network tab of the virtual machine settings:

Network settings

Then select the attach to drop down menu:

Attach

Then change the attach to, drop down menu, to bridged adapter:

Bridged adapter

By

VirtualBox Windows Vista – Host Network Bridge and Tap

This entire post is no longer applicable to the most recent version of VirtualBox. Here is a more recent post.

VirtualBox is well equipped for a Windows environment. Most of its features have a mechanism for automatic installation and setup. To get your guest OS, in Windows Vista, to have a real IP address from your router you first need a network bridge and tap. Open the VirtualBox manager:

VirtualBox manager screenshot

Then select a guest OS and open its settings. Then click the network tab:
VirtualBox manager network tab

Then click the add network tap button:
Add network tap button

It doesn’t matter what the name is :) Then adjust your guest OS networking adapter accordingly.

Enable host network

Now open your Windows Vista network configurations manager:

Microsoft Vista network configuration

This screenshot is what your network configurations should be after everything is done. To achieve this simply select both the VirtualBox tap, that was previously created, and bridge it to your LAN connection. Select both by click on each adapter while pressing the shift key. Then right click on either of the two highlighted icons and select “bridge”. This will automatically create a bridge between the tap and your real host networking adapter. Wham bam, now you can select a real static IP in your VirtualBox guest OS on a Windows Vista system :)

Update (12/4/2009); At the top of this post I say that the information here is outdated. You can view the post listed above if you want, but here are the pertinent screenshots also:

Here is a screen from Windows Vista. Go to the network tab of the virtual machine settings:

Network settings

Then select the attach to drop down menu:

Attach

Then change the attach to, drop down menu, to bridged adapter:

Bridged adapter

By

VirtualBox Auto Boot

If you have setup your bridge and tap directly in the network interfaces file, you still have to chmod the /dev/net/tun folder to successfully utilize host networking. I use a quick startup script located conveniently in my home folder. sudo chmod 666 /dev/net/tun Place this line in a file and name it host.sh or something. Then open your preferences>>session configuration menu and set it to be run on startup. Now with correct network interfaces configuration your guest system will successfully recognize the tap.

By

Bridge and Default Eth Same IP

When configuring your network, bridges, and taps you want your default Ethernet card to have the same static ip address as the bridge you create in /etc/network/interfaces. Doing so you will have internet access on the host and guest systems. Within the guest system configure the interfaces to be one numerical value higher in order to avoid conflict with the host.

By

Network Interfaces Configuration File

In your /etc ditectory is the network folder. In the network folder is the interfaces file that contains all the data used to configure your network. The default configuration is dhcp. You can configure this file manually, to a limited degree, via the administration>>network panel. For most applications dhcp will be fine, and therefore you can leave your default configuration. If you want to setup a static ip, for your primary ethernet card, use the administration>>network configuration menu. You can set any static local ip outside the range of the dhcp configuration on your router. You can disable the dhcp of your router to set static addresses for the lower safe range. The default dhcp range is typically 192.168.0.2 to 1982.168.0.50. After disabling dhcp you can disable network manager in the preferences>>sessions configuration menu. If you are using a bridge and tap I highly recommend direct configuration of your interfaces via the /etc/network/interfaces file. Please refer to my previous post for more information about bridge and tap configuration.

By

VirtualBox Host Networking – Script Versus Interfaces

There are two methods of creating a bridge and tap on Linux. The easy method is via a script that is set to automatically run at login. The following is the script that I used for a long time to setup two taps. It will create a bridge and assign an ip address to it via dhcp. It will create a tap with ip 192.168.0.102, and a second tap with ip 192.168.0.105. host.sh Bridge and Tap Configuration Script I have completely abandoned the startup script method in favor of directly configuring the network interfaces on the host and the guests. To configure the host networking bridge and tap open the interfaces file located in /etc/networking. sudo nano /etc/networking/interfaces Now add a tap: auto tap0 allow-hotplug tap0 address 192.168.0.101 iface tap0 inet manual tunctl_user nseidm1 Then add the bridge: auto br0 iface br0 inet static address 192.168.0.100 netmask 255.255.255.0 broadcast 192.168.0.255 gateway 192.168.0.1 bridge-ports eth1 tap0 bridge-ageing 7200 bridge-fd 0 The tap will be created with an ip address of 192.168.0.101 and the bridge with and ip of 192.168.0.100. Then inside your guest os configure the interface; set the eth0 ip address to the same ip as the tap. This works fine based on my experience up to this point. This also help consolidate ip addresses; note that only two have been used in total. One for the host system configured through the bridge br0, and the other for the tap that is configured in conjunction with the guest os interface.