In the previous VirtualBox post, I explained how (and how not) to set up bridged networking with LAN access to a Virtual Machine running on a Windows XP Host. Today I will explain how to do the same thing (without the How Not To part) using a virtual Machine running on a Headless Ubuntu Server.
For this example we can assume a few things:
- You have already set up a headless VirtualBox server
- You have already created a Virtual Machine instance. For this sample, we will call the Virtual Machine “MyVM”.
Believe it or not, setting up bridged networking to allow your VM to access your network is pretty simple and completed by issuing the following VBoxManage command in a terminal window.
Command: VBoxManage modifyvm “MyVM” –nic1 bridged –nictype1 82540OEM –bridgeadapter1 eth0
Break it down
To understand a bit more about what’s happening here, let’s break down the command string from the beginning.
VBoxManage – This is the command line utility used to access, control, configure and manage your VirtualBox Virtual Machines.
modifyvm – This command allows you to make changes to the properties of a Virtual Machine, including the amount of memory assigned, nic interfaces, Virtual device boot sequence, number of CPUs, etc. It can be compared to the Settings dialog of the VirtualBox Graphical user Interface. The command line version, however, offers additional advanced options not found in the GUI.
Note: the VM must be registered within VirtualBox, but must not be running
“MyVM” – This is simply the name of the VM you want to modify.
–nic1 bridged – The –nic1 parameter is used to set the type of networking your VM should use for each of the it’s virtual network cards. You can have more than one network card in use for a VM so the paramater is written as –nicX where X is the network card being targeted. Here, “–nic1” is the first network interface, –nic2 would be the second and so on. This portion of the command string is setting the type of networking on the first interface to “bridged”.
–nictype1 82540OEM – The –nictype1 parameter allows you to specify which networking hardware VirtualBox should emulate for the VM’s virtual network cards. Here we set the networking hardware to emulate an Intel PRO/1000 MT Desktop card or 82540EM.
–nictypeX follows the same sequence numbering and –nicX for multiple interfaces where –nictype1 is the first virtual card, –nictype2 is the second and so on.
Note: Â The following is a list of the available nic hardware types and the associated ID recognized in VirtualBox.
- AMD PCNet PCI II =Â Am79C970A
- AMD PCNet FAST III =Â Am79C973Â (the default)
- Intel PRO/1000 MT Desktop =Â 82540EM
- Intel PRO/1000 T Server =Â 82543GC
- Intel PRO/1000 MT Server =Â 82545EM
- Paravirtualized network adapter =Â virtio-net
–bridgeadapter1 eth0 – Finally we have the –bridgeadapter paramater. This is the only part of the command string that references a part of the VirtualBox host and tells your VM which physical host adapter to pass it’s traffic through.
Again, this uses the same sequence numbering as nicX and nictypeX for multiple interfaces. Here, we are setting the bridgeadapter for our first virtual network card to use the eth0 Â interface on the host. Note that is eth zero, as in the number and not the letter O.
And that’s it. Restart your VM and you should now have a working bridged network interface for you VM with full network and internet access.