1.1 --- a/README.txt Wed May 12 02:14:32 2010 +0200
1.2 +++ b/README.txt Sat May 29 23:03:30 2010 +0200
1.3 @@ -39,12 +39,12 @@
1.4 DISTNAME, exposing derivatives of these variables by default.
1.5 * Added explicit keyring package installation.
1.6 * Added -do scripts for configuring and entering the chroot.
1.7 - * Added support for UML instance construction from distribution
1.8 - installations.
1.9 * Removed specific apt- and dpkg-related scripts, replacing them with the
1.10 general -do scripts.
1.11 * Added --root options to certain scripts in order to support normal chroot
1.12 installations.
1.13 + * Added support for UML instance construction from distribution
1.14 + installations, along with networking support and a uml-net script.
1.15
1.16 Configuration
1.17 -------------
1.18 @@ -235,6 +235,20 @@
1.19
1.20 NOTE: Add Linux build process.
1.21
1.22 +Enabling Networking for UML Instances
1.23 +-------------------------------------
1.24 +
1.25 +To enable networking for a UML instance, use the uml-net script:
1.26 +
1.27 +sudo uml-net --start $USER
1.28 +
1.29 +Here, $USER should be expanded to the name of the user running the above
1.30 +command, not the root user.
1.31 +
1.32 +To stop networking, use the same script:
1.33 +
1.34 +sudo uml-net --stop
1.35 +
1.36 Entering or Starting UML Instances
1.37 ----------------------------------
1.38
2.1 --- a/uml-do Wed May 12 02:14:32 2010 +0200
2.2 +++ b/uml-do Sat May 29 23:03:30 2010 +0200
2.3 @@ -21,7 +21,18 @@
2.4 export UML_MEMORY=$1
2.5 export THIS_DIR=`dirname $0`
2.6
2.7 +# Discard the memory argument.
2.8 +
2.9 +shift 1
2.10 +
2.11 +# Test for networking.
2.12 +
2.13 +if [[ $1 == '--net' ]]; then
2.14 + export UML_NETWORKING="$NETDEVICE=tuntap,$TUNDEVICE,fe:fd:0:0:0:1,$HOSTADDRESS"
2.15 + xhost +$GUESTADDRESS
2.16 + shift 1
2.17 +fi
2.18 +
2.19 # Now we start the virtual machine...
2.20
2.21 -shift 1
2.22 -$THIS_DIR/linux ubd0=$IMAGE ubd1=$SWAPIMAGE mem=$UML_MEMORY $*
2.23 +$THIS_DIR/linux ubd0=$IMAGE ubd1=$SWAPIMAGE mem=$UML_MEMORY $UML_NETWORKING $*
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/uml-net Sat May 29 23:03:30 2010 +0200
3.3 @@ -0,0 +1,28 @@
3.4 +#!/bin/bash
3.5 +# Usage: uml-net ( --start <username> | --stop )
3.6 +
3.7 +# Configuration:
3.8 +if [ -e userinstall-defaults-uml ]; then
3.9 + source userinstall-defaults-uml
3.10 +elif [ -e /etc/default/userinstall-uml ]; then
3.11 + source /etc/default/userinstall-uml
3.12 +else
3.13 + echo "No defaults found for userinstall (UML)."
3.14 + exit 1
3.15 +fi
3.16 +
3.17 +if [[ $1 == "--start" ]]; then
3.18 + chgrp adm /dev/net/tun
3.19 + tunctl -u $2 -t $TUNDEVICE
3.20 + ifconfig $TUNDEVICE $HOSTADDRESS up
3.21 + bash -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
3.22 + iptables -t nat -I POSTROUTING -o $NETDEVICE -j MASQUERADE
3.23 + iptables -I FORWARD -i $TUNDEVICE -j ACCEPT
3.24 + iptables -I FORWARD -o $TUNDEVICE -j ACCEPT
3.25 +
3.26 +elif [[ $1 == "--stop" ]]; then
3.27 + iptables -t nat -D POSTROUTING 1
3.28 + iptables -D FORWARD 1
3.29 + iptables -D FORWARD 1
3.30 + tunctl -d $TUNDEVICE
3.31 +fi
4.1 --- a/userinstall-defaults-uml Wed May 12 02:14:32 2010 +0200
4.2 +++ b/userinstall-defaults-uml Sat May 29 23:03:30 2010 +0200
4.3 @@ -13,3 +13,14 @@
4.4 # Configuration details for building a UML instance.
4.5
4.6 export UMLROOT=$HOME/.userinstall-uml
4.7 +
4.8 +# Optional settings.
4.9 +# Guest: the extra address provided for communication with the UML instance
4.10 +# Host: the address used inside the UML instance
4.11 +# Devices: the tunnelling device (or interface) used by the actual machine, plus
4.12 +# the device (or interface) used inside the UML instance
4.13 +
4.14 +export GUESTADDRESS=192.168.0.254
4.15 +export HOSTADDRESS=192.168.0.99
4.16 +export TUNDEVICE=tap0
4.17 +export NETDEVICE=eth0