nns.sh: fixes and improvements
authorvolpol <volpol@packet-gain.de>
Mon, 22 Apr 2019 16:18:01 +0000 (18:18 +0200)
committervolpol <volpol@packet-gain.de>
Mon, 22 Apr 2019 16:18:01 +0000 (18:18 +0200)
Fix bridge configuration (netmask / broadcast)
Use static MAC for bridge and guest network interfaces

nns.sh

diff --git a/nns.sh b/nns.sh
index 74d2a4d7c14096d09d961d1dcbf49560ba63ebae..784f4f735391c91bd2cd1400300d5daae98b42a7 100755 (executable)
--- a/nns.sh
+++ b/nns.sh
@@ -28,9 +28,15 @@ BASE_IF=vpn_tap1
 
 GUEST_ADDR=
 GUEST_NET=192.168.30.0/24
+GUEST_MAC=FE:17:90:DF:24:4F
+
 
 BRIDGE_IF=br0
 BRIDGE_ADDR=192.168.30.3
+BRIDGE_BCAST=192.168.30.255
+BRIDGE_PLEN=24
+BRIDGE_MAC=FE:17:90:DE:23:4D
+
 
 # List of nameservers to provide DNS in the new network namespace;
 # If empty, host resolv.conf will be used.
@@ -136,10 +142,12 @@ start_nns() {
     # Create the new namespace, the veth cable and the bridge interface:
     $IP netns add $1
     $IP link add $VETH_HOST type veth peer name $VETH_GUEST
+    $IP link set dev $VETH_GUEST address $GUEST_MAC
     $IP link add $BRIDGE_IF type bridge
+    $IP link set dev $BRIDGE_IF address $BRIDGE_MAC
     $IP link set $BASE_IF master $BRIDGE_IF
     $IP link set $VETH_HOST master $BRIDGE_IF
-    $IP addr add $BRIDGE_ADDR dev $BRIDGE_IF
+    $IP addr add $BRIDGE_ADDR/$BRIDGE_PLEN broadcast $BRIDGE_BCAST dev $BRIDGE_IF
     $IP link set dev $VETH_HOST up
     $IP link set dev $BRIDGE_IF up