summaryrefslogtreecommitdiffstats
path: root/vde/build/rc.vdenetwork
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2005-08-31 19:47:01 +0000
committer Eric Hameleers <alien@slackware.com>2005-08-31 19:47:01 +0000
commit8530ccfa273e63279e439548d5720fed2874c069 (patch)
tree633473fbda3f8a2a5606babf395275548be2ea5f /vde/build/rc.vdenetwork
parent940b20d0c291dfcdc9f40f72e181406c19f84f42 (diff)
downloadasb-8530ccfa273e63279e439548d5720fed2874c069.tar.gz
asb-8530ccfa273e63279e439548d5720fed2874c069.tar.xz
Initial revision
Diffstat (limited to '')
-rwxr-xr-xvde/build/rc.vdenetwork99
1 files changed, 99 insertions, 0 deletions
diff --git a/vde/build/rc.vdenetwork b/vde/build/rc.vdenetwork
new file mode 100755
index 00000000..da73a646
--- /dev/null
+++ b/vde/build/rc.vdenetwork
@@ -0,0 +1,99 @@
+#!/bin/sh
+# Qemu environment preparation script
+# ---------------------------------------------------------------------------
+#
+# After running this startup script, run a QEMU virtual machine in this way:
+#
+# vdeqemu [qemu_option [qemu_option], ...]
+#
+# The vdeqemu program will automatically connect
+# the QEMU virtual machine to the VDE switch.
+#
+# ---------------------------------------------------------------------------
+
+# The IP configuration for the tap device that will be used for
+# the virtual machine network:
+
+TAP_DEV=tap0
+TAP_IP=10.111.111.254
+TAP_MASK=255.255.255.0
+
+TAP_BCAST=`/bin/ipmask ${TAP_MASK} ${TAP_IP} | cut -f 1 -d ' '`
+
+# Definitions for the LAN segment the Qemu virtual machines will be in.
+# These definitions will be fed to dnsmasq - this program will provide DNS and DHCP to the
+# Qemu LAN.
+
+# The VM_IPLOW and VM_IPHIGH addresses must agree with the definitions for the tap0 device
+# above. These 'low' and 'high' values are the IP address range for the DHCP server to use.
+
+VM_DOMAIN=qemu.lan
+VM_IPLOW=10.111.111.128
+VM_IPHIGH=10.111.111.199
+VM_BCAST=${TAP_BCAST}
+VM_MASK=${TAP_MASK}
+
+# For additional options to dnsmasq:
+
+DNSMASQ_OPTIONS="--server /barrier.lan/192.168.0.11 \
+ --server /ibm.com/9.132.41.1"
+
+# See how we were called.
+
+case "$1" in
+ start)
+ echo -n "Starting VDE network for QEMU: "
+
+ # Start tap switch
+ vde_switch -tap ${TAP_DEV} -daemon
+
+ # Bring tap interface up
+ ifconfig ${TAP_DEV} ${TAP_IP} broadcast ${TAP_BCAST} netmask ${TAP_MASK}
+
+ # Start IP Forwarding
+ echo "1" > /proc/sys/net/ipv4/ip_forward
+ iptables -t nat -A POSTROUTING -o eth+ -j MASQUERADE
+ iptables -t nat -A POSTROUTING -o ath+ -j MASQUERADE
+
+ # Change pipe permission
+ chmod 666 /tmp/vde.ctl
+
+ # If we are running 2.6, apply workaround
+ if uname -r | grep '^2.4'; then
+ echo 1024 > /proc/sys/dev/rtc/max-user-freq
+ fi
+
+ # Start dnsmasq, the DNS/DHCP server
+ # for our Virtual Machines behind the tap0 interface
+ /usr/sbin/dnsmasq \
+ --log-queries \
+ --user=named \
+ --dhcp-leasefile=/var/state/dhcp/qemu-dhcpd.leases \
+ --dhcp-range=${VM_IPLOW},${VM_IPHIGH},${VM_MASK},${VM_BCAST},8h \
+ --interface=${TAP_DEV} \
+ --domain=${VM_DOMAIN} \
+ $DNSMASQ_OPTIONS
+ echo
+ ;;
+ stop)
+ echo -n "Stopping VDE network for QEMU: "
+ {
+ # Bring tap interface down
+ ifconfig ${TAP_DEV} down
+ # Kill VDE switch
+ pgrep -f vde_switch | xargs kill -TERM
+ # Remove the control socket
+ rm -f /tmp/vde.ctl
+ # Stop dnsmasq
+ pgrep -f dnsmasq | xargs kill -TERM
+ } >/dev/null 2>&1
+ echo
+ ;;
+ restart|reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|reload}"
+ exit 1
+esac