Thursday, July 17, 2008

Networking (Host Interface) in xVM

All those who use Sun Virtual Machine (xVM) to run guest OS over Ubuntu (esp XP) and trying very hard to achieve proper network setup, then you are at the right place. I will show you how to give your guest OS proper native network setup.
Sun VM supports 4 kinda Network Adapter

  1. Not Attached (behaves as network cable is un-pulgged).

  2. NAT (Good if you want to sruf web and download coontents, not much communication with host OS).

  3. Host Interface (Provides almost real network adapter kinda support).

  4. Internal Network (Some kinda secure and fast stuff as per document).



We will use Host Interface to achieve our network structure.

Software requirement:

  • Bridge Utility
    apt-get install bridge-util

  • Uml Utility
    apt-get install uml-utilities 



Next provide the access right to the tap0 device

sudo chmod 0660 /dev/net/tun
sudo chgrp vboxusers /dev/net/tun


Next create the tap0 device
sudo tunctl -t tap0 -u  


Now create scripts files to control Starting/Stopping the tap0 interface

StartTap0.sh
 
#!/bin/sh
gksu brctl addbr br0
gksu ifconfig eth0 0.0.0.0
gksu brctl addif br0 eth0
gksu ifconfig $2 0.0.0.0
gksu brctl addif br0 $2
gksu dhclient br0



StopTap0.sh
 
#!/bin/sh
gksu brctl delif br0 $2
gksu ifconfig eth0 down
gksu ifconfig $2 down
gksu ifconfig br0 down
gksu brctl delif br0 eth0
gksu brctl delif br0 $2
gksu brctl delbr br0
gksu ifconfig eth0 up



After the scripts are ready open xVM and navigate to network adapter tab, Set the following config.




  • Attached to : Host Interface

  • Interface Name : tap0

  • Setup Application : ~/StartTap0.sh

  • Termination Application : ~/StopTap0.sh






All set just boot up the guest OS, fill in the password and enjoy full fledge network. At Guest OS Network adapter will only take static IP, remember to set it to something under the same subnet mask. Thus enjoy complete Network (lets play). :D


No comments: