Preface
In the past articles, I have talked about how to make internal networking work between two virtual machines built using Virtualbox. In this article, we will see seeing a configuration of host only networking between two virtual machines built on virtualbox.
The advantages of configuring host only networking are :
1) Internet works (yes!)
2) You get an IP on the LAN for each virtual machine. Yes, this is really possible. So this means that you can have 2 more real LAN IPs coming out of a single windows desktop/laptop in the LAN. Isn’t that amazing?
3) Due to 2), your host machine can also ping or access your virtual machine
4) Each virtual machine can access the other virtual machine. E.g. ping/ssh/telnet into it.
For most purposes, this kind of setup should be optimal or sufficient. Hey, if you can access your machines in the LAN and internet works from them, that should be good enough. And, its for free.
Here is a bird’s eye overview of the end setup..
click here to enlarge this diagram
The Virtualbox Network Adapter configuration
We start with the Virtualbox Network Adapter configuration. We create a host only network interface on each virtual machine definition.
For Virtual machine1 – Gutsy:
For Virtual machine2 – gutsy2:
Please note here that while this article primarily deals with setting up host only networking, in the previous article, I had setup internal networking too, so these VMs also have a Virtual Host Interface 2 for internal networking within themselves.
Install the Guest Operating system on the virtual machines
Now, do the installation of the guest operating system in the virtual machine and setup the two network interfaces like this.
Note here that I chose static IP 192.168.0.5 because my windows machine (host OS) had the IP 192.168.0.3 and the IP had to be in the 192.168.0.x subnet. My windows host was behind a Netgear router.
We need to make sure we choose non-conflicting IPs for the host only interface otherwise you will get an IP conflict in your LAN domain. For the other machine, the eth0 static IP was 192.168.0.4.
An interesting fact here was that if I chose DHCP for eth0 in the VM, i was getting an IP of 192.168.0.3, the same as that of my windows host!! This is another reason why I had to choose static IP address.
For eth1, i chose a random IP in the subnet 192.168.2.x for no particular reason. The eth1 IP of the other virtual machine was 192.168.2.1
Make sure to restart the network after doing this network setup to bring it into effect.
Do not bother about the SIOCADDRT: No such process error:
gverma@gverma-laptop:~$ sudo /etc/init.d/networking restart [sudo] password for gverma: * Reconfiguring network interfaces... SIOCADDRT: No such process Failed to bring up eth1. [ OK ]
For the benefit of the reader, the DNS and host information is also reproduced here, although the only thing of significance should be the DNS and default gateway, both of which were set to be the same as that on windows host:
This is how the network configuration on the other virtual machine looked like:
For those who are interested, here is the output of the route command:
gverma@gverma-laptop:~$ route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.2.0 * 255.255.255.0 U 0 0 0 eth1 192.168.0.0 * 255.255.255.0 U 0 0 0 eth0 link-local * 255.255.0.0 U 1000 0 0 eth0 default 192.168.0.1 0.0.0.0 UG 100 0 0 eth0
A quick side note for Windows Vista
Here is a quick side note for Vista or windows in general. It is preferable to disable the UAC (user access control) setting and also disable the firewall on the host windows machine.
Disable the User Access Control (UAC) feature on vista to make your life easier:
Network bridging: the key to make host only networking work
The KEY to make host only networking work on windows is to bridge the real working network interface (either wireless connection of a hard wired ethernet) with the virtual adapter network interface. You can do this by selecting two network interfaces, right click, choose bridge and voila, there you have it.
A network bridge is nothing but a simplified concept of joining two connections into one. Its like joining two rivers into a bigger river. When water will flow into the bigger river, it will flow into both the rivers. At least, this is how I understand it.
ALSO, we have to enable promiscuous packet routing mode in ALL the member network interfaces that are in the bridge. This is an important setup to make it work.
Initially, I had struggled a lot to make host only networking work by enabling promiscuous for only the Virtualbox Adapter in the bridge, but was not successful. That is when I read a cryptic posting on the Virtualbox forum saying that it has to be done for all the member bridge interfaces; and thats when it worked.
A note of caution
When we add an adapter to the bridge, the connection of the main wireless network is lost for a moment, but it is re-enabled back. This is also covered in the user manual in secion 6.3 (Virtualbox version 1.5.6)
Warning: Setting up Host Interface Networking requires changes to your
host’s network configuration, which will cause the host to lose its network
connection. Do not change network settings on remote or production systems
unless you know what you are doing.
Later on, I assigned Virtualbox Host Interface 2 (on windows) to NAT0 (eth0) of Virtual machine 2 and bridged it to the wireless network connection too:
After the bridging, this is how the ipconfig output looked like (the IP of the windows host is 192.168.0.3):
Now, we were one BIG, HAPPY Family. Make sure the connection status shows as connected.
Testing the connections – Internet works!
At this point, the internet was working from the virtual machines:
Another real quick check is to use the wget utility:
gverma@gverma-laptop:~$ wget yahoo.com --18:32:56-- http://yahoo.com/ => `index.html' Resolving yahoo.com... 216.109.112.135, 66.94.234.13 Connecting to yahoo.com|216.109.112.135|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://www.yahoo.com/ [following] --18:32:57-- http://www.yahoo.com/ => `index.html' Resolving www.yahoo.com... 69.147.114.210 Connecting to www.yahoo.com|69.147.114.210|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 9,490 (9.3K) [text/html] 100%[=====================================================>] 9,490 --.--K/s 18:32:57 (258.06 KB/s) - `index.html' saved [9490/9490]
Testing the connections – Host only networking
Now comes the acid test of whether the virtual machines and hosts can see each other.
Windows could see the individual virtual machines:
C:\Users\gaurav> ping 192.168.0.4 Pinging 192.168.0.4 with 32 bytes of data: Reply from 192.168.0.4: bytes=32 time<1ms TTL=64 Reply from 192.168.0.4: bytes=32 time<1ms TTL=64 Reply from 192.168.0.4: bytes=32 time<1ms TTL=64 Reply from 192.168.0.4: bytes=32 time<1ms TTL=64 Ping statistics for 192.168.0.4: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms C:\Users\gaurav> ping 192.168.0.5 Pinging 192.168.0.5 with 32 bytes of data: Reply from 192.168.0.5: bytes=32 time<1ms TTL=128 Reply from 192.168.0.5: bytes=32 time<1ms TTL=128 Reply from 192.168.0.5: bytes=32 time<1ms TTL=128 Reply from 192.168.0.5: bytes=32 time<1ms TTL=128 Ping statistics for 192.168.0.5: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms
Pinging the windows host IP from inside the VMs worked beautifully:
And, pinging to the other virtual machine from each VM worked beautifully too:
Taking this a step further, since ssh was enabled on both the virtual machines, I was able to login to the individual virtual machines also:
gverma@gverma-laptop:~$ ps -ef | grep ssh gverma 4684 4643 0 21:27 ? 00:00:00 /usr/bin/ssh-agent x-session-manager root 5422 1 0 22:20 ? 00:00:00 /usr/sbin/sshd gverma 5456 4864 0 22:23 pts/0 00:00:00 grep ssh gverma@gverma-desktop:~$ ssh 192.168.0.5 gverma@192.168.0.5's password: Linux gverma-desktop 2.6.22-14-generic #1 SMP Sun Oct 14 23:05:12 GMT 2007 i686 The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Mon Apr 14 22:20:55 2008 from gverma-laptop.local gverma@gverma-desktop:~$
gverma@gverma-desktop:~$ ssh 192.168.0.4 The authenticity of host '192.168.0.4 (192.168.0.4)' can't be established. RSA key fingerprint is a8:29:91:97:7d:99:37:6e:31:f1:06:ec:04:39:78:d7. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.0.4' (RSA) to the list of known hosts.
gverma@192.168.0.4's password: Linux gverma-laptop 2.6.22-14-generic #1 SMP Sun Oct 14 23:05:12 GMT 2007 i686
The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.
Private networks
To make things better, the private networks were working too (thanks to the good karma accumulated in the previous article – Case study: Configuring Internal networking work for talking two linux guest OS (Ubuntu) on windows vista host ) :
gverma@gverma-laptop:~$ ping 192.168.2.1 PING 192.168.2.1 (192.168.2.1) 56(84) bytes of data. 64 bytes from 192.168.2.1: icmp_seq=1 ttl=64 time=0.200 ms 64 bytes from 192.168.2.1: icmp_seq=2 ttl=64 time=1.16 ms 64 bytes from 192.168.2.1: icmp_seq=3 ttl=64 time=0.000 ms 64 bytes from 192.168.2.1: icmp_seq=4 ttl=64 time=0.073 ms --- 192.168.2.1 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3006ms rtt min/avg/max/mdev = 0.000/0.358/1.160/0.468 ms gverma@gverma-laptop:~$ ping 192.168.2.2 PING 192.168.2.2 (192.168.2.2) 56(84) bytes of data. 64 bytes from 192.168.2.2: icmp_seq=1 ttl=64 time=4.49 ms 64 bytes from 192.168.2.2: icmp_seq=2 ttl=64 time=0.368 ms 64 bytes from 192.168.2.2: icmp_seq=3 ttl=64 time=1.65 ms 64 bytes from 192.168.2.2: icmp_seq=4 ttl=64 time=3.15 ms 64 bytes from 192.168.2.2: icmp_seq=5 ttl=64 time=1.51 ms
A moment of Triumph
So here we are. Let us take a moment to sit back, relax and let reality sink it. It is really working! I am reminded of the umpteen times I had gone to forums.virtualbox.org to find the answer to this riddle and here it is, solved.
I hope this guide is of use to someone else who is trying to make a similar configuration work or just trying to understand — what is it that we can achieve from host only networking??
Nothing could be sweeter, nothing.
Filed under: Virtualbox, Virtualization, host only networking, internal networking, windows host | Tagged: host only, networking, Ubuntu, virtual machine, Virtualbox, windows host


















Hey Gaurav,
I liked the way you have presented your ideas pictorially . Looking at the pictures and your documentation, one can easily understand the topic.
Keep Blogging !!!
[...] Eine sehr gute Anleitung findet sich hier. [...]
Hi Gaurav,
What a great case study, your step by step instruction make me understand very well how to setup network under virtualbox. The most clearest virtualbox network setup explaination which I found from google.
Thank you!
Hello Nurasto, Thanks a LOT for your kind words. I was just like many other wannabe opensource experimenter who wanted to get this good looking piece of software work, but faced many silly issues. To make it easier for the next person, i thought it would make sense to jot these ideas down. I am very thankful that virtualbox.org people linked these articles on their howto page and hence allowed more people to look/evaluate the ideas. Wishing you good luck — regards, Gaurav
Hi Gaurav,
May be you know how setting up Host Interface Networking based on TCP/IP routing.
Best regards
Arik
I don’t understand why have you created two adapters in virtual machines (eth0 and eth1)?
Hey Gaurav
Thanks man for all your contribution for making it work. I am following your case studies to use virtual box on my setups. Gaurav I am facing one big problem.
I want to set up host only interface when we add an adapter to the bridge then my network on host system gets lost. And it do not come up. It says network cable unplugged. I am using windows XP as host system and ubuntu8.04 as guest. Can you help me in resolving this issue?
Thanks in advance.
Hi gaurav…………………
Xcellent !!!!!!!!!!!!!!!!!!!!. it worked. thanks a lot !!!!!!!!!!!. I was looking for such a solution. Thanks and keep up the good work !!!!!!!!!!!!!!
Excellent tutorial! Very well laid out and presented in clear graphical fashion.
And maybe more importantly it works!
Is it just me or does there seem to be a bit of attitude on the virtualbox forums. No flaming as such but some of the guys with the apparent knowledge to fix stuff seem more interested in telling users with legitimate problems to the read the manual than actually help
Mark, Usually I am a bit slow in responding to comments but your comment caught my eye. Yes, you are right to a degree. In the world of open source softwares, there is always this facet of the core developers being so busy that it will appear that no one wants to help you. This is the biggest catch of open source softwares — documentation and support is limited and so the people who trek the road of open source softwares must be ready to bear this ignominy, if it may be called so. BUT, we can do away with it by sharing knowledge and our experiences through blogs or websites. I had thought of launching opensourceexperiments.com with this thought.. — it would be a community where people could share their experiences freely and supplement the mailing lists or forums etc. Anyways, thanks for your comments and Please carry the torch forward by sharing your experiences if you can.
FINALLY!!! Thank you for providing some information that actually works! Nowhere else that I’ve found did anyone’s advice worked, but this article did
Hi!
WHAT A GREAT POST!
Finally I am able to create development servers in VirtualBox and use the host system to access them. I can even map shares from the win2003 server (guest) in my host (win xp) system.
Great post and I think that this should be part of the official VirtualBox documentation.
Great Post- I had struggled with getting a XP guest OS working in my Vista box. Looked at the VirtualBox documentation and no help. I saw the promiscuous notes, but hadn’t found what that meant yet or how to set it in Vista. I am pretty sure you have saved me many hours of searching. More importantly, you saved my computer from a sledgehammer.
THANK YOU!! This was the information I needed to finally get my Ubuntu guest visible on the network. XP Host, Ubuntu guest, so slightly different configuration, but the bit about how to configure the adapter and bridge was exactly what I’d been missing. WOO HOO!!!
Great Tutorial! Helped me a lot.
I used this case to help me configuring my network between a win xp host and win server 2003 as guest.
I own you a beer!
Telling users to disable UAC is not responsible. UAC increases security of Windows.
Hi Ryan, If we are able to find a way to make it work without disabling UAC, that would be a good learning. Please post it, if you have discovered te same. –Thanks, Gaurav
Thanks a lot man, I was in a hurry and your post saved me a lot of time!
Hi Gaurav,
I spent a full day to find the way to bridge a wireless connection with my Virtual Box adapter! Thank you so much!!
[...] http://www.ubuntugeek.com/how-to-set-up-host-interface-networking-for-virtualbox-on-ubuntu.html http://opensourceexperiments.wordpress.com/2008/04/18/virtualbox-case-study-making-host-only-network... http://forums.virtualbox.org/viewtopic.php?t=10148&highlight=vboxaddif [...]
Thanks for the posting. Worked like a charm.
- Pete
thanks gaurav for this detailed howto, it worked superb. until today
i updated to virtualbox 2.1.2 on my vista host. after that, id did not work anymore. virtualbox complained that it can’t find the virtualbox hostinterface.
tap-interfaces and bridges are no longer required since taht update. you can directly use the network interfaces of the host as host-interface for the guest.
Nice article – thanks for the tips.
Being a newbie to VM’s, this is usually indeed, and you have presented your article in a very clear fashion.
Very detailed … and very easy to follow. I’m tackling the same situation on my server but are working with an openSuse host and a RedHat, Windows2008, and Windows XP virtual machines do you know of any good post that can take me through accomplishing this?
I need the virtual machines to talk to each other and for the host to be able to talk to any of the virtual machines as well as give internet access to both the host and virtual machines. The tricky part is that I need to run all the nics (both the host and virtual machine nics) on static IP addresses
I’ve looked but I haven’t been able to find anything that works yet. Can you help me out?
Hi all, I’m using VirtualBox 2.1.4, it’s different from the one of this post and maybe I’ll save someone’s time with this.
I have a Ubuntu Server 8.10 in a VM, and a windows XP as host, and I couldn’t find a way to make them see each other in the network. My server has an apache-php-mysql installation, and my objective was to access it from the host machine, for example, open my browser, write http://guest-server-ip-address and see the apache welcome page.
well… After several tries, reading docs, etc with no luck, i tried “brute force” option. I enabled the 4 network adapters from the VirtualBox GUI. each with the different card types (PCFast, intel PRO, etc). all four using the “Host interface”.
Then edited the interfaces file: sudo vim /etc/network/interfaces
and started testing different network devices (eth0, eth1, eth2….)
until this gave me a result (just add this to the end of the file):
auto eth1
iface eth1 inet dhcp
then typed in the console:
sudo /etc/init.d/networking restart
and it found my wireless lan… after that, I needed a static IP address, so I edited the interfaces, here’s the result:
auto eth1
iface eth1 inet static
address 192.168.1.11 #Choose this ip
netmask 255.255.255.0
network 192.168.1.0 #again, for your ip
broadcast 192.168.1.255
gateway 192.168.1.1 #your wireless router ip
Saved the changes, restarted the network, and got what i wanted
, now if I type http://192.168.1.11 I can see the apache welcome page.
HOPE THIS HELPS!!!
[...] Virtualbox Case Study: Making host only networking work between two Ubuntu Guest OS (virtual machine… (tags: windows vista sysadmin virtualization vi virtualbox bridge networking linux vmware ubuntu) [...]
[...] http://opensourceexperiments.wordpress.com/2008/04/18/virtualbox-case-study-making-host-only-network... Howto linux, ubuntu, virtualbox, virtualization, vista, windows [...]
Nice article.
I having problems with my setup, which is different to the articles. Hope someone can help.
Host – windows xp home edition
VM – Centos 5
installed on a dell inspiron 6400. Internet connection for both host and vm is through wireless network.
I can connect to the internet from both vm and host..
My problem is that i cannot ping the VM from host or ping the host from VM.
Cheers for any help!!
Dun, you may be required to open the ports in VM (centos) and allow the firewall in XP.