Difference between revisions of "VirtualBox Network Configuration"

From DAVE Developer's Wiki
Jump to: navigation, search
(NFS section added)
(NFS Configuration completed)
Line 78: Line 78:
  
 
===== NFS Configuration =====
 
===== NFS Configuration =====
 +
 +
[[w:Network_File_System|NFS]] is commonly used to network mount the target root file system. NFS Server is already installed on [[:Category:DVDK|DVDK]] but needs to be configured before using it.
 +
 +
User just need to edit <code>/etc/exports</code> file to allow the local network to mount NFS shares.
 +
 +
The default configuration provided with DVDK allow mounting all subdirectory of ''/home/shared'' by the default class C private network 192.168.0.0/24, but is disabled.
 +
 +
<pre class="workstation-terminal">
 +
nelk@nelk-desktop:~$ cat /etc/exports
 +
# /etc/exports: the access control list for filesystems which may be exported
 +
# to NFS clients.  See exports(5).
 +
#
 +
# Example for NFSv2 and NFSv3:
 +
# /srv/homes      hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
 +
#
 +
# Example for NFSv4:
 +
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
 +
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
 +
#
 +
 +
#/home/shared    192.168.0.0/24(rw,sync,no_subtree_check,no_root_squash,no_all_squash)
 +
 +
nelk@nelk-desktop:~$
 +
</pre>
 +
 +
If you are on the default network just remove the <code>#</code> at the beginning of the last line. If you are on a different network, e.g. private class A network 10.0.0.0/8, change the line in;
 +
 +
<pre>
 +
/home/shared    10.0.0.0/8(rw,sync,no_subtree_check,no_root_squash,no_all_squash)
 +
</pre>
 +
 +
Changes are applied by running <code>exportfs -a</code> as root, and can be verified with <code>exportfs</code>
 +
 +
<pre class="workstation-terminal">
 +
nelk@nelk-desktop:~$ sudo exportfs -a
 +
nelk@nelk-desktop:~$ sudo exportfs
 +
/home/shared  192.168.0.0/24
 +
</pre>
 +
 +
For more information regarding NFS server and /etc/exports see ''exports'' man page or, for example, [http://linux.die.net/man/5/exports]

Revision as of 15:40, 8 May 2012

Info Box
VirtualMachine.png Applies to DVDK

VirtualBox Network Configuration Primer[edit | edit source]

VirtualBox networking supports different configuration. For a in-depth discussion regarding virtual networking see VBox official documentation here.

For developing purpose, we are interested in two configuration:

  • NAT, which is the default provided with DVDK, and
  • Bridged Networking

Network Address Translation (NAT)[edit | edit source]

Network Address Translation is a tecnique used in IP networking that modify IP packet header, by changing IP address, while the routing device processes the packet.

Only the IP address of the routing device (in case of a Virtual Machine, the host ack at router for the guest) is seen from outside. Usually the routed device (in our case, the guest machine) has an IP address that belongs to a completely different IP subnet.

NAT make easy to use a virtual machine because:

  • it does not require to configure guest network parameters (the router act as DHCP server and give all the needed information to the guest)
  • it guarantees that the VM can be executed in any network environment without breaking the existing network.

However it's really hard to configure NAT to let the VM to act as a server (e.g. as NFS or TFTP server), for this reason the developer usually choose a bridged configuration, with proper IP parameter assignments.

Bridge Configuration[edit | edit source]

In brief, Bridge Networking configure host's physical network interface and guest's virtual network interface as if they are connected with a Ethernet Switch.

In this way:

  • guest (DVDK Virtual Machine) has it's own IP address, usually on the same subnet of the host
  • guest is directly accessible (apart from firewall rules that may be configured on the host) from any device on the same subnet

To change from NAT to Bridge configuration user have to:

  • change Virtual Box network setting
  • configure, if needed, guest networking. Guest by default uses DHCP so, if DHCP server is available on your network, no additional configuration is needed.

VBox Bridge Configuration[edit | edit source]

It's easy to change Virtual Box Network configuration:

  • open VBox application and start DVDK VM
  • from the VBox main window, select your VM and choose Settings from the toolbar


DVDK Bridge Configuration 1.png


  • Choose Network item and, from the Attached To: dropdown choose Bridged Adapter


DVDK Bridge Configuration 2.png

  • Now the Name dropdown should be enabled. If you have more than one network interface, choose the right one to connect the bridge too

DVDK Bridge Configuration 3.png

  • That's all, click Ok to apply changes.

Guest (Ubuntu) Network Configuration[edit | edit source]

By default, the virtual machine image provided with DVDK is configured with DHCP. If you don't have a DHCP server available on your network, you should configure the interface manually.

Right-Click on the NetworkManager Applet on the top Panel and choose Edit Connections

DVDK Ubuntu Network Configuration 1.png

Now Add new connection

DVDK Ubuntu Network Configuration 2.png

Fill all the required fields (name and IPv4 configuration) and hit Apply button.

DVDK Ubuntu Network Configuration 3.png

Now the new configuration is added and the Network Manager Applet should tell you that the connection with your network is established

For more information about ubuntu take a look at its official documentation

NFS Configuration[edit | edit source]

NFS is commonly used to network mount the target root file system. NFS Server is already installed on DVDK but needs to be configured before using it.

User just need to edit /etc/exports file to allow the local network to mount NFS shares.

The default configuration provided with DVDK allow mounting all subdirectory of /home/shared by the default class C private network 192.168.0.0/24, but is disabled.

nelk@nelk-desktop:~$ cat /etc/exports 
# /etc/exports: the access control list for filesystems which may be exported
#		to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#

#/home/shared    192.168.0.0/24(rw,sync,no_subtree_check,no_root_squash,no_all_squash)

nelk@nelk-desktop:~$ 

If you are on the default network just remove the # at the beginning of the last line. If you are on a different network, e.g. private class A network 10.0.0.0/8, change the line in;

/home/shared    10.0.0.0/8(rw,sync,no_subtree_check,no_root_squash,no_all_squash)

Changes are applied by running exportfs -a as root, and can be verified with exportfs

nelk@nelk-desktop:~$ sudo exportfs -a
nelk@nelk-desktop:~$ sudo exportfs 
/home/shared  	192.168.0.0/24

For more information regarding NFS server and /etc/exports see exports man page or, for example, [1]