blob: b6b9337cf21a74dcf9ddef8b5428c1f31d5d1577 (
plain) (
tree)
|
|
#!/bin/sh
# Copyright (c) 2009 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your suggestions, praise, or complaints to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# qemu-ifup
# - Script used for network setup of qemukvm in Stage4
# -----------------------------------------------------------------------------
# Use the udhcpcd as DHCP server and brctl as provided by default in OpenSLX
# environments.
brctlcmd="LD_LIBRARY_PATH=/opt/openslx/uclib-rootfs/lib\
/opt/openslx/uclib-rootfs/usr/sbin/brctl"
dhcpdcmd="LD_LIBRARY_PATH=/opt/openslx/uclib-rootfs/lib\
/opt/openslx/uclib-rootfs/usr/sbin/udhcpd"
# Just decide by the virtual network device used which kind of connection
# should be set up (passed in $1): tap0 = bridge, tap1 = nat, tap2 = hostonly.
case "$1" in
tap0)
# Adding the tap0 interface to the existing bridge configured in stage3
eval $brctlcmd addif br0 tap0
;;
tap1)
# Configuring DHCP on host tap1 interface and enable IP masquerading
mkdir /var/lib/qemu
sed "s,NWIF,tap1,;s,/misc,/qemu," /etc/opt/openslx/udhcpd.qemukvm \
>/var/lib/qemu/udhcpd.conf
eval $dhcpdcmd /var/lib/qemu/udhcpd.conf
echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding
echo "1" >/proc/sys/net/ipv4/conf/tap1/forwarding
iptables -t nat -A POSTROUTING -i tap1 -o br0 -j MASQUERADE
;;
tap2)
:
;;
esac
|