diff options
author | Marco Platania <platania@research.att.com> | 2017-06-05 15:35:45 -0400 |
---|---|---|
committer | Marco Platania <platania@research.att.com> | 2017-06-05 15:35:45 -0400 |
commit | 9f94d8c2fd838c1607f630dfdd5f936605d9873f (patch) | |
tree | a9d3150f74a788bdb829e8a8dd6f95d722ca4af4 /vnfs/vFW/scripts/v_sink_init.sh | |
parent | a8a9fec9dd7ab059c46a686d81a9b2c41537d6b8 (diff) |
Parametrize CIDR and Netmask in the demos
Change-Id: I01f46fc1ee5cd1774e3db2e3381081dc9fc4c967
Signed-off-by: Marco Platania <platania@research.att.com>
Diffstat (limited to 'vnfs/vFW/scripts/v_sink_init.sh')
-rw-r--r-- | vnfs/vFW/scripts/v_sink_init.sh | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/vnfs/vFW/scripts/v_sink_init.sh b/vnfs/vFW/scripts/v_sink_init.sh index 77f4296c..7975d435 100644 --- a/vnfs/vFW/scripts/v_sink_init.sh +++ b/vnfs/vFW/scripts/v_sink_init.sh @@ -1,7 +1,17 @@ #!/bin/bash +# Convert Network CIDR to Netmask +cdr2mask () { + # Number of args to shift, 255..255, first non-255 byte, zeroes + set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0 + [ $1 -gt 1 ] && shift $1 || shift + echo ${1-0}.${2-0}.${3-0}.${4-0} +} + # Set the IP address of the protected network interface of the vFirewall as a default gateway to the unprotected network PROTECTED_NET_GW=$(cat /opt/config/protected_net_gw.txt) UNPROTECTED_NET=$(cat /opt/config/unprotected_net.txt | cut -d'/' -f1) +BITS=$(cat /opt/config/unprotected_net.txt | cut -d"/" -f2) +NETMASK=$(cdr2mask $BITS) -route add -net $UNPROTECTED_NET netmask 255.255.255.0 gw $PROTECTED_NET_GW +route add -net $UNPROTECTED_NET netmask $NETMASK gw $PROTECTED_NET_GW |