Debian Codegraph @

samples/bagpipe-bgp/chain-example3

raw
1 #!/bin/bash
2 #
3 # This is an example of a service chain between two IP VPNs
4 # for which we do not modify the RT import/export lists to
5 # establish chaining.
6 #
7 # This script will setup network namespaces SVM1 ("service VM1") and SVM2 so that
8 # traffic between net1 (to which VM1 is attached) and net2 (to which VM2 is attached)
9 # goes through SMV1 and SVM2:
10 #
11 # VM1-------net1 SVM1 --- SVM2 net2-----VM2
12 # .1 11.0.0. 12.0.0 .1
13 #
14 # Route targets....
15 #
16 # net1: :1
17 # net2: :2
18 #
19 # - chain for traffic from net1 to net2:
20 # hop12_0: first hop: net1 to SVM1
21 # hop12_1: second hop: SVM1 to SVM2
22
23 as=64512
24
25 hop12_0=$as:120
26 hop12_1=$as:121
27
28 ##
29 ## - chain for traffic from net2 to net1:
30 ## hop21_0: first hop: net2 to SVM2
31 ## hop21_1: second hop: SVM2 to SVM1
32
33 hop21_0=$as:210
34 hop21_1=$as:211
35
36
37 source $(dirname $0)/generic-functions
38
39 clean_start
40
41 clean_netns_all net1vm1 svm1 svm2 net2vm2
42
43 ##
44 ## VM1: sur A
45 ##
46
47 r_a bagpipe-rest-attach --attach --port netns:to-vm1 --network-type ipvpn --vpn-instance-id net1vm1 --ip 11.0.0.1 --rt $as:1
48
49
50
51 ## SVM1: sur B
52 ##
53 ## [vrf:x1][if:to-svm1-x1]---[x1][netns:svm1][h0]---[to-svm1-h0][vrf:h01]
54 ##
55 ##
56 ## x1:100.0.0.0/24
57 ## h01:30.0.0.0/24
58 ## h02:40.0.0.0/24
59 ## x2:200.0.0.0/24
60
61 ## attach x1:
62
63 r_b bagpipe-rest-attach --attach --port netns:to-svm1-x1 --network-type ipvpn --vpn-instance-id x1 --ip 100.0.0.1/24 --netns svm1 --if2vpn x1 \
64 --import $as:1 \
65 --readv-from-rt $hop12_1 --readv-to-rt $as:1
66
67 ## attach h0:
68
69 r_b bagpipe-rest-attach --attach --port netns:to-svm1-h0 --mac 52:54:00:99:99:99 --network-type ipvpn --vpn-instance-id h01 --ip 30.0.0.1/24 --netns svm1 --if2vpn h0 \
70 --import-rt $hop12_1 \
71 --readv-from-rt $as:1 --readv-to-rt $hop21_1
72
73 r_b bagpipe-rest-attach --attach --port to-svm1-h0 --mac 52:54:00:99:99:99 --network-type ipvpn --vpn-instance-id h01 --ip 11.0.0.0/24 --advertise-subnet --export-rt $hop21_1 --import-rt $hop12_1
74
75 r_b ./setup-cross-routing svm1 x1 100.0.0.254 h0 30.0.0.254
76
77
78
79 ## SVM2: sur A
80 #
81 # [vrf:h02][to-svm2-h0]---[h0][netns:svm2][x2]---[if:to-svm2-x2][vrf:x2]
82
83 ## attach h0:
84
85 r_a bagpipe-rest-attach --attach --port netns:to-svm2-h0 --mac 52:54:00:99:99:99 --network-type ipvpn --vpn-instance-id h02 --ip 40.0.0.1/24 --netns svm2 --if2vpn h0 \
86 --import-rt $hop21_1 \
87 --readv-from-rt $as:2 --readv-to-rt $hop12_1
88
89 r_a bagpipe-rest-attach --attach --port to-svm2-h0 --mac 52:54:00:99:99:99 --network-type ipvpn --vpn-instance-id h02 --ip 12.0.0.0/24 --advertise-subnet --export-rt $hop12_1 --import-rt $hop21_1
90
91 ## attach x2:
92 r_a bagpipe-rest-attach --attach --port netns:to-svm2-x2 --network-type ipvpn --vpn-instance-id x2 --ip 200.0.0.1/24 --netns svm2 --if2vpn x2 \
93 --import $as:2 \
94 --readv-from-rt $hop21_1 --readv-to-rt $as:2
95
96 r_a ./setup-cross-routing svm2 x2 200.0.0.254 h0 40.0.0.254
97
98
99 ## VM2: sur B
100 ##
101
102 r_b bagpipe-rest-attach --attach --port netns:to-vm2 --network-type ipvpn --vpn-instance-id net2vm2 --ip 12.0.0.1 --rt $as:2
103
104 #
105 # Test
106 #
107
108 wait_ready
109
110 r_a ip netns exec net1vm1 ping 12.0.0.1 -c 3
111
112
113 r_a bagpipe-looking-glass vpns instances net1vm1 dataplane flows
114 r_b bagpipe-looking-glass vpns instances x1 dataplane flows
115 r_b bagpipe-looking-glass vpns instances h01 dataplane flows
116 r_a bagpipe-looking-glass vpns instances h02 dataplane flows
117 r_a bagpipe-looking-glass vpns instances x2 dataplane flows
118 r_b bagpipe-looking-glass vpns instances net2vm2 dataplane flows
119
120 r_both bagpipe-looking-glass logs
121
122 clean_stop
123