From: Urban Wallasch Date: Mon, 22 Apr 2019 17:17:57 +0000 (+0200) Subject: * Changed default for broadcast config to '+', i.e. auto-calculate. X-Git-Url: https://git.packet-gain.de/?a=commitdiff_plain;h=8159af7fca35b3f64b8aa61e1b96291405d7f1da;p=netutil.git * Changed default for broadcast config to '+', i.e. auto-calculate. * Added GUEST_PLEN and GUEST_BCAST for static guest configurations. * Replace `route add` by `ip route add` invocation. * Partially blanked the example MAC addresses. --- diff --git a/nns.sh b/nns.sh index 784f4f7..b6e0831 100755 --- a/nns.sh +++ b/nns.sh @@ -26,17 +26,20 @@ NNSNAME= BASE_IF=vpn_tap1 +# If GUEST_ADDR is empty, DHCP is used to figure stuff out: GUEST_ADDR= -GUEST_NET=192.168.30.0/24 -GUEST_MAC=FE:17:90:DF:24:4F - +GUEST_NET=192.168.30.0 +# '+' means auto calculate broadcast address: +GUEST_BCAST=+ +GUEST_PLEN=24 +GUEST_MAC=FE:17:90:00:00:00 BRIDGE_IF=br0 BRIDGE_ADDR=192.168.30.3 -BRIDGE_BCAST=192.168.30.255 +# '+' means auto calculate broadcast address: +BRIDGE_BCAST=+ BRIDGE_PLEN=24 -BRIDGE_MAC=FE:17:90:DE:23:4D - +BRIDGE_MAC=FE:17:90:00:00:01 # List of nameservers to provide DNS in the new network namespace; # If empty, host resolv.conf will be used. @@ -158,14 +161,14 @@ start_nns() { if [ -z "$GUEST_ADDR" ] ; then $IP netns exec $1 $DHCLIENT -pf "$RUNDIR/dhclient.$VETH_GUEST.pid" -v $VETH_GUEST else - $IP netns exec $1 $IP addr add $GUEST_ADDR dev $VETH_GUEST + $IP netns exec $1 $IP addr add $GUEST_ADDR/$GUEST_PLEN broadcast $GUEST_BCAST dev $VETH_GUEST $IP netns exec $1 $IP link set dev $VETH_GUEST up fi $IP netns exec $1 $IP link set dev lo up # Set up routing: $IPTABLES -t nat -A POSTROUTING --source $GUEST_NET --jump MASQUERADE - $IP netns exec $1 /sbin/route add default gw $BRIDGE_ADDR + $IP netns exec $1 $IP route add default via $BRIDGE_ADDR # Run the configured command, if any, inside the namespace: if [ -n "$XCMD" ] ; then