13 ### Avoid IP address collisions between NAT and virtual links.
14 ### Virtual links have addresses 10.A.B.[23], where A < B always.
15 ### So make sure that A > B for NAT.
17 if [ $KEY > $NODEID ]; then
18 BASE="10.$KEY.$NODEID"
20 BASE="10.$NODEID.$KEY"
26 echo $ETUN0,$ETUN1 > /sys/module/etun/parameters/newif
27 ifconfig $ETUN1 $BASE.1 up
29 /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
30 /sbin/iptables -A FORWARD -i eth0 -o $ETUN1 -m state --state RELATED,ESTABLISHED -j ACCEPT
31 /sbin/iptables -A FORWARD -i $ETUN1 -o eth0 -j ACCEPT
33 ### Put a process in the vserver so we can move the interface there
34 su $SLICE -c "sleep 30" &
36 PID=`su $SLICE -c "pgrep sleep"`
37 chcontext --ctx 1 -- echo $PID > /sys/class/net/$ETUN0/new_ns_pid
40 su $SLICE -c "sudo /sbin/ifconfig $ETUN0 $BASE.2/24 up; \
41 sudo /sbin/route add -net $BASE.0/24 $ETUN0; \
42 sudo /sbin/route add default gw $BASE.1"