Converting a VirtualBox guest from a client (NAT) to a server (Host Interface Networking)

Sun xVM VirtualBox on a Mac has been great for running multiple "client" vm's which use NAT networking, but rubbish for running "server" vm's because it wasn't easy to give a vm a real IP address which other machines on the network can connect to.

All this has changed with the introduction of Host Interface Networking for the Mac in VirtualBox 2.0 and this entry attempts to show you how to convert an existing vm configured for NAT networking into a full blown server that I can run Apache on.

 So here's my starting setup on my home network:

  • Router connected to set-top box: 10.0.1.1
  • Host: Mac OS X 10.5.4: 10.0.1.200
  • Guest: OpenSolaris 2008.05 : 10.0.2.15 (VirtualBox NAT engine assigned)

The VirtualBox config looks like this:

VirtualBox NAT

And the guest sees the world thus:

OpenSolaris (Nat'ed)

What I want to do is configure VirtualBox and OpenSolaris to be a server with IP address 10.0.1.199, say.

Step 1. - Reconfigure VirtualBox

Shutdown your guest if it is running and go to the VirtualBox Console GUI.

Here is the Before config:

NAT Config

 And here is the After Config:

HIF Config

We changed 2 things:

  • Attached to: Host Interface
  • Host Interfaces: Airport (I don't use wired Ethernet in my house)
N.B. You might also have expected to have to change the NIC to a Server variant such as:
  • Adapter Type: Intel PRO/1000 T Server

...but I found that OpenSolaris got stuck during the boot sequence when I did this. (OpenSolaris experts out there, please explain. Random number generation?)

Now boot up the vm.

Step 2 - Configure OpenSolaris

Fat Bloke is not an OpenSolaris expert but he blindly followed the instructions in this excellent Observatory blog as follows: 

1 . Set IP address:

pfexec vi /etc/nwam/llp

and change from:

e1000g0 dhcp 

to:

e1000g0 static 10.0.1.199

and restart nwam:

pfexec svcadm restart nwam

2. Get DNS Working:

pfexec vi /etc/resolv.conf

and add the address of the wireless router:

nameserver 10.0.1.1 

Also tell nsswitch.con to use dns to resolve hosts:

pfexec cp /etc/nsswitch.dns /etc/nsswitch.conf 

3. Routing

Configure the default router to be the wireless router:

pfexec vi /etc/defaultrouter

Add the line: 

10.0.1.1

And restart the routing service:

pfexec svcadm restart network/routing-setup

4. Summary

So in summary here is my new OpenSolaris config:

OpenSolaris Config

Step 3 - Test it

Test it as a client

Simply firing up Firefox shows that things appear to be working:

firefox

And in actual fact Fat Bloke found Host Interface networking to be about xx% faster than NAT networking using exactly the same guest.

Test it as a server

An easy test is simply:

ssh jack@10.0.1.199 

(BTW you can easily add an entry to the Mac /etc/hosts file to give your server a name rather than using the IP address) 

from a Mac Terminal window like this:

ssh

or why not install a real server application such as an Apache web server, glassfish or whatever.

Here I've installed Sun Secure Global Desktop Software which provides remote access to a server via a browser based interface. I'm accessing it from my Mac, so I have a client and server all contained on one box.

SGD

Conclusion

Sun xVM VirtualBox is now great for running client and server vm's on Mac and Solaris hosts. The configuration interface is very simple and the performance improvement over NAT in Fat Bloke's tests is about 30% quicker.

But don't take my word for it ;-)

Comments:

I couldn't reproduce the problem with PRO/1000 T Server card. My host is Mac OS X 10.5.4. The guest is OpenSolaris 2008.05. The guest boots and acquires IP address from VirtualBox' NAT. I tried Host Interface Networking with AirPort as well. The guest boots and is able to ping the wireless router.
Could you provide more specific information? Logs will be much appreciated.

Posted by Aleksey on September 05, 2008 at 05:22 AM BST #

Thank you very much!! It was very useful your post. Just a favor, which is the way to do the same thing but in Solaris 10?? Do you know?

Posted by Daian on October 07, 2008 at 12:09 PM BST #

Hi !!! thanks to your useful information
how can i do it with Windows (host) and Kubuntu(guest) ????
thanks
BR

Posted by Redanium on November 26, 2008 at 10:23 AM GMT #

Thanks a lot. Hats up to you Sir. I configured for Linux.

Posted by Aravind G V on February 21, 2009 at 03:01 AM GMT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Fat Bloke

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today