diff options
author | Dirk | 2013-12-13 20:52:00 +0100 |
---|---|---|
committer | Dirk | 2013-12-13 20:52:00 +0100 |
commit | efd86cc8b5b138e4076bf1657ea888dc52e62901 (patch) | |
tree | dde241d9c0041f10584415e97c6b6f326e03cd3f /remote/modules/vmchooser | |
parent | Merge branch 'master' of git.openslx.org:openslx-ng/tm-scripts (diff) | |
download | tm-scripts-efd86cc8b5b138e4076bf1657ea888dc52e62901.tar.gz tm-scripts-efd86cc8b5b138e4076bf1657ea888dc52e62901.tar.xz tm-scripts-efd86cc8b5b138e4076bf1657ea888dc52e62901.zip |
Heavily reworked the networking for the various virtual machines:
There will be three types of network interfaces for virtual machines available
all will be configured for every type of virtualization tool
a) br0 is the direct host bridge into the local LAN (br0 already exists)
vmnet0 for VMware
vboxnet0 for VirtualBox
kvmnet0* for Qemu/KVM
b) nat1 is an internal bridge which "NATes" into the local LAN (with DHCP)
vmnet1 for VMware
vboxnet1 for VirtualBox
kvmnet1* for Qemu/KVM
c) vsw2 is an internal host bridge to connect software defined LANs to
vmnet2 for VMware
vboxnet2 for VirtualBox
kvmnet2* for Qemu/KVM
Diffstat (limited to 'remote/modules/vmchooser')
-rwxr-xr-x | remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env | 52 | ||||
-rwxr-xr-x | remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt | 10 | ||||
-rw-r--r-- | remote/modules/vmchooser/data/opt/openslx/vmchooser/config/smb.conf | 21 | ||||
-rw-r--r-- | remote/modules/vmchooser/data/opt/openslx/vmchooser/config/udhcpd-nat1.conf (renamed from remote/modules/vmchooser/data/opt/openslx/vmchooser/config/udhcpd.conf) | 4 |
4 files changed, 78 insertions, 9 deletions
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env b/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env index c796b3db..913d9de6 100755 --- a/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env +++ b/remote/modules/vmchooser/data/opt/openslx/scripts/systemd-vmchooser_env @@ -36,7 +36,7 @@ mkdir -p "${VMCHOOSER_DIR}/fd-loop" -m 1777 grep -qE "unionfs |aufs " /proc/mounts && \ mount -n -o size=1500k -t tmpfs vm-loopimg "${VMCHOOSER_DIR}/data/loopimg" -# create an empty floppy image of 1.4MByte size +# create an empty floppy image of 1.44 MByte size dd "if=/dev/zero" "of=${VMCHOOSER_DIR}/data/loopimg/fd.img" count=2880 bs=512 2>/dev/null chmod 0777 "${VMCHOOSER_DIR}/data/loopimg/fd.img" @@ -51,8 +51,7 @@ mount -n -t msdos -o loop,umask=000 "${VMCHOOSER_DIR}/data/loopimg/fd.img" "${VM #fi # setup more scratch space for virtual machines, if configured -mkdir -p /tmp/virt -mkdir -p /var/log/samba +mkdir -p /tmp/virt /var/log/samba /run/samba # enable normal users to setup the extended virtual machine redo file space # and image source via network block device (NBD only at the moment) @@ -131,3 +130,50 @@ for floppy in $(dmesg|grep -i "Floppy drive"|sed "s,.*(s): ,,;s, is .*,,"); do j=$(expr $j + 1) done +################################################################################ +### Setup VM networking +################################################################################ + +# there will be three types of network interfaces for virtual machines available +# all will be configured for every type of virtualization tool +# a) br0 is the direct host bridge into the local LAN (br0 already exists) +# vmnet0 for VMware +# vboxnet0 for VirtualBox +# kvmnet0* for Qemu/KVM +# b) nat1 is an internal bridge which "NATes" into the local LAN (with DHCP) +# vmnet1 for VMware +# vboxnet1 for VirtualBox +# kvmnet1* for Qemu/KVM +# c) vsw2 is an internal host bridge to connect software defined LANs to +# vmnet2 for VMware +# vboxnet2 for VirtualBox +# kvmnet2* for Qemu/KVM + +# creating and configuring nat0 +brctl addbr nat1 +ip link set dev nat1 up +ip addr add 192.168.101.1/24 dev nat1 +echo "1" >/proc/sys/net/ipv4/conf/nat1/forwarding +echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding 2>/dev/null +iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE + +for wait in 1 1 2 2 3 end; do + grep '^SLX_DNS' "/opt/openslx/config" > /dev/null && break + [ "$wait" == "end" ] && echo "No DNS config found, using google dns" && break + echo "Waiting for DNS config.." + sleep "$wait" +done + +# read the DNS configuration and configure the udhcpd +[ -z "${SLX_DNS}" ] && SLX_DNS="8.8.8.8" +sed -i "s,DNSSERVER,${SLX_DNS},;s,DOMAIN,${SLX_NET_DOMAIN}," \ + /opt/openslx/vmchooser/config/udhcpd-nat1.conf + +mkdir -p /var/lib/udhcpd +udhcpd -S /opt/openslx/vmchooser/config/udhcpd-nat1.conf + +# creating and configuring vsw2 +brctl addbr vsw2 +ip link set dev vsw2 up +echo "1" >/proc/sys/net/ipv4/conf/vsw2/forwarding + diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt index 2d6dfb41..bef43dd1 100755 --- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt +++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt @@ -439,7 +439,8 @@ SPOOLDIR="/var/spool" QUEUE="STANDARD" # Start the lpdaemon listening on the given port -tcpsvd -E 0.0.0.0 5515 \ +# FixMe: Solution for general printer redirection in other cases (iptables on outgoing port) +tcpsvd -E 192.168.101.1 5515 \ lpd "$SPOOLDIR" \ sh -c "printergui $USER $SPOOLDIR/$QUEUE/\$DATAFILE" & @@ -542,6 +543,13 @@ if ! kill -0 "$PID_LPD"; then slxlog "virt-lpd" "Could not start tcpsvd/lpd for virtual machine session" fi +# Configure and start samba service to provide user's home directory +#if [ -f /usr/sbin/smbd ] ; then +# sudo /opt/openslx/bin/sed -i /opt/openslx/vmchooser/smb.conf -e "s,USER,$USER," +# sudo /usr/sbin/nmbd -s /opt/openslx/vmchooser/config/smb.conf +# sudo /usr/sbin/smbd -s /opt/openslx/vmchooser/config/smb.conf +#fi + # This will start the VM eval ${VIRTCMD} ${VIRTCMDOPTS} # diff --git a/remote/modules/vmchooser/data/opt/openslx/vmchooser/config/smb.conf b/remote/modules/vmchooser/data/opt/openslx/vmchooser/config/smb.conf index ec757ce4..d8966f71 100644 --- a/remote/modules/vmchooser/data/opt/openslx/vmchooser/config/smb.conf +++ b/remote/modules/vmchooser/data/opt/openslx/vmchooser/config/smb.conf @@ -1,16 +1,29 @@ -# basic samba configuration file for OpenSLX host-internal networking +# ----------------------------------------------------------------------------- +# Copyright (c) 2009..2013 - OpenSLX GmbH +# +# This program/file 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 feedback to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org +# ----------------------------------------------------------------------------- +# smb.conf +# - basic samba configuration file for OpenSLX host-internal networking +################################################################################ [global] workgroup = OPENSLX netbios name = HOMESERVER security = SHARE server string = Home and Print Provider bind interfaces only = Yes - interfaces = NWIF - pid directory = PIDDIR + interfaces = nat1 + pid directory = /run/samba [userhome] comment = Home Directory of USER - path = /home/USER + path = /home/USER/PERSISTENT create mask = 0700 guest ok = No read only = No diff --git a/remote/modules/vmchooser/data/opt/openslx/vmchooser/config/udhcpd.conf b/remote/modules/vmchooser/data/opt/openslx/vmchooser/config/udhcpd-nat1.conf index eb510098..ee862e79 100644 --- a/remote/modules/vmchooser/data/opt/openslx/vmchooser/config/udhcpd.conf +++ b/remote/modules/vmchooser/data/opt/openslx/vmchooser/config/udhcpd-nat1.conf @@ -17,6 +17,7 @@ # start and end of the IP lease block start 192.168.101.20 end 192.168.101.100 +max_leases 80 # interface that udhcpd will use interface nat1 @@ -35,7 +36,8 @@ option subnet 255.255.255.0 option router 192.168.101.1 option wins 192.168.101.10 option domain DOMAIN virtual.site - +option lprsvr 192.168.101.1 +#option ntpsrv NTPSERVER # additional options known to udhcpd not used in OpenSLX at the moment #subnet #timezone |