Initial OpenECOMP Demo commit
[demo.git] / vnfs / vLB / scripts / v_lb_init.sh
1 #!/bin/bash
2
3 # Start VPP
4 start vpp
5 sleep 1
6
7 # Configure VPP for vPacketGenerator
8 IPADDR1=$(ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2)
9 IPADDR2=$(ifconfig eth1 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2)
10 HWADDR1=$(ifconfig eth0 | grep HWaddr | tr -s ' ' | cut -d' ' -f5)
11 HWADDR2=$(ifconfig eth1 | grep HWaddr | tr -s ' ' | cut -d' ' -f5)
12 FAKE_HWADDR1=$(echo -n 00; dd bs=1 count=5 if=/dev/urandom 2>/dev/null |hexdump -v -e '/1 ":%02X"')
13 FAKE_HWADDR2=$(echo -n 00; dd bs=1 count=5 if=/dev/urandom 2>/dev/null |hexdump -v -e '/1 ":%02X"')
14 GW=$(route | grep default | awk '{print $2}')
15
16 ifconfig eth0 down
17 ifconfig eth0 hw ether $FAKE_HWADDR1
18 ip addr flush dev eth0
19 ifconfig eth0 up
20 vppctl tap connect tappub hwaddr $HWADDR1
21 vppctl set int ip address tap-0 $IPADDR1"/24"
22 vppctl set int state tap-0 up
23 brctl addbr br0
24 brctl addif br0 tappub
25 brctl addif br0 eth0
26 ifconfig br0 up
27
28 ifconfig eth1 down
29 ifconfig eth1 hw ether $FAKE_HWADDR2
30 ip addr flush dev eth1
31 ifconfig eth1 up
32 vppctl tap connect tap111 hwaddr $HWADDR2
33 vppctl set int ip address tap-1 $IPADDR2"/24"
34 vppctl set int state tap-1 up
35 brctl addbr br1
36 brctl addif br1 tap111
37 brctl addif br1 eth1
38 ifconfig br1 up
39 sleep 1
40
41 vppctl lb conf ip4-src-address $IPADDR2
42 vppctl lb vip $IPADDR1"/32" encap gre4
43 vppctl ip route add 0.0.0.0/0 via $GW
44 sleep 1
45
46 cd /opt/FDserver
47 ./dnsmembership.sh &>/dev/null &disown
48
49 # Start VES client
50 cd /opt/VES/code/evel_training/VESreporting/
51 echo 0 > active_dns.txt
52 ./go-client.sh &>/dev/null &disown