* Changed default for broadcast config to '+', i.e. auto-calculate.
authorUrban Wallasch <urban.wallasch@freenet.de>
Mon, 22 Apr 2019 17:17:57 +0000 (19:17 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Mon, 22 Apr 2019 17:17:57 +0000 (19:17 +0200)
* Added GUEST_PLEN and GUEST_BCAST for static guest configurations.
* Replace `route add` by `ip route add` invocation.
* Partially blanked the example MAC addresses.

nns.sh

diff --git a/nns.sh b/nns.sh
index 784f4f735391c91bd2cd1400300d5daae98b42a7..b6e0831e324552ca996467016a2c975283b2ec4f 100755 (executable)
--- 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