aboutsummaryrefslogtreecommitdiffstats
path: root/vnfs/vFW/scripts/v_firewall_install.sh
diff options
context:
space:
mode:
Diffstat (limited to 'vnfs/vFW/scripts/v_firewall_install.sh')
-rw-r--r--vnfs/vFW/scripts/v_firewall_install.sh32
1 files changed, 23 insertions, 9 deletions
diff --git a/vnfs/vFW/scripts/v_firewall_install.sh b/vnfs/vFW/scripts/v_firewall_install.sh
index 21164383..5ec634e4 100644
--- a/vnfs/vFW/scripts/v_firewall_install.sh
+++ b/vnfs/vFW/scripts/v_firewall_install.sh
@@ -6,6 +6,14 @@ DEMO_ARTIFACTS_VERSION=$(cat /opt/config/demo_artifacts_version.txt)
INSTALL_SCRIPT_VERSION=$(cat /opt/config/install_script_version.txt)
CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
+# 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}
+}
+
# OpenStack network configuration
if [[ $CLOUD_ENV == "openstack" ]]
then
@@ -17,25 +25,31 @@ then
MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
- VFW_PRIVATE_IP_O=$(cat /opt/config/vfw_private_ip_0.txt)
+ IP=$(cat /opt/config/vfw_private_ip_0.txt)
+ BITS=$(cat /opt/config/unprotected_private_net_cidr.txt | cut -d"/" -f2)
+ NETMASK=$(cdr2mask $BITS)
echo "auto eth1" >> /etc/network/interfaces
echo "iface eth1 inet static" >> /etc/network/interfaces
- echo " address $VFW_PRIVATE_IP_O" >> /etc/network/interfaces
- echo " netmask 255.255.255.0" >> /etc/network/interfaces
+ echo " address $IP" >> /etc/network/interfaces
+ echo " netmask $NETMASK" >> /etc/network/interfaces
echo " mtu $MTU" >> /etc/network/interfaces
- VFW_PRIVATE_IP_1=$(cat /opt/config/vfw_private_ip_1.txt)
+ IP=$(cat /opt/config/vfw_private_ip_1.txt)
+ BITS=$(cat /opt/config/protected_private_net_cidr.txt | cut -d"/" -f2)
+ NETMASK=$(cdr2mask $BITS)
echo "auto eth2" >> /etc/network/interfaces
echo "iface eth2 inet static" >> /etc/network/interfaces
- echo " address $VFW_PRIVATE_IP_1" >> /etc/network/interfaces
- echo " netmask 255.255.255.0" >> /etc/network/interfaces
+ echo " address $IP" >> /etc/network/interfaces
+ echo " netmask $NETMASK" >> /etc/network/interfaces
echo " mtu $MTU" >> /etc/network/interfaces
- VFW_PRIVATE_IP_2=$(cat /opt/config/vfw_private_ip_2.txt)
+ IP=$(cat /opt/config/vfw_private_ip_2.txt)
+ BITS=$(cat /opt/config/onap_private_net_cidr.txt | cut -d"/" -f2)
+ NETMASK=$(cdr2mask $BITS)
echo "auto eth3" >> /etc/network/interfaces
echo "iface eth3 inet static" >> /etc/network/interfaces
- echo " address $VFW_PRIVATE_IP_2" >> /etc/network/interfaces
- echo " netmask 255.255.255.0" >> /etc/network/interfaces
+ echo " address $IP" >> /etc/network/interfaces
+ echo " netmask $NETMASK" >> /etc/network/interfaces
echo " mtu $MTU" >> /etc/network/interfaces
ifup eth1