From: Andy Bavier Date: Mon, 20 Apr 2009 18:15:18 +0000 (+0000) Subject: Sync with vsys-scripts X-Git-Tag: vsys-0.99-0~17 X-Git-Url: http://git.onelab.eu/?p=vsys.git;a=commitdiff_plain;h=8ed96be634f1c0cd324d15e366efbf508cb20744 Sync with vsys-scripts --- diff --git a/factory/setup-link b/factory/setup-link index e5cbd2f..d56c91a 100755 --- a/factory/setup-link +++ b/factory/setup-link @@ -1,7 +1,5 @@ #!/bin/sh +x -IP=/sbin/ip - SLICE=$1 SLICEID=`id -u $SLICE` read INDEX @@ -11,17 +9,16 @@ read KEY LINK=${KEY}if${INDEX} modprobe ip_gre -modprobe etun ### Setup EGRE tunnel EGRE=d$LINK -$IP tunnel add $EGRE mode gre/eth remote $REMOTE key $KEY -$IP link set $EGRE up +ip tunnel add $EGRE mode gre type eth remote $REMOTE key $KEY ttl 64 +ip link set $EGRE up ### Setup etun ETUN0=a$LINK ETUN1=b$LINK -echo $ETUN0,$ETUN1 > /sys/module/etun/parameters/newif +ip link add name $ETUN0 type veth peer name $ETUN1 ifconfig $ETUN0 mtu 1458 up ifconfig $ETUN1 up @@ -44,7 +41,7 @@ cat > $GRAB < /sys/class/net/$ETUN0/new_ns_pid +ip link set $ETUN0 netns $PID EOF chmod +x $GRAB @@ -79,7 +76,7 @@ read NULL iptables -t mangle -D FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID # Get rid of etun devices, only need name of one of them -echo $ETUN1 > /sys/module/etun/parameters/delif +ip link delete dev $ETUN1 # Get rid of bridge ifconfig $BRIDGE down diff --git a/factory/setup-nat b/factory/setup-nat index 64be40b..5955868 100755 --- a/factory/setup-nat +++ b/factory/setup-nat @@ -1,22 +1,18 @@ #!/bin/sh +x -IP=/sbin/ip - SLICE=$1 SLICEID=`id -u $SLICE` read KEY -modprobe etun - ### Setup etun ETUN0=nat$KEY ETUN1=natx$KEY -echo $ETUN0,$ETUN1 > /sys/module/etun/parameters/newif +ip link add name $ETUN0 type veth peer name $ETUN1 ifconfig $ETUN1 10.0.$KEY.1 up -/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE -/sbin/iptables -A FORWARD -i eth0 -o $ETUN1 -m state --state RELATED,ESTABLISHED -j ACCEPT -/sbin/iptables -A FORWARD -i $ETUN1 -o eth0 -j ACCEPT +iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE +iptables -A FORWARD -i eth0 -o $ETUN1 -m state --state RELATED,ESTABLISHED -j ACCEPT +iptables -A FORWARD -i $ETUN1 -o eth0 -j ACCEPT ### Create "grab link" script GRAB=/vsys/local_grab-$ETUN0 @@ -27,7 +23,7 @@ cat > $GRAB < /sys/class/net/$ETUN0/new_ns_pid +ip link set $ETUN0 netns $PID EOF chmod +x $GRAB @@ -41,12 +37,12 @@ cat > $DELETE < /sys/module/etun/parameters/delif +ip link delete dev $ETUN1 # Clean up files rm -f $GRAB $GRAB.acl