X-Git-Url: http://git.onelab.eu/?p=nodemanager-topo.git;a=blobdiff_plain;f=setup-nat;fp=setup-nat;h=7eb87c63bc21ff6bbce154a39213bf86b048104d;hp=c835670007fb1fba82245a4871400cf8312f70a7;hb=599d2d85b6f40ef1d3fc3b1b6d622305878cfb78;hpb=c942afff43b57d7fd15a86df5d084c224dbf972a diff --git a/setup-nat b/setup-nat index c835670..7eb87c6 100644 --- a/setup-nat +++ b/setup-nat @@ -9,22 +9,19 @@ KEY=$3 modprobe etun -### -### Avoid IP address collisions between NAT and virtual links. -### Virtual links have addresses 10.A.B.[23], where A < B always. -### So make sure that A > B for NAT. -### -if [ $KEY > $NODEID ]; then - BASE="10.$KEY.$NODEID" -else - BASE="10.$NODEID.$KEY" -fi +# +# OpenVPN uses addresses in 10./16 block. Avoid collisions with +# this block. NAT interface is not advertised and so does not require +# unique address throughout the topology. But the address of each slice's +# NAT interface must be unique on a single node. +# +BASE="10.0.$KEY" ### Setup etun ETUN0=nat$KEY ETUN1=natx$KEY echo $ETUN0,$ETUN1 > /sys/module/etun/parameters/newif -ifconfig $ETUN1 $BASE.1 up +ifconfig $ETUN1 $BASE.1/24 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