Example-update-rootfs

From VNUML-WIKI
Revision as of 11:33, 4 October 2007 by Fjmartin (talk | contribs) (Connection through NAT)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Update Root-Filesystem Example

Authors:
Fermín Galán (galan at dit.upm.es)
David Fernández (david at dit.upm.es)
version 1.8, October 3rd, 2007


Scenario

This is a simple example useful to install or update applications inside a UML root filesystem. It just creates a virtual machine with external network access. Once started you can use typical applications like dselect or apt-get in Debian to update the filesystem.

Two versións of the scenario are presented:

  • Direct connection, where the virtual machine is connected by means of a new subinterface configured in the host machine network interface.
  • Connection through NAT, where the virtual machine is connected to an internal virtual private network which is connected to Internet through a NAT configured in the host machine.

Important notes:

  • As this example interacts with the host machine network interface, an incorrect use of it can let the host unaccesible. Even if correctly used, the host will be unaccesible during short periods of time while the simulation starts/stops. So, it is recomended to execute it from the host console (at least not being far from it :).
  • If you are experiencing problems with the conventional xterm, we recommend you to uncomment the <xterm> tag in each virtual machine, in order to use gnome-terminal, that seems to be more stable. Of course, you will need the gnome-terminal installed in your system.
  • Note the use of <filesystem type="direct"> in order to make the changes in the filesystem (e.g., installed software) permantent. If you were using for example type="cow" changes won't be stored in the /usr/share/vnuml/filesystems/root_fs_tutorial file. More information about installing software in the User Manual.


Direct Connection

In this case, the virtual machine is connected to Internet using its own IP address configured over the network interface of the host.

update rootfilesystem

To configure this example, you need an aditional IP network address from the subnet where the host is connected. The relevant data used in the example follows:

  • Host address: 192.168.11.16
  • Virtual Machine address: 192.168.11.30
  • Router address: 192.168.11.254
  • Subnet Mask: 255.255.255.0 (/24)

After starting the scenario you will have to access the virtual machine and configure the address of a DNS server in your network in order to have full Intenter access. To do that, you just have to edit /etc/resolv.conf file and add a line like:

 nameserver x.y.z.v

being x.y.z.v the IP address of your DNS server.

Connection through NAT

In this case the virtual machine is connected to a virtual private network using private addresses. The host is configured to run a NAT that allows sharing the host IP address between the host and the virtual machine.

update rootfilesystem though a host NAT

In the example we use a private network (192.168.1.0/24), having the virtual machine the address 192.168.1.2 and the host 192.168.1.1.

In order to configure the NAT in your host, you will have to execute the following commands:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

being "eth0" the name of the host interface you will use to conncet to Internet.

After starting the scenario you will have to access the virtual machine and configure the address of a DNS server in your network in order to have full Intenter access. To do that, you just have to edit /etc/resolv.conf file and add a line like:

nameserver x.y.z.v

being x.y.z.v the IP address of your DNS server.

VNUML Description

Direct Connection

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vnuml SYSTEM "/usr/share/xml/vnuml/vnuml.dtd" [
  <!ENTITY VNUMLDIR "/usr/share/vnuml/">
  <!ENTITY BASEDIR  "/usr/share/vnuml/examples/update-fs/">
  <!ENTITY REDIR "&lt;/dev/null &gt;/dev/null 2&gt;&amp;1&amp;">
]>
<vnuml>

   <global>
      <version>1.8</version>
      <simulation_name>update-fs</simulation_name>
      <ssh_key>/root/.ssh/identity.pub</ssh_key>
      <automac offset="0"/>
      <vm_mgmt type="none" network="192.168.0.0" mask="24" offset="0"/>
   </global>
   
   <net name="Net0" mode="virtual_bridge" external="eth0"/>
   
   <vm name="vm1">
      <filesystem type="direct">&VNUMLDIR;filesystems/root_fs_tutorial</filesystem>
      <mem>64M</mem>
      <kernel>&VNUMLDIR;kernels/linux</kernel>
      <console id="1">xterm</console>
      <!--xterm>gnome-terminal,-t,-x</xterm-->      
      <if id="1" net="Net0">
         <ipv4 mask="255.255.255.0">192.168.11.30</ipv4>
      </if>
      <route type="ipv4" gw="192.168.11.254">default</route>
   </vm>
   
   <host>
      <hostif net="Net0">
         <ipv4 mask="255.255.255.0">192.168.11.16</ipv4>
      </hostif>
      <physicalif name="eth0" type="ipv4" ip="192.168.11.16" mask="255.255.255.0" gw="172.16.0.1"/>
      <route type="ipv4" gw="192.168.11.254">default</route>
   </host>
</vnuml>


Connection through NAT

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vnuml SYSTEM "/usr/share/xml/vnuml/vnuml.dtd" [
  <!ENTITY VNUMLDIR "/usr/share/vnuml/">
  <!ENTITY BASEDIR  "/usr/share/vnuml/examples/update-fs/">
  <!ENTITY REDIR "&lt;/dev/null &gt;/dev/null 2&gt;&amp;1&amp;">
]>
<vnuml>

  <global>
    <version>1.8</version>
    <simulation_name>update-fs-nat</simulation_name>
    <ssh_key>/root/.ssh/identity.pub</ssh_key>
    <automac/>
    <vm_mgmt type="none"/>
    <vm_defaults>
       <console id="1">xterm</console>
    </vm_defaults>
  </global>  

  <net name="Net0" mode="uml_switch"/>

  <vm name="vm1">
    <filesystem type="direct">&VNUMLDIR;filesystems/root_fs_tutorial</filesystem>
    <mem>64M</mem>
    <kernel>&VNUMLDIR;kernels/linux</kernel>
    <if id="1" net="Net0">
     <ipv4 mask="255.255.255.0">192.168.1.2</ipv4>
    </if>
    <route type="ipv4" gw="192.168.1.1">default</route>
  </vm>

  <host>
    <hostif net="Net0">
       <ipv4 mask="255.255.255.0">192.168.1.1</ipv4>
    </hostif>
  </host> 

</vnuml>

Download

Old Releases