Case study: Making Internal networking for talking between two linux guest OS (Ubuntu) on windows vista host


Preface

For the past few days, I had been struggling with making internal networking work on two (or more) linux guest OSes on Windows host using virtualbox.

The advantage of this setup is we can setup an internal networking lab between two or more nods using regular windows, which can be used for a variety of purposes. My primary purpose behind this setup was to simulate an environment for implementing Oracle 10gR2 RAC cluster.

As we know, setting up 10g RAC on a node needs a public network and a private network. The public network is achieved right off the bat with the NAT network configuration in Virtualbox, but the internal network setup is one that is pretty tricky.

I will give credit to both http://www.virtualbox.org/wiki/Testing_Networks and http://blogs.sun.com/manoj/entry/netowkring_with_virtualbox for the ideas tested, but more so to http://www.virtualbox.org/wiki/Testing_Networks

That being said, I would daresay that the content authoring in Virtualbox user manual about setting up internal networking on windows host deserves a little more attention. I was able to find several posts on the internet, including a particular Virtualbox wiki page, that dealt with making host only networking or internal networking work on Ubuntu host, but was not able to find the same for windows host.

Lets get to the setup now..

This is how the GUI setup looks like internal network (Adapter 1 – 2nd adapter) for the two virtual machines:

The caveat…

The first thing which we need to understand that is the Virtualbox GUI for setting up internal network is BROKEN!

You need to set it up using the command line interface (VboxManage command) Also, be aware that the internal network settings are reset by the GUI if any of the VM settings are changed, so you better do this AFTER you are done with all the other VM changes.

As per the User manual, the default internal network name is “intnet”, but you can choose any other name. I chose the intnet for no particular reason.

This is what we need to do with the VboxManage command. (here, we assume that there are two guest OSes – “Gutsy” and “gutsy2″). Mind you, the virtual machine name is case-sensitive in the VboxManage command.

c:\Program Files\Innotek> VboxManage modifyvm Gutsy -nic2 intnet

c:\Program Files\Innotek> VboxManage modifyvm Gutsy -intnet2 intnet

c:\Program Files\Innotek> VboxManage modifyvm gutsy2 -nic2 intnet

c:\Program Files\Innotek> VboxManage modifyvm gutsy2 -intnet2 intnet

Default Gateway and DNS of eth1 interfaces – (used for private network as per our semantics)

If you already have the eth0 in the guest OS (linux) as NAT, it will automatically acquire a DHCP assigned IP in the subnet 10.0.2.x, and will have a default gateway of 10.0.2.2. The names server will be 10.0.2.3. With this setup, internet will work on the linux guest OS, (provided it is works on the windows host too).

We will need to make the default gateway of the private network (eth1) in guest OS (linux) as 10.0.2.2 too — whichever is causing the internet to work.

Private IPs should be the same subnet…

Another thing to notice here is that all the guest OSes that are intended to be connected through internal network should have the private interface IP (eth1) in the SAME subnet. You can choose any private subnet like 192.168.x.x or 10.10.x.x:

Here are three valid combinations of eth1 IPs:

a) Gutsy could have 192.168.2.1, and gutsy2 could have 192.168.2.2

b) Gutsy could have 192.168.3.2, and gutsy2 could have 192.168.3.4

c) Gutsy could have 10.10.1.1, and gutsy2 could have 10.10.1.2

( I hope you get the idea).

For the sake of illustration, I chose this combination of private IPs:

  • 192.168.2.1 (for linux guest OS 1 – Gutsy)
  • 192.168.2.2 (for linux guest OS 1 – gutsy2)

Restart networking

After doing this, you need to restart the networking on the linux host. On Ubuntu, it is done with the sudo /etc/init.d/networking restart command:

gverma@gverma-desktop:~$ sudo /etc/init.d/networking restart
[sudo] password for gverma: ********
* Reconfiguring network interfaces...
SIOCADDRT: No such process
Failed to bring up eth1.
[ OK ]

Overview of the networking configuration

Here is how the ifconfig for Gutsy – linux guest OS 1 looks like (as you can see the eth0 IP has been acquired in 10.0.2.x subnet by the DHCP server):

And this is how it looks of Gutsy2 (as you can see, the eth0 IP has been acquired in 10.0.2.x subnet by the DHCP server):

By mistake, I have put the same image for the ifconfig output (that of Gutsy) for Gutsy2  as well. The hardware MAC address for eth1/0 should be different and so should be the the IP address for eth1 — it should be 192.168.2.1. The eth0 IP for Gutsy2 would still be 10.0.2.x as it was of NAT type. — Thanks, Gaurav

A variation…

Let us consider a variation here.

If the Virtual machines have only 1 virtualbox network adapter defined of type internal network, then the internal static IP within the Virtual machine would have needed to use a default gateway == host’s IP default gateway.

For example, if the windows host had an IP of 192.168.0.4 (say), by virtue of being behind a router, then the default gateway of eth0 interface in in the virtual machine should be 192.168.0.1. (Again, this is assuming ONLY if you do not have a NAT type virtual interface defined for the VM.)

In my case, since I had two virtual network interfaces defined (one NAT and one internal networking type) for the VMs, I had to make the default gateway of the eth1 (private interface) of guest OS the same as that of eth0 — which was 10.0.2.2.

The default gateway can be verified by the output of route command.

Interesting Trivia

In addition, the media state of the Virtual TAP Adapters in windows host were showing up as media disconnected, but still the internet was working for the Virtual machines AND the pings to each other were working. So, don’t be fooled by the status of Virtulbox Adapters in the windows host.

gverma@gverma-desktop:~$ ping 192.168.2.1
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=0.031 ms
64 bytes from 192.168.2.2: icmp_seq=2 ttl=64 time=0.030 ms
64 bytes from 192.168.2.2: icmp_seq=3 ttl=64 time=0.109 ms
64 bytes from 192.168.2.2: icmp_seq=4 ttl=64 time=0.031 ms
64 bytes from 192.168.2.2: icmp_seq=5 ttl=64 time=0.036 ms
64 bytes from 192.168.2.2: icmp_seq=6 ttl=64 time=0.033 ms
64 bytes from 192.168.2.2: icmp_seq=7 ttl=64 time=0.110 ms

— 192.168.2.2 ping statistics —
7 packets transmitted, 7 received, 0% packet loss, time 5998ms
rtt min/avg/max/mdev = 0.030/0.054/0.110/0.035 ms

gverma@gverma-desktop:~$ ping 192.168.2.2
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.398 ms
64 bytes from 192.168.2.1: icmp_seq=2 ttl=64 time=0.304 ms
64 bytes from 192.168.2.1: icmp_seq=3 ttl=64 time=0.380 ms
64 bytes from 192.168.2.1: icmp_seq=4 ttl=64 time=7.20 ms
64 bytes from 192.168.2.1: icmp_seq=5 ttl=64 time=0.407 ms
64 bytes from 192.168.2.1: icmp_seq=6 ttl=64 time=0.272 ms
64 bytes from 192.168.2.1: icmp_seq=7 ttl=64 time=3.42 ms
64 bytes from 192.168.2.1: icmp_seq=8 ttl=64 time=0.411 ms
64 bytes from 192.168.2.1: icmp_seq=9 ttl=64 time=0.398 ms

— 192.168.2.1 ping statistics —
9 packets transmitted, 9 received, 0% packet loss, time 8004ms
rtt min/avg/max/mdev = 0.272/1.465/7.200/2.241 ms

Viola! The same result can be seen on gutsy2 too.

Well done!

Congratulations on setting up a private internal network between multiple virtual machines using Virtualbox. I hope this tutorial is of use to someone exploring the virtualbox tool. I personally feel it is a lot leaner and powerful, as compared to the vmware’s size. It is also more robust performance wise.

If you feel this was helpful, send me a note at gaurav_verma two two [at] yahoo dot com or just leave me a comment.

20 Responses

  1. Hi Gaurav Verma,

    Thanks your great tutorial
    I’m planning to design an internal network & the internal network should included a router(s)/firewall created by Linux/FreeBSD.

    How can i setup the virtual router that can connect to internet on one interface & the other interface connect to internal network? Also, Can i setup direct connection between two VMs? Just like a ethernet line between them.

    Your tutorial is very helpful, but i don’t know is it the missing piece on my situation.

    Please kindly help ~

    Regards,
    Keith

  2. Hi Kevin, Thanks a lot for the encouragement in the first place! It is really good to know that this content is helping someone figure out their frustrations.

    Kevin, for your requirement, I think adding a host only or NAT network interface is the answer. if I understand it right, you need

    1) internet connection
    2) have the ability to talk between your 2 VMs
    3) setup a private network between then

    For requirements 2) and 3), setting up a private network will work fine.

    For requirement 1), either NAT or Host only networking will work, but NAT is the easiest to setup (Let it select an IP using DHCP, unless you are really hell bent upon choosing a static IP). For either NAT or host only networking, please see the other 2 articles on this blog:

    # Migrating from vmware to Virtualbox: Making NAT networking type work with SuSE Linux as guest OS and Windows Host

    # Virtualbox Case Study: Making host only networking work between two Ubuntu Guest OS (virtual machine) on Windows Vista host

    Let me know if this helped you at all. I do not know how to design a router from scratch as such, so please forgive my ignorance.

    Thanks
    Gaurav

  3. [...] Recent Comments Gaurav Verma on Virtualbox Case Study: Making …nurasto on Virtualbox Case Study: Making …A weblog about nothi… on Virtualbox Case Study: Making …Case Study: Discover… on Combining Openfiler and Virtua…Gaurav Verma on Case study: Making Internal ne… [...]

  4. Gaurav,

    I have a problem setting up Ubuntu 7.03 as guest OS in Windows Host. Even the NAT networking is not working for me. Not able to understand where I am going wrong. I tried Internal Networking as per your Tutorial. Still not working. BTW I have only one guest OS. Is there something in Vista stopping me to do so.

    Appreciate any quick reply.

    Thanks.

    Rajesh(RT)

  5. Rajesh, make sure you setup the network interface in ubuntu as DHCP. Also make sure the name server is the same as that on your windows host (take it from the ethernet or wireless connection)

  6. Your issue can also be related to a proxy. If you are doing it from office intranet, make sure you set your proxy in http_proxy variable.

  7. My set up is :
    Windows XP SP3 host,
    Sun xVM VirtualBox 1.6,
    Ubuntu 8.04 guest,
    Xubuntu 8.04 guest.

    I followed your tutorial to the letter and everything worked like you said it would. This was a very good tutorial. Thanks a ton, man! Great work :)

  8. Surja, Thanks a lot for your encouragement. It is really good to know your feedback.. Thanks

  9. Hi Gaurav
    I found this blog post really useful, and was able to successfully setup network between xubuntu7.10 and Ubuntu8.04 Vbox guests.
    Thanks Man for this really helpful guide.

  10. Hi Gaurav,

    Thanks for your tutorial. In your setup you can have two different IPs in the subnet, but for me I can’t have since I have a private internet connection on my host with a static IP. I don’t want internet connection on my VM guest, but only need to and fro ping from guest and host. Could you please advice me how to do this.

    Thanks a lot in advance

  11. Hi Gaurav,

    I have some sort of problem in the network that was handed to me. This was running before but now, it’s not. The setup is this.

    For the Physical Server (Host)
    IP Address – 10.60.0.100
    GW – 10.60.0.98
    SM – 255.255.255.224

    Guest
    IP Address – 10.80.0.194
    GW – 10.80.0.193
    SM – 255.255.255.224

    I can ping the gateway of the guest from the physical server(host) but i can’t ping the IP address of the guest. No internet on guest.

    This was working before.What seems to be the problem. Prior to this I upgraded the vmware server from GSX to Vmware server. Will that be a reason why this is not running as before? Can you help me.. please.. thanks.. I’ve been working on this problem for 3 days now and no success..

    Thanks.

    Felix

  12. Hello Gaurav,

    Thanks for the Virtual Box write ups
    I have a couple questions concerning this part:

    http://opensourceexperiments.wordpress.com/2008/04/13/case-study-configuring-internal-networking-work-for-talking-two-linux-guest-os-ubuntu-on-windows-vista-host/

    =========================================
    Overview of the networking configuration

    Here is how the ifconfig for Gutsy – linux guest OS 1 looks like (as you can see the eth0 IP has been acquired in 10.0.2.x subnet by the DHCP server):
    HWaddr 08:00:27:9A:46:02

    And this is how it looks of Gutsy2 (as you can see, the eth0 IP has been acquired in 10.0.2.x subnet by the DHCP server):
    HWaddr 08:00:27:9A:46:02

    =========================================

    1) What happened to the original Gutsy2 MAC?
    HWaddr 08:00:27:6D:DC:85

    It looks like you pasted the Gutsy ifconfig twice
    instead of using Gutsy2 for the second ifconfig

    2) Would there be any improvement in network speed if used the Intel E1000 vs the PCNet-Fast III(Am79C973) virtual NICS?

    Thanks,
    Al

  13. Al, you are right. By mistake, I have put the same image for the ifconfig output (that of Gutsy) for Gutsy2 as well. The hardware MAC address for eth1/0 should be different and so should be the the IP address for eth1 — it should be 192.168.2.1. The eth0 IP for Gutsy2 would still be 10.0.2.x as it was of NAT type. — Thanks, Gaurav

  14. Hi, i’m interested in create a virtual network using VirtualBox. Host is Win XP SP2.
    Guest1: Win XP SP2
    Guest2: Win 2003 Server SP1 as a domain controller using LDAP
    Guest3: Win 2003 Server SP1 as a database server using SQL 2005 SP2

    This for a client server app required to validate user first against LDAP.

    given these assumptions, Is it possible to have a virtual network?

    would you provide some basics about how to configure this using VBox?

    Thanks in advance !!

  15. hello!
    thank you very much for this great tutorial!
    i am using it on my project @ OS Admin: samba, nfs, nbd comparisson!
    I have win xp as host.. with Virtual Box two Debian guests. This was exactly what i was looking for. The host only networking looks nice too, but i get my IP from dhcp (student campus) and I would have LAN confflict.
    all works well now, and the two guests are visible by IP.
    indeed, spared me for some hours of searching forums.
    all the best! kiri from Romania

  16. Thanks for these great case studies! They were very helpful! Needed to set up a windows server 2003 guest host as the “main server” for a game design company which would act a domain controller and having windows xp pro connect to it and other domain controllers, all very confusing, seeing as I have ubuntu in virtual box already a simple “ping” between the VM’s was used proove i understand classful IP addressing and all manner of things! :-)
    Just wanted to say thanks from Terry in England!

  17. Thanks for the tutorial, I used it for VB 2.1.4 and finally got my virtual network up and running after many hours of forum searching.

    One thing I’d like to add (that I learned the hard way after banging my head against the wall many times).

    **Remember to install the “guest additions” VB provides for the guest OSs if your networking doesn’t seem to work despite following the instructions here.**

    Thanks very much for this case study.

  18. Thanks for the help man.
    I appreciate it.

  19. Hi,
    i have created a virtual network with host Vista
    Guest1: Win XP SP3
    Guest2: Ubuntu 8.04
    Guest3: Ubuntu 8.10

    i am able to ping 2 ubuntu machine , but from either ubuntu machines i am not able to ping win xp machine. But am able to ping both ubuntu machines from XP.

    Also i want to know will i have to create one more virtual machine to act as gateway, since i want all the packets to go from one machine with static address.

  20. Hi Gaurav,

    Wonderful…I am searching for this from past 2 days…
    atlast i got it in your blog ….
    great presentation ……… helps a lot for me…

    Thanks So much….
    Nagababu

Leave a Reply