Differences between revisions 5 and 6
Revision 5 as of 2008-10-02 06:11:22
Size: 7638
Editor: FranklinPiat
Comment: formating
Revision 6 as of 2008-10-02 14:34:13
Size: 9758
Editor: ?JosephRawson
Comment: add some more instructions, thanks for the help with formatting :)
Deletions are marked like this. Additions are marked like this.
Line 114: Line 114:

You will need a directory to store your uml images. Make the directory, and
copy /etc/rootstrap/rootstrap.conf to it. Change (cd) to that directory and
edit the rootstrap.conf file. You can use mine as an example. The name of both
the uml machine and the filesystem image will be "nethead". Feel free to change
it, but remember that the rest of this guide will assume that the this uml's name is
nethead.
Line 169: Line 177:
Once you have prepared the rootstrap.conf file, you are ready to run rootstrap. Make sure
that you are in the same directory as the rootstrap.conf that you just modified and type:

{{{
rootstrap nethead
}}}

Here, nethead is the name of the image file. I like to keep the image files
named after the hostnames of the uml's (or prefixed with the hostname when
using multiple images). This is a good habit, as it keeps things organized when you
have a lot of testing machines laying around.

We will wait just a bit before we configure nethead.
Line 172: Line 193:
We are now ready to start configuring the tap bridge. We won't bring this interface
up until the we configure the nethead uml, but doing this now will help you see
what is going to be happening, and how the nethead uml will be run.
Line 173: Line 198:
no auto here, bring this interface up when you login to the desktop
Line 187: Line 211:
save this in /etc/network/br0-interface
replace username with the your user name
Please note that there is no auto line here. This is because this interface would be
brought up too early in the boot process, and the nethead uml would be able to
connect to the switch. You can bring this interface up when you login to the desktop, or
you can make an initscript for this that will run after the uml-utilities script runs.

The interface stanza above references a script to be run on enabling and disabling
the tap bridge interface. This script is provided below. Save this script in
/etc/network/br0-interface and replace username with the your user name. You will
also need to set the ubd0 variable to the absolute path to the nethead uml image that
you just made.
Line 197: Line 229:
         # If you don't need ip forwarding or already have it, remove
    # or comment out the next two lines, and the corresponding lines for "down"
Line 200: Line 233:
    # I don't really think it makes a difference whether the TERM variable is
    # set here, or left unset. The uml kernel seems to complain either way.
Line 209: Line 244:

===== Configure Nethead UML Machine =====

[:DebianWiki/EditorGuide#translation:Translation(s)]: none

(!) [:/Discussion:Discussion]


There is not much info here yet. This page is devoted to describing how to configure debian to be able to use a virtual network on your system that lets different virtualization applications to work together and be able to talk to each other on the virtual network.

?TableOfContents(5)

Virtual Networking

Getting User Mode Linux networked with VirtualBox

Introduction

The method outlined below will help get user-mode-linux machines and VirtualBox machines working on the same "virtual network". In this routine, we will be creating a primary tap interface and bridging it. This is not the same as bridging the local ethernet interface, and the virtual machines will only be accessible from the host system.

In this guide, I will be using some abbreviations. The term "uml" will be used to refer to a user-mode-linux virtual machine. The term "vbox" will be used to refer to a virtualbox machine. The term "VM" (or "vm") will be used for an unspecified virtual machine (either uml or vbox). Also there will be some assumptions being made that you may want to change. It will be assumed that your local network interface will be called eth0. It will also be assumed that the virtual network that you'll be creating is on 10.1.0.0/24, with the host being 10.1.0.1 and the main uml machine on 10.1.0.2 .

This guide will also make use of a persistent uml machine to run the dhcp server and the nameserver for the virtual network. This is not really necessary, as you can choose to run those programs on the host system. It is useful, however, if you wish to keep the configuration on the host system at a minimum, and also to minimize the requirement for root access on the host system.

These instructions can be modified to use vde2. Doing this will allow you to also use qemu and kvm machines on the same network. Using vde2 would probably be the optimal setup for this guide, but since I'm not using it at the moment, these instructions will have to suffice.

One final note. These instructions will assume that you are either familiar with the programs and/or procedures detailed here, or are willing to read up on them. These instructions aren't meant to be howto's for using rootstrap, setting up a bridged network, configuring dhcp3-server, etc. I will try to provide links to places where you can learn how to do these things, but this guide isn't meant to be a replacement for those instructions.

Prepare Host System

Install Requirements

Required packages on host system:

You will need to add your user to these groups: uml-net and vboxusers

You will need to log out entirely and possibly kill every process being run by that user in order to finalize the addition to the groups (slay is a good command for this). The rest of the guide will assume that this has already been done.

Prepare TAP Interface

Edit /etc/network/interfaces and add these lines:

        auto tap0
        iface tap0 inet static
                address 10.1.0.1
                netmask 255.255.255.0
                tunctl_user uml-net

The ip address can be changed according to your needs, but the rest of the guide will assume that it's set to 10.1.0.1 .

Edit /etc/default/uml-utilites and set UML_SWITCH_OPTIONS="-tap tap0".

Now you can stop uml-utilities:

sudo /etc/init.d/uml-utilities stop

Bring up the new tap interface:

sudo ifup tap0

Now start uml-utilities again:

sudo /etc/init.d/uml-utilities start

This should start the uml_switch on tap0.

At this point, you will probably want to enable masquerading to get the tap network access to the local network or internet. You will only have to do this once here, since later, we will write scripts to help manage this.

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

Don't bother reading below here

Prepare Rootstrap

You will need a directory to store your uml images. Make the directory, and copy /etc/rootstrap/rootstrap.conf to it. Change (cd) to that directory and edit the rootstrap.conf file. You can use mine as an example. The name of both the uml machine and the filesystem image will be "nethead". Feel free to change it, but remember that the rest of this guide will assume that the this uml's name is nethead.

my rootstrap.conf:

[global]
fstype=ext2
## I have about 100M or so free using a 1G 
## filesystem.  I'm not running much more than
## the standard, plus dhcp3-server, bind9 and 
## some extra stuff like xemacs, rsync, slay, etc.
initialsize=1024
freespace=0
modules=network mkfs mount debian uml umount
PATH=/bin:/sbin:/usr/bin:/usr/sbin
## we will set the memory back down to 32M once
## the rootstrap is over, but having it high is
## helpful for installing the system
umlargs=mem=128M
## you don't really need this one, but it can be 
## informative, and will help when you run into problems
debug=true

[network]
## the rest of the guide will assume that this
## hostname is being used, but you can change
## this, just be aware that this hostname will 
## be used in the guide.
hostname=nethead

## most of this was just uncommented from
## the example rootstrap.conf file and the
## ip's were modified.
interface=eth0
transport=daemon
uml=10.1.0.2
netmask=255.255.255.0
control=/var/run/uml-utilities/uml_switch.ctl
data=/var/run/uml-utilities/uml_switch.data
gateway=10.1.0.1
## get the nameserver from /etc/resolv.conf
## and replace this option
nameserver=10.1.0.1

[debian]
dist=lenny
mirror=http://10.1.0.1/debian
exclude=pcmcia-cs setserial

[base-config]
root_password=rootstrap

[uml]
kernel_modules=copy
kernel_modules_dir=/usr/lib/uml/modules

Once you have prepared the rootstrap.conf file, you are ready to run rootstrap. Make sure that you are in the same directory as the rootstrap.conf that you just modified and type:

rootstrap nethead

Here, nethead is the name of the image file. I like to keep the image files named after the hostnames of the uml's (or prefixed with the hostname when using multiple images). This is a good habit, as it keeps things organized when you have a lot of testing machines laying around.

We will wait just a bit before we configure nethead.

Prepare TAP Bridge

We are now ready to start configuring the tap bridge. We won't bring this interface up until the we configure the nethead uml, but doing this now will help you see what is going to be happening, and how the nethead uml will be run.

add this to network interfaces

iface br0 inet static
        address 10.1.0.1
        netmask 255.255.255.0
        broadcast 10.1.0.255
        bridge_ports tap0
        bridge_stp off
        bridge_fd 2.5
        post-up /etc/network/br0-interface up
        post-down /etc/network/br0-interface down

Please note that there is no auto line here. This is because this interface would be brought up too early in the boot process, and the nethead uml would be able to connect to the switch. You can bring this interface up when you login to the desktop, or you can make an initscript for this that will run after the uml-utilities script runs.

The interface stanza above references a script to be run on enabling and disabling the tap bridge interface. This script is provided below. Save this script in /etc/network/br0-interface and replace username with the your user name. You will also need to set the ubd0 variable to the absolute path to the nethead uml image that you just made.

set -e
ubd0=/path/to/uml/images/nethead

case "$1" in 
    up)
    # If you don't need ip forwarding or already have it, remove
    # or comment out the next two lines, and the corresponding lines for "down"
    iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    echo '1' > /proc/sys/net/ipv4/ip_forward
    # I don't really think it makes a difference whether the TERM variable is
    # set here, or left unset.  The uml kernel seems to complain either way.
    su -l -c "env TERM=console linux ubd0=$ubd0 eth0=daemon con=pts mem=32m umid=nethead" username &
    ;;
    down)
    su -l -c "uml_mconsole nethead halt" username
    iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
    echo '0' > /proc/sys/net/ipv4/ip_forward
    ;;
esac

Configure Nethead UML Machine

Make VirtualBox Machine

set -e
IF="$1"
BRIDGE=br0
case "$2" in
    up)
        # ensure that the TAP device is down
        sudo VBoxTunctl -d $IF >/dev/null 2>&1
        # Create a TAP network device
        sudo VBoxTunctl -u $LOGNAME -t $IF >/dev/null 2>&1
        # Bring it up (without IP address)
        sudo ifconfig $IF up
        # Add it to the bridge
        sudo brctl addif $BRIDGE $IF
        # Tell VirtualBox the name of the interface
        echo $IF
        ;;
    down)
        sudo VBoxTunctl -d $IF >/dev/null 2>&1
        ;;
esac

See also