Virtual Box for Windows – VBoxManage and Interface Names

virtualbox-logoIf you’re trying out Virtual Box on a Windows host, there is a little catch with the virtual network interface names that happens. It’s a platform specific thing because you are running Windows rather than Linux, and it isn’t an issue unless you are following command line scripts and docs from people using the other platform.

For those who haven’t tried out VirtualBox, it’s freely available, and you will find that it is a common platform for the OpenStack lab work that I do, as well as with the vBrownBag sessions. Add on Vagrant and you’re really ready for fun, but that’s another post altogether 🙂

VBoxManage

The VirtualBox product comes with command line tools to be able to control nearly every aspect of your virtualization environment, including guest control, virtual disk management and in the case of what we are talking about here, host-only virtual networking.

The full VBoxManage commands and parameters list is available here: http://www.virtualbox.org/manual/ch08.html#vboxmanage-general

In this case we are focusing on this command:

VBoxManage hostonlyif create

VBoxManage hostonlyif ipconfig networkname –ip n.n.n.n –netmak n.n.n.n

The *Nix Version

If you are running on a Mac platform, or on a Linux system, you can run the commands above to follow along with what many blogs use. This example adds a host-only network range and assigns it 172.16.0.254/24 as the IP.

VBoxManage hostonlyif create

VBoxManage hostonlyif ipconfig vboxnet0 –ip 172.16.0.254 –netmask 255.255.255.0

So from this command we see that we create a new network, and then we assign the IP based on the name vboxnet0 which is the default name. Subsequent networks will be named vboxnet1, vboxnet2 and so on.

My Windows VBoxManage Isn’t Happy

Now if were to follow along with the commands as provided above on Windows, I run into a distinct problem. First let’s run the first command VBoxManage hostonlyif create

vboxmanage-1

It works like a charm right? But if you see the results, you will notice that the output says Interface ‘VirtualBox Host-Only Ethernet Adapter’ was successfully created.

So if I was to blindly move on to the next command VBoxManage hostonly ipconfig vboxnet0 –ip 172.16.0.254 –netmask 255.255.255.0 can you guess what happens?

vboxmanage-02

Sad trombone 🙁

Lot’s of folks I’ve talked to have hit this wall and then thought they had a problem, but the only issue is that the interface names are platform specific. For Windows hosts, the names will be VirtualBox Host-Only Ethernet Adapter followed by VirtualBox Host-Only Ethernet Adapter #2 then VirtualBox Host-Only Ethernet Adapter #3 and so on.

Time to Think on our Feet!

The fix is simple for us, but just requires us to work with any scripts and documentation according to our platform. In the case of our Windows host, here is the command to make this example work:

VBoxManage hostonlyif create

VBoxManage hostonlyif ipconfig “VirtualBox Host-Only Ethernet Adapter” –ip 172.16.0.254 –netmask 255.255.255.0

And the results are much nicer now:

vboxmanage-03

We can confirm from the GUI also, under File | Preferences | Network which shows our adapter list:

vboxmanage-gui

Now you can play along with the shared scripts using the modified command line. Enjoy!

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.