diff options
author | root <rujun.li@intel.com> | 2017-09-21 11:01:06 +0800 |
---|---|---|
committer | rujun li <rujun.li@intel.com> | 2017-09-22 06:29:10 +0000 |
commit | 3958b908d8802195292a59e84f43ce5180f01a2b (patch) | |
tree | 6501f95822083f405970874ecac012dffe762233 /vnfs/vCPE | |
parent | 2b048ca69a0fb3b8a76746a1d6cb8cf5075a73c5 (diff) |
Add scripts to bind nic and set ip
Issue-ID: INT-80
Change-Id: Idd407cadae26f354b85a356ce5aaf6e090e03fc1
Signed-off-by: root <rujun.li@intel.com>
Signed-off-by: RujunLi <rujun.li@intel.com>
Diffstat (limited to 'vnfs/vCPE')
-rw-r--r-- | vnfs/vCPE/scripts/v_brgemu_init.sh | 1 | ||||
-rw-r--r-- | vnfs/vCPE/scripts/v_brgemu_install.sh | 57 |
2 files changed, 57 insertions, 1 deletions
diff --git a/vnfs/vCPE/scripts/v_brgemu_init.sh b/vnfs/vCPE/scripts/v_brgemu_init.sh index 1bf8a500..fdeb4395 100644 --- a/vnfs/vCPE/scripts/v_brgemu_init.sh +++ b/vnfs/vCPE/scripts/v_brgemu_init.sh @@ -3,4 +3,5 @@ systemctl start vpp systemctl start honeycomb +/opt/bind_nic.sh /opt/set_nat.sh diff --git a/vnfs/vCPE/scripts/v_brgemu_install.sh b/vnfs/vCPE/scripts/v_brgemu_install.sh index c4626a41..86d08b4b 100644 --- a/vnfs/vCPE/scripts/v_brgemu_install.sh +++ b/vnfs/vCPE/scripts/v_brgemu_install.sh @@ -193,9 +193,61 @@ set bridge-domain arp term 10 EOF cat >> /opt/config/ip.txt << EOF -hcip: 192.168.1.20 +hcip: 192.168.4.20 EOF +cat > /opt/bind_nic.sh << EOF +while : +do + if [[ ! $(ps -aux | grep [[:alnum:]]*/vpp/startup.conf | wc -l) = 2 ]]; then + #echo "vpp not running" + else + break + fi +done +nic_name=$(lshw -C network | grep "logical name:") +nic_name=${nic_name#*:} +ifconfig $nic_name down +service vpp restart +while read -r line +do + re=${line#*/[0-9]/[0-9]} + if [ "$line" != "$re" ]; then + nic=${line%(*} + vppctl set dhcp client intfc $nic + vppctl set int state $nic up + break + fi +done < <(vppctl show int addr) +while read -r sdnc_ip +do + if [[ $sdnc_ip = sdnc_ip* ]]; then + sdnc_ip=${sdnc_ip#*" "} + break + fi +done < /opt/config/ip.txt + +vppctl tap connect tap0 +vppctl set int state tap-0 up +vppctl set int ip addr tap-0 20.0.0.40/24 +ifconfig tap0 192.168.4.20/24 +route add -host $sdnc_ip tap0 +route add -host 20.0.0.40 tap0 +vppctl ip route add 192.168.4.0/24 via tap-0 +vppctl set interface snat in tap-0 out $nic +while read -r hw +do + if [[ "$hw" = tap-0* ]]; then + read -r hw + hw_addr=${hw#" "} + hw_addr=${hw_addr#" "} + break + fi +done < <(vppctl show hardware) +arp -s $sdnc_ip $hw_addr +EOF +chmod +x /opt/bind_nic.sh + #set nat rule cat > /opt/set_nat.sh << EOF #! /bin/bash @@ -206,6 +258,7 @@ do #echo "vpp not running" continue fi + flag=0 while read -r line do @@ -245,6 +298,8 @@ do sleep 1 done EOF +chmod +x /opt/set_nat.sh + # Download and install HC2VPP from source cd /opt git clone ${HC2VPP_SOURCE_REPO_URL} -b ${HC2VPP_SOURCE_REPO_BRANCH} hc2vpp |