What you are trying to do is possible, but requires a little bit of
funny command line scripting.  Here are some scripts I wrote to boot UML
machines.  You will need to create /etc/uml/, a uml-net user group, and
put each virtual machine as a user in its own home directory.  Swap
files should be named swap and root filesystems should be named root_fs.
swap and root_fs should be owned by the user that the virtual machine
runs as.

add the following to /etc/rc.local

------------------------------------------------------
# Copyright Jonas Meyer 2009.  This script is licensed under the latest
# version of the GPL, which is currently 3, and the full text of which 
# is available at fsf.org

# Make it so UMLs can use tuntap
chown root:uml-net /dev/net/tun

# Make the host forward low level network packets from the UMLs to the
local
# subnet.  This let's routers and stuff think that UMLs are real
machines.
echo 1 > /proc/sys/net/ipv4/ip_forward

# This is a workaround for a bug where permenant entries disappear from
the
# arp table.  Don't ask.  I have no idea how this works.
echo 512 > /proc/sys/net/ipv4/neigh/default/gc_thresh1
echo 1024 > /proc/sys/net/ipv4/neigh/default/gc_thresh2
echo 2048 > /proc/sys/net/ipv4/neigh/default/gc_thresh3
echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp

# Finally, crank up each UML.  Order is important, as some depend on
others'
# services.
/etc/uml/machine1.sh
sleep 15
/etc/uml/machine2.sh


--------------------------------------------------------------

#!/bin/sh -e

# Copyright Jonas Meyer 2009.  This script is licensed under the latest
# version of the GPL, which is currently 3, and the full text of which 
# is available at fsf.org

# Set global variables
HOST_ADAPTER="eth0"
HOST_IP="xxx.xxx.xxx.xxx"
GUEST_IP="xxx.xxx.xxx.xxy"
USER="machine1"
TAP="machine1tap"
MAC="fe:fd:00:00:00:00"
MEMORY="48M"

# make a tap interface (fake ethernet link that the host and guest
communicate via
tunctl -u $USER -b -t $TAP
ifconfig $TAP $HOST_IP up netmask 255.255.255.255

# tell the host how to talk to the uml
route add -host $GUEST_IP dev $TAP

# make the host forward low level ip packets from umls to local subnet
# This lets routers and stuff know how to find the uml
echo 1 > /proc/sys/net/ipv4/conf/$TAP/proxy_arp

# now do it back the other way to the uml
arp -Ds $GUEST_IP $HOST_ADAPTER pub

# Crank up UMLs
screen -d -m -S $USER su - $USER -c
"cd /home/$USER ; /usr/local/bin/linux ubda=root_fs ubdb=swap
eth0=tuntap,$TAP,$MAC mem=$MEMORY"

----------------------------------------------------------------

pull out the extra linebreaks added by email and you should be good to
go.

Jonas


On Fri, 2009-08-21 at 00:13 +0100, andy baxter wrote:
> hi,
> 
> I have two virtual machines, dolphin and anthill, running on a single 
> real machine, whale. I am trying to set them both up to serve websites. 
> dolphin is for my personal stuff and anthill is for a site that I'm 
> doing with some other people - I want to be able to give them root 
> access to the vm but not to whale or dolphin.
> 
> The problem I'm having is getting the networking set up right. I can 
> start either of the vms separately, and they start up OK, but when I 
> start them both together, the second one to start can't start its 
> network. I've tried two ways of doing it:
> 
> - using a single tap device (tap0), with the IP 192.168.2.1, and dolphin 
> on 192.168.2.2, anthill on 192.168.2.3
> - using two tap devices (tap0=192.168.2.1 --> dolphin=192.168.2.2, 
> tap1=192.168.2.3 --> anthill=192.168.2.4)
> 
> Neither of these seem to work.
> 
> Before I try anything else, it would be good to know if what I'm trying 
> to do is possible in principle, or if there are limitations in the way 
> TUN/TAP works which I need to know about. What I really want is to have 
> a virtual network of VMs all on the same network with a single route 
> (tap device) to the host computer. The reason for this is that whale is 
> also serving as my network firewall, and it's awkward to define rules 
> for multiple interfaces in shorewall.
> 
> Is this possible?
> 
> Thanks,
> 
> andy
> 
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with 
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> User-mode-linux-user mailing list
> User-mode-linux-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
User-mode-linux-user mailing list
User-mode-linux-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user

Reply via email to