├── .gitignore ├── config ├── sc_fw.sh ├── dx4_r3.sh ├── B6_r3.sh ├── sc_r4.sh ├── sc_r1.sh ├── sc_r3.sh ├── dx4_r4.sh ├── dx6_r4.sh ├── dx4_r1.sh ├── B6_r4.sh ├── dx6_r1.sh ├── B6_r1.sh ├── config_a.sh ├── config_b.sh ├── config_r1.sh ├── config_app2.sh ├── config_server2.sh ├── config_r2.sh ├── config_app1.sh ├── config_server1.sh ├── config_r3.sh ├── deploy-vnf-v4.sh ├── deploy-vnf.sh └── deploy-term.sh ├── README.md ├── Vagrantfile ├── topo.py ├── topo_new.py ├── topo2.py └── topo2_new.py /.gitignore: -------------------------------------------------------------------------------- 1 | /.vagrant 2 | /.vscode 3 | /.idea 4 | -------------------------------------------------------------------------------- /config/sc_fw.sh: -------------------------------------------------------------------------------- 1 | ip -6 route add fc00:5::a/128 encap seg6local action End dev fw-eth0 2 | -------------------------------------------------------------------------------- /config/dx4_r3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Adding DX4 Rules for R3" 4 | ip -6 route add fc00:3::bb/128 encap seg6local action End dev r3-eth2 5 | 6 | 7 | -------------------------------------------------------------------------------- /config/B6_r3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Adding DX4 Rules for R3" 4 | ip -6 route add fc00:3::a1/128 encap seg6local action End.B6.Encaps srh segs fc00:1::a2 dev r3-eth1 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /config/sc_r4.sh: -------------------------------------------------------------------------------- 1 | ip -6 route add fc00:4::a/128 encap seg6local action End.DX4 nh4 10.0.2.1 dev r4-eth1 2 | 3 | ip route add 10.0.0.0/24 encap seg6 mode encap segs fc00:1::a dev r4-eth1 4 | 5 | -------------------------------------------------------------------------------- /config/sc_r1.sh: -------------------------------------------------------------------------------- 1 | ip route add 10.0.2.0/24 encap seg6 mode encap segs fc00:3::a,fc00:4::a dev r1-eth1 2 | ip -6 route add fc00:1::a/128 encap seg6local action End.DX4 nh4 10.0.0.1 dev r1-eth1 3 | 4 | -------------------------------------------------------------------------------- /config/sc_r3.sh: -------------------------------------------------------------------------------- 1 | ip -6 route add fc00:3::a/128 encap seg6local action End.B6.Encaps srh segs fc00:5::a,fc00:3::b dev r3-eth1 2 | 3 | ip -6 route add fc00:3::b/128 encap seg6local action End.DX6 nh6 :: dev r3-eth1 4 | 5 | -------------------------------------------------------------------------------- /config/dx4_r4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Adding DX4 Rules for R4" 4 | 5 | ip -6 route add fc00:4::bb/128 encap seg6local action End.DX4 nh4 10.0.2.1 dev r4-eth1 6 | ip route add 10.0.0.0/24 encap seg6 mode encap segs fc00:1::bb dev r4-eth1 -------------------------------------------------------------------------------- /config/dx6_r4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Adding DX6 Rules for R4" 4 | ip -6 route add fc00:4::bb/128 encap seg6local action End.DX6 nh6 :: dev r4-eth2 5 | ip -6 route add 2001:1a::/64 encap seg6 mode encap segs fc00:1::bb dev r4-eth2 6 | 7 | -------------------------------------------------------------------------------- /config/dx4_r1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Adding DX4 Rules for R1" 4 | ip -6 route add fc00:1::bb/128 encap seg6local action End.DX4 nh4 10.0.0.1 dev r1-eth1 5 | ip route add 10.0.2.0/24 encap seg6 mode encap segs fc00:3::bb,fc00:4::bb dev r1-eth1 6 | -------------------------------------------------------------------------------- /config/B6_r4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Adding DX4 Rules for R4" 4 | ip -6 route add fc00:4::a1/128 encap seg6local action End.DX4 nh4 10.0.2.1 dev r4-eth1 5 | ip route add 10.0.0.0/24 encap seg6 mode encap segs fc00:1::a1 dev r4-eth1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /config/dx6_r1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Adding DX6 Rules for R1" 4 | ip -6 route add fc00:1::bb/128 encap seg6local action End.DX6 nh6 :: dev r1-eth2 5 | ip -6 route add 2001:4b::/64 encap seg6 mode encap segs fc00:3::bb,fc00:4::bb dev r1-eth2 6 | 7 | -------------------------------------------------------------------------------- /config/B6_r1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Adding DX4 Rules for R1" 4 | ip -6 route add fc00:1::a1/128 encap seg6local action End.DX4 nh4 10.0.0.1 dev r1-eth1 5 | ip route add 10.0.2.0/24 encap seg6 mode encap segs fc00:3::a1,fc00:4::a1 dev r1-eth1 6 | ip -6 route add fc00:1::a2/128 encap seg6local action End.DX6 nh6 :: dev r1-eth1 7 | 8 | 9 | -------------------------------------------------------------------------------- /config/config_a.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Configure Interfaces 4 | ifconfig eth1 up 5 | ip addr add 10.0.0.1/24 dev eth1 6 | 7 | 8 | 9 | 10 | 11 | # Configure Routing 12 | ip route add 10.0.1.0/24 via 10.0.0.2 13 | 14 | 15 | # Accept SRv6 traffic 16 | # sysctl -w net.ipv6.conf.all.seg6_enabled=1 17 | # sysctl -w net.ipv6.conf.lo.seg6_enabled=1 18 | # sysctl -w net.ipv6.conf.eth1.seg6_enabled=1 19 | # sysctl -w net.ipv6.conf.eth2.seg6_enabled=1 20 | 21 | # Enable forwarding 22 | sysctl -w net.ipv6.conf.all.forwarding=1 23 | 24 | 25 | 26 | # # Configure Branches (BR1 and BR2) 27 | # cd ~/ 28 | # rm -rf sr-sfc-demo 29 | # git clone https://github.com/SRouting/sr-sfc-demo 30 | # cd sr-sfc-demo/config/ 31 | # sh deploy-term.sh add br1 veth1 inet6 fc00:b1::1/64 fc00:b1::2/64 32 | # sh deploy-term.sh add br2 veth2 inet6 fc00:b2::1/64 fc00:b2::2/64 33 | 34 | # # Configure Policy Based Routing (PBR) 35 | # echo "201 br1" >> /etc/iproute2/rt_tables 36 | # ip -6 rule add from fc00:b1::/64 lookup br1 37 | 38 | # echo "202 br2" >> /etc/iproute2/rt_tables 39 | # ip -6 rule add from fc00:b2::/64 lookup br2 40 | 41 | # # Configure SR SFC policies 42 | # ip -6 route add fc00:e::/64 encap seg6 mode encap segs fc00:2::f1:0,fc00:3::f2:AD60,fc00:6::D6 dev eth1 table br1 43 | # ip -6 route add fc00:e::/64 encap seg6 mode encap segs fc00:5::f3:0,fc00:6::D6 dev eth2 table br2 44 | 45 | # # Configure Routing 46 | # ip -6 route add fc00:2::/64 via fc00:12::2 47 | # ip -6 route add fc00:5::/64 via fc00:14::4 48 | 49 | # # Configure SRv6 End.D6 behaviour for traffic going to BR1 and BR2 50 | # ip -6 route add local fc00:1::d6/128 dev lo 51 | -------------------------------------------------------------------------------- /config/config_b.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Configure Interfaces 4 | ifconfig eth1 up 5 | ip addr add 10.0.1.1/24 dev eth1 6 | 7 | 8 | # Enable forwarding 9 | # sysctl -w net.ipv6.conf.all.forwarding=1 10 | 11 | # Accept SRv6 traffic 12 | # sysctl -w net.ipv6.conf.all.seg6_enabled=1 13 | # sysctl -w net.ipv6.conf.lo.seg6_enabled=1 14 | # sysctl -w net.ipv6.conf.eth1.seg6_enabled=1 15 | # sysctl -w net.ipv6.conf.eth2.seg6_enabled=1 16 | 17 | # Configure Routing 18 | ip route add 10.0.0.0/24 via 10.0.1.2 19 | 20 | # Enable forwarding 21 | sysctl -w net.ipv6.conf.all.forwarding=1 22 | 23 | 24 | # # Configure Branches (BR1 and BR2) 25 | # cd ~/ 26 | # rm -rf sr-sfc-demo 27 | # git clone https://github.com/SRouting/sr-sfc-demo 28 | # cd sr-sfc-demo/config/ 29 | # sh deploy-term.sh add br1 veth1 inet6 fc00:b1::1/64 fc00:b1::2/64 30 | # sh deploy-term.sh add br2 veth2 inet6 fc00:b2::1/64 fc00:b2::2/64 31 | 32 | # # Configure Policy Based Routing (PBR) 33 | # echo "201 br1" >> /etc/iproute2/rt_tables 34 | # ip -6 rule add from fc00:b1::/64 lookup br1 35 | 36 | # echo "202 br2" >> /etc/iproute2/rt_tables 37 | # ip -6 rule add from fc00:b2::/64 lookup br2 38 | 39 | # # Configure SR SFC policies 40 | # ip -6 route add fc00:e::/64 encap seg6 mode encap segs fc00:2::f1:0,fc00:3::f2:AD60,fc00:6::D6 dev eth1 table br1 41 | # ip -6 route add fc00:e::/64 encap seg6 mode encap segs fc00:5::f3:0,fc00:6::D6 dev eth2 table br2 42 | 43 | # # Configure Routing 44 | # ip -6 route add fc00:2::/64 via fc00:12::2 45 | # ip -6 route add fc00:5::/64 via fc00:14::4 46 | 47 | # # Configure SRv6 End.D6 behaviour for traffic going to BR1 and BR2 48 | # ip -6 route add local fc00:1::d6/128 dev lo 49 | -------------------------------------------------------------------------------- /config/config_r1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Configure Interfaces 4 | ifconfig eth1 up 5 | ip addr add 10.0.0.2/24 dev eth1 6 | 7 | ifconfig eth2 up 8 | ip -6 addr add 2001:12::1/64 dev eth2 9 | 10 | ifconfig lo up 11 | ip -6 addr add fc00:1::1/64 dev lo 12 | 13 | # Enable forwarding 14 | sysctl -w net.ipv4.ip_forward=1 15 | sysctl -w net.ipv6.conf.all.forwarding=1 16 | 17 | # Accept SRv6 traffic 18 | sysctl -w net.ipv6.conf.all.seg6_enabled=1 19 | sysctl -w net.ipv6.conf.lo.seg6_enabled=1 20 | sysctl -w net.ipv6.conf.eth1.seg6_enabled=1 21 | sysctl -w net.ipv6.conf.eth2.seg6_enabled=1 22 | 23 | # Configure Routing 24 | ip -6 route del default 25 | ip -6 route add default via 2001:12::2 26 | 27 | 28 | # Enable forwarding 29 | sysctl -w net.ipv6.conf.all.forwarding=1 30 | 31 | # # Configure SR policies 32 | ip -6 route add fc00:1::a/128 encap seg6local action End.DX4 nh4 10.0.0.1 dev eth1 33 | ip route add 10.0.1.0/24 encap seg6 mode encap segs fc00:2::a,fc00:3::a dev eth2 34 | # ip -6 route add fc00:e::/64 encap seg6 mode encap segs fc00:5::f3:0,fc00:6::D6 dev eth2 table br2 35 | 36 | 37 | 38 | # # Configure Branches (BR1 and BR2) 39 | # cd ~/ 40 | # rm -rf sr-sfc-demo 41 | # git clone https://github.com/SRouting/sr-sfc-demo 42 | # cd sr-sfc-demo/config/ 43 | # sh deploy-term.sh add br1 veth1 inet6 fc00:b1::1/64 fc00:b1::2/64 44 | # sh deploy-term.sh add br2 veth2 inet6 fc00:b2::1/64 fc00:b2::2/64 45 | 46 | # # Configure Policy Based Routing (PBR) 47 | # echo "201 br1" >> /etc/iproute2/rt_tables 48 | # ip -6 rule add from fc00:b1::/64 lookup br1 49 | 50 | # echo "202 br2" >> /etc/iproute2/rt_tables 51 | # ip -6 rule add from fc00:b2::/64 lookup br2 52 | 53 | # # Configure SR SFC policies 54 | # ip -6 route add fc00:e::/64 encap seg6 mode encap segs fc00:2::f1:0,fc00:3::f2:AD60,fc00:6::D6 dev eth1 table br1 55 | # ip -6 route add fc00:e::/64 encap seg6 mode encap segs fc00:5::f3:0,fc00:6::D6 dev eth2 table br2 56 | 57 | # # Configure SRv6 End.D6 behaviour for traffic going to BR1 and BR2 58 | # ip -6 route add local fc00:1::d6/128 dev lo 59 | -------------------------------------------------------------------------------- /config/config_app2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Configure Interfaces 4 | ifconfig eth1 up 5 | ip -6 addr add 2001:b::2/64 dev eth1 6 | 7 | ifconfig lo up 8 | ip -6 addr add fc00:b::b/64 dev lo 9 | 10 | # Enable forwarding 11 | sysctl -w net.ipv4.ip_forward=1 12 | 13 | sysctl -w net.ipv6.conf.all.forwarding=1 14 | 15 | # Accept SRv6 traffic 16 | sysctl -w net.ipv6.conf.all.seg6_enabled=1 17 | sysctl -w net.ipv6.conf.lo.seg6_enabled=1 18 | sysctl -w net.ipv6.conf.eth1.seg6_enabled=1 19 | 20 | 21 | # Enable SR Aware IPtables 22 | sysctl -w net.ipv6.ip6t_seg6=1 23 | 24 | # Configure Routing 25 | ip -6 route del default 26 | ip -6 route add default via 2001:b::1 27 | 28 | # Enable forwarding 29 | sysctl -w net.ipv6.conf.all.forwarding=1 30 | 31 | 32 | # Configure SRv6 Policy 33 | ip -6 route add fc00:b::a1/128 encap seg6local action End dev eth1 34 | 35 | 36 | # Configure snort rules 37 | sudo mkdir -p /etc/snort/ /etc/snort/rules/ /var/log/snort 38 | touch /etc/snort/snort.conf /etc/snort/rules/local.rule 39 | echo 'var RULE_PATH rules' >> /etc/snort/snort.conf 40 | echo 'include $RULE_PATH/local.rule' >> /etc/snort/snort.conf 41 | echo 'alert icmp any any -> any any (msg:"ICMP detected"; sid:1000)' >> /etc/snort/rules/local.rule 42 | 43 | 44 | 45 | # # Configure Branches (BR1 and BR2) 46 | # cd ~/ 47 | # rm -rf sr-sfc-demo 48 | # git clone https://github.com/SRouting/sr-sfc-demo 49 | # cd sr-sfc-demo/config/ 50 | # sh deploy-term.sh add br1 veth1 inet6 fc00:b1::1/64 fc00:b1::2/64 51 | # sh deploy-term.sh add br2 veth2 inet6 fc00:b2::1/64 fc00:b2::2/64 52 | 53 | # # Configure Policy Based Routing (PBR) 54 | # echo "201 br1" >> /etc/iproute2/rt_tables 55 | # ip -6 rule add from fc00:b1::/64 lookup br1 56 | 57 | # echo "202 br2" >> /etc/iproute2/rt_tables 58 | # ip -6 rule add from fc00:b2::/64 lookup br2 59 | 60 | # # Configure SR SFC policies 61 | # ip -6 route add fc00:e::/64 encap seg6 mode encap segs fc00:2::f1:0,fc00:3::f2:AD60,fc00:6::D6 dev eth1 table br1 62 | # ip -6 route add fc00:e::/64 encap seg6 mode encap segs fc00:5::f3:0,fc00:6::D6 dev eth2 table br2 63 | 64 | # # Configure Routing 65 | # ip -6 route add fc00:2::/64 via fc00:12::2 66 | # ip -6 route add fc00:5::/64 via fc00:14::4 67 | 68 | # # Configure SRv6 End.D6 behaviour for traffic going to BR1 and BR2 69 | # ip -6 route add local fc00:1::d6/128 dev lo 70 | -------------------------------------------------------------------------------- /config/config_server2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Configure Interfaces 4 | ifconfig eth1 up 5 | ip -6 addr add 2001:b::2/64 dev eth1 6 | 7 | ifconfig lo up 8 | ip -6 addr add fc00:b::b/64 dev lo 9 | 10 | # Enable forwarding 11 | sysctl -w net.ipv4.ip_forward=1 12 | 13 | sysctl -w net.ipv6.conf.all.forwarding=1 14 | 15 | # Accept SRv6 traffic 16 | sysctl -w net.ipv6.conf.all.seg6_enabled=1 17 | sysctl -w net.ipv6.conf.lo.seg6_enabled=1 18 | sysctl -w net.ipv6.conf.eth1.seg6_enabled=1 19 | 20 | 21 | # Enable SR Aware IPtables 22 | sysctl -w net.ipv6.ip6t_seg6=1 23 | 24 | # Configure Routing 25 | ip -6 route del default 26 | ip -6 route add default via 2001:b::1 27 | 28 | # Enable forwarding 29 | sysctl -w net.ipv6.conf.all.forwarding=1 30 | 31 | 32 | # Configure SRv6 Policy 33 | ip -6 route add fc00:b::a1/128 encap seg6local action End dev eth1 34 | 35 | 36 | # Configure snort rules 37 | sudo mkdir -p /etc/snort/ /etc/snort/rules/ /var/log/snort 38 | touch /etc/snort/snort.conf /etc/snort/rules/local.rule 39 | echo 'var RULE_PATH rules' >> /etc/snort/snort.conf 40 | echo 'include $RULE_PATH/local.rule' >> /etc/snort/snort.conf 41 | echo 'alert icmp any any -> any any (msg:"ICMP detected"; sid:1000)' >> /etc/snort/rules/local.rule 42 | 43 | 44 | 45 | # # Configure Branches (BR1 and BR2) 46 | # cd ~/ 47 | # rm -rf sr-sfc-demo 48 | # git clone https://github.com/SRouting/sr-sfc-demo 49 | # cd sr-sfc-demo/config/ 50 | # sh deploy-term.sh add br1 veth1 inet6 fc00:b1::1/64 fc00:b1::2/64 51 | # sh deploy-term.sh add br2 veth2 inet6 fc00:b2::1/64 fc00:b2::2/64 52 | 53 | # # Configure Policy Based Routing (PBR) 54 | # echo "201 br1" >> /etc/iproute2/rt_tables 55 | # ip -6 rule add from fc00:b1::/64 lookup br1 56 | 57 | # echo "202 br2" >> /etc/iproute2/rt_tables 58 | # ip -6 rule add from fc00:b2::/64 lookup br2 59 | 60 | # # Configure SR SFC policies 61 | # ip -6 route add fc00:e::/64 encap seg6 mode encap segs fc00:2::f1:0,fc00:3::f2:AD60,fc00:6::D6 dev eth1 table br1 62 | # ip -6 route add fc00:e::/64 encap seg6 mode encap segs fc00:5::f3:0,fc00:6::D6 dev eth2 table br2 63 | 64 | # # Configure Routing 65 | # ip -6 route add fc00:2::/64 via fc00:12::2 66 | # ip -6 route add fc00:5::/64 via fc00:14::4 67 | 68 | # # Configure SRv6 End.D6 behaviour for traffic going to BR1 and BR2 69 | # ip -6 route add local fc00:1::d6/128 dev lo 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SRv6 Sandbox 2 | 3 | This project is a SRv6 Sandbox base on Mininet. 4 | 5 | ### Requirements 6 | 7 | - Linux Kernel higher than 4.15 8 | 9 | - Latest Mininet Installed 10 | 11 | - Quagga Installed 12 | 13 | - Python Installed 14 | 15 | ### Install Guide 16 | 17 | The install guide is base on Ubuntu 18.04 LTS version 18 | 19 | 1. Upgrade Kernel to the recommended version 20 | 21 | ```bash 22 | apt-get install linux-headers-4.15.0-38 linux-headers-4.15.0-38-generic linux-image-4.15.0-38-generic linux-modules-4.15.0-38-generic linux-modules-extra-4.15.0-38-generic 23 | ``` 24 | 2. Reboot and check if the kernel is upgraded 25 | ```bash 26 | uname -a 27 | Linux ubuntu 4.15.0-38-generic #41-Ubuntu SMP Wed Oct 10 10:59:38 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux 28 | 29 | ``` 30 | 3. Install Mininet and Quagga 31 | ```bash 32 | apt-get install mininet gawk libreadline-dev libc-ares-dev 33 | wget https://github.com/Quagga/quagga/releases/download/quagga-1.2.4/quagga-1.2.4.tar.gz 34 | tar -xzvf ./quagga-1.2.4.tar.gz 35 | cd ./quagga-1.2.4 36 | ./configure --enable-vtysh --enable-user=root --enable-group=root --enable-vty-group=root 37 | make install 38 | ``` 39 | 4. Install iproute2 40 | ```bash 41 | wget https://mirrors.edge.kernel.org/pub/linux/utils/net/iproute2/iproute2-4.9.0.tar.gz 42 | tar -xzvf ./iproute2-4.9.0.tar.gz 43 | cd ./iproute2-4.9.0 44 | apt-get install bison flex 45 | make 46 | make install 47 | ``` 48 | 5. Install python dependencies 49 | ```bash 50 | pip install mako ipaddress ipmininet --no-deps 51 | ``` 52 | 6. Run Environment 53 | ```bash 54 | sudo python topo.py 55 | ``` 56 | 57 | ### Usage Guide 58 | 59 | In file topo.py: 60 | 61 | You can define topology by adding Host/Router and adding Links. 62 | 63 | Use build_dx4_tunnel to build a DX4 Tunnel 64 | Use build_dx6_tunnel to build a DX6 Tunnel 65 | Use RouterConfiguration to Initialize a Router to SRv6 Router. 66 | 67 | #### For manual configuration 68 | 69 | For manual configuration, run dx4_r1.sh on R1 and dx4_r3 on R3 70 | 71 | ### Mininet Simple tutorial 72 | 73 | After running sudo python topo.py, you will be promoted to a Mininet shell. 74 | 75 | Run "xterm " to go to the destinated host shell 76 | 77 | For example, xterm R1 will give you access to R1 shell. 78 | 79 | -------------------------------------------------------------------------------- /config/config_r2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Configure Interfaces 4 | ifconfig eth1 up 5 | ip -6 addr add 2001:12::2/64 dev eth1 6 | 7 | ifconfig eth2 up 8 | ip -6 addr add 2001:23::1/64 dev eth2 9 | 10 | ifconfig eth3 up 11 | ip -6 addr add 2001:a::1/64 dev eth3 12 | 13 | ifconfig lo up 14 | ip -6 addr add fc00:2::2/64 dev lo 15 | 16 | 17 | # Enable forwarding 18 | sysctl -w net.ipv4.ip_forward=1 19 | 20 | sysctl -w net.ipv6.conf.all.forwarding=1 21 | 22 | # Accept SRv6 traffic 23 | sysctl -w net.ipv6.conf.all.seg6_enabled=1 24 | sysctl -w net.ipv6.conf.lo.seg6_enabled=1 25 | sysctl -w net.ipv6.conf.eth1.seg6_enabled=1 26 | sysctl -w net.ipv6.conf.eth2.seg6_enabled=1 27 | sysctl -w net.ipv6.conf.eth3.seg6_enabled=1 28 | 29 | 30 | # Configure Routing 31 | ip -6 route add fc00:1::/64 via 2001:12::1 32 | ip -6 route add fc00:3::/64 via 2001:23::2 33 | ip -6 route add fc00:a::/64 via 2001:a::2 34 | ip -6 route add fc00:b::/64 via 2001:23::2 35 | 36 | # Enable forwarding 37 | sysctl -w net.ipv6.conf.all.forwarding=1 38 | 39 | 40 | 41 | # # Install SREXT 42 | 43 | 44 | # cd ~/ 45 | # git clone https://github.com/SRouting/SRv6-net-prog 46 | # cd SRv6-net-prog/srext/ 47 | # make && make install && depmod -a && modprobe srext 48 | # srconf localsid add fc00:3::f2:AD60 end.ad6 ip fd00:3:0::f2:2 veth0 veth1 49 | # srconf localsid add fc00:3::f2:AD61 end.ad6 ip fd00:3:1::f2:2 veth1 veth0 50 | 51 | 52 | 53 | 54 | # # Configure SR policies 55 | ip -6 route add fc00:2::a/128 encap seg6local action End dev eth1 56 | 57 | 58 | 59 | 60 | # Configure VNFs 61 | # cd ~/ 62 | # rm -rf sr-sfc-demo 63 | # git clone https://github.com/SRouting/sr-sfc-demo 64 | # cd sr-sfc-demo/config/ 65 | # sh deploy-vnf.sh add f1 veth0 veth1 fd00:2:0::f1:1/64 fd00:2:1::f1:1/64 fd00:2:0::f1:2/64 fd00:2:1::f1:2/64 66 | # ip netns exec f1 sysctl -w net.ipv6.conf.all.seg6_enabled=1 67 | # ip netns exec f1 sysctl -w net.ipv6.conf.lo.seg6_enabled=1 68 | # ip netns exec f1 sysctl -w net.ipv6.conf.veth0-f1.seg6_enabled=1 69 | # ip netns exec f1 sysctl -w net.ipv6.conf.veth1-f1.seg6_enabled=1 70 | # ip netns exec f1 sysctl -w net.ipv6.ip6t_seg6=1 71 | # ip netns exec f1 ifconfig lo up 72 | # ip netns exec f1 ip -6 route add local fc00:2::f1:0/112 dev lo 73 | 74 | # # Configure Routing 75 | # ip -6 route add fc00:3::/64 via fc00:23::3 76 | # ip -6 route add fc00:1::/64 via fc00:12::1 77 | # ip -6 route add fc00:2::f1:0/112 via fd00:2:0::f1:2 78 | 79 | -------------------------------------------------------------------------------- /config/config_app1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Configure Interfaces 4 | ifconfig eth1 up 5 | ip -6 addr add 2001:a::2/64 dev eth1 6 | 7 | ifconfig lo up 8 | ip -6 addr add fc00:a::a/64 dev lo 9 | 10 | # Enable forwarding 11 | sysctl -w net.ipv6.conf.all.forwarding=1 12 | 13 | # Accept SRv6 traffic 14 | sysctl -w net.ipv6.conf.all.seg6_enabled=1 15 | sysctl -w net.ipv6.conf.lo.seg6_enabled=1 16 | sysctl -w net.ipv6.conf.eth1.seg6_enabled=1 17 | 18 | 19 | # Configure Routing 20 | ip -6 route del default 21 | ip -6 route add default via 2001:a::1 22 | 23 | 24 | # Enable forwarding 25 | sysctl -w net.ipv4.ip_forward=1 26 | sysctl -w net.ipv6.conf.all.forwarding=1 27 | 28 | 29 | 30 | # Configure VNFs 31 | cd ~/ 32 | rm -rf srv6_Sandbox/ 33 | git clone https://github.com/ljm625/srv6_Sandbox 34 | cd srv6_Sandbox/config/ 35 | sh deploy-vnf-v4.sh add snort veth0 veth1 192.168.1.1/24 192.168.2.1/24 192.168.1.2/24 192.168.2.2/24 36 | 37 | # Install Snort 38 | cd ~/ 39 | wget https://snort.org/downloads/snort/daq-2.0.6.tar.gz 40 | wget https://snort.org/downloads/snort/snort-2.9.12.tar.gz 41 | 42 | tar xvzf daq-2.0.6.tar.gz 43 | cd daq-2.0.6 44 | ./configure && make && sudo make install 45 | 46 | cd ~/ 47 | tar xvzf snort-2.9.12.tar.gz 48 | cd snort-2.9.12 49 | ./configure --enable-sourcefire --disable-open-appid && make && sudo make install 50 | 51 | # Update shared libraries (mandatory according to Snort documentation) 52 | sudo ldconfig 53 | 54 | 55 | # Install and configure srext (SR proxy) 56 | cd ~/ 57 | git clone https://github.com/SRouting/SRv6-net-prog 58 | cd SRv6-net-prog/srext/ 59 | make && make install && depmod -a && modprobe srext 60 | 61 | 62 | 63 | 64 | # Configure SRv6 Policies 65 | srconf localsid add fc00:a::a1 end.ad4 ip 192.168.1.2 veth0 veth1 66 | 67 | 68 | 69 | 70 | # configure snort rules 71 | sudo mkdir -p /etc/snort/ /etc/snort/rules/ /var/log/snort 72 | 73 | touch /etc/snort/snort.conf /etc/snort/rules/local.rule 74 | echo 'var RULE_PATH rules' >> /etc/snort/snort.conf 75 | echo 'include $RULE_PATH/local.rule' >> /etc/snort/snort.conf 76 | echo 'alert icmp any any -> any any (msg:"ICMP detected"; sid:1000)' >> /etc/snort/rules/local.rule 77 | 78 | 79 | 80 | # # Configure Branches (BR1 and BR2) 81 | # cd ~/ 82 | # rm -rf sr-sfc-demo 83 | # git clone https://github.com/SRouting/sr-sfc-demo 84 | # cd sr-sfc-demo/config/ 85 | # sh deploy-term.sh add br1 veth1 inet6 fc00:b1::1/64 fc00:b1::2/64 86 | # sh deploy-term.sh add br2 veth2 inet6 fc00:b2::1/64 fc00:b2::2/64 87 | 88 | # # Configure Policy Based Routing (PBR) 89 | # echo "201 br1" >> /etc/iproute2/rt_tables 90 | # ip -6 rule add from fc00:b1::/64 lookup br1 91 | 92 | # echo "202 br2" >> /etc/iproute2/rt_tables 93 | # ip -6 rule add from fc00:b2::/64 lookup br2 94 | 95 | # # Configure SR SFC policies 96 | # ip -6 route add fc00:e::/64 encap seg6 mode encap segs fc00:2::f1:0,fc00:3::f2:AD60,fc00:6::D6 dev eth1 table br1 97 | # ip -6 route add fc00:e::/64 encap seg6 mode encap segs fc00:5::f3:0,fc00:6::D6 dev eth2 table br2 98 | 99 | # # Configure Routing 100 | # ip -6 route add fc00:2::/64 via fc00:12::2 101 | # ip -6 route add fc00:5::/64 via fc00:14::4 102 | 103 | # # Configure SRv6 End.D6 behaviour for traffic going to BR1 and BR2 104 | # ip -6 route add local fc00:1::d6/128 dev lo 105 | -------------------------------------------------------------------------------- /config/config_server1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Configure Interfaces 4 | ifconfig eth1 up 5 | ip -6 addr add 2001:a::2/64 dev eth1 6 | 7 | ifconfig lo up 8 | ip -6 addr add fc00:a::a/64 dev lo 9 | 10 | # Enable forwarding 11 | sysctl -w net.ipv6.conf.all.forwarding=1 12 | 13 | # Accept SRv6 traffic 14 | sysctl -w net.ipv6.conf.all.seg6_enabled=1 15 | sysctl -w net.ipv6.conf.lo.seg6_enabled=1 16 | sysctl -w net.ipv6.conf.eth1.seg6_enabled=1 17 | 18 | 19 | # Configure Routing 20 | ip -6 route del default 21 | ip -6 route add default via 2001:a::1 22 | 23 | 24 | # Enable forwarding 25 | sysctl -w net.ipv4.ip_forward=1 26 | sysctl -w net.ipv6.conf.all.forwarding=1 27 | 28 | 29 | 30 | # Configure VNFs 31 | cd ~/ 32 | rm -rf srv6_Sandbox/ 33 | git clone https://github.com/ljm625/srv6_Sandbox.git 34 | cd srv6_Sandbox/config/ 35 | sh deploy-vnf-v4.sh add snort veth0 veth1 192.168.1.1/24 192.168.2.1/24 192.168.1.2/24 192.168.2.2/24 36 | 37 | # Install Snort 38 | cd ~/ 39 | wget https://snort.org/downloads/snort/daq-2.0.7.tar.gz 40 | wget https://snort.org/downloads/snort/snort-2.9.18.1.tar.gz 41 | 42 | tar xvzf daq-2.0.7.tar.gz 43 | cd daq-2.0.7 44 | ./configure && make && sudo make install 45 | 46 | cd ~/ 47 | tar xvzf snort-2.9.18.1.tar.gz 48 | cd snort-2.9.18.1 49 | ./configure --enable-sourcefire --disable-open-appid && make && sudo make install 50 | 51 | # Update shared libraries (mandatory according to Snort documentation) 52 | sudo ldconfig 53 | 54 | 55 | # Install and configure srext (SR proxy) 56 | cd ~/ 57 | git clone https://github.com/SRouting/SRv6-net-prog.git 58 | cd SRv6-net-prog/srext/ 59 | make && make install && depmod -a && modprobe srext 60 | 61 | 62 | 63 | 64 | # Configure SRv6 Policies 65 | srconf localsid add fc00:a::a1 end.ad4 ip 192.168.1.2 veth0 veth1 66 | 67 | 68 | 69 | 70 | # configure snort rules 71 | sudo mkdir -p /etc/snort/ /etc/snort/rules/ /var/log/snort 72 | 73 | touch /etc/snort/snort.conf /etc/snort/rules/local.rule 74 | echo 'var RULE_PATH rules' >> /etc/snort/snort.conf 75 | echo 'include $RULE_PATH/local.rule' >> /etc/snort/snort.conf 76 | echo 'alert icmp any any -> any any (msg:"ICMP detected"; sid:1000)' >> /etc/snort/rules/local.rule 77 | 78 | 79 | 80 | # # Configure Branches (BR1 and BR2) 81 | # cd ~/ 82 | # rm -rf sr-sfc-demo 83 | # git clone https://github.com/SRouting/sr-sfc-demo 84 | # cd sr-sfc-demo/config/ 85 | # sh deploy-term.sh add br1 veth1 inet6 fc00:b1::1/64 fc00:b1::2/64 86 | # sh deploy-term.sh add br2 veth2 inet6 fc00:b2::1/64 fc00:b2::2/64 87 | 88 | # # Configure Policy Based Routing (PBR) 89 | # echo "201 br1" >> /etc/iproute2/rt_tables 90 | # ip -6 rule add from fc00:b1::/64 lookup br1 91 | 92 | # echo "202 br2" >> /etc/iproute2/rt_tables 93 | # ip -6 rule add from fc00:b2::/64 lookup br2 94 | 95 | # # Configure SR SFC policies 96 | # ip -6 route add fc00:e::/64 encap seg6 mode encap segs fc00:2::f1:0,fc00:3::f2:AD60,fc00:6::D6 dev eth1 table br1 97 | # ip -6 route add fc00:e::/64 encap seg6 mode encap segs fc00:5::f3:0,fc00:6::D6 dev eth2 table br2 98 | 99 | # # Configure Routing 100 | # ip -6 route add fc00:2::/64 via fc00:12::2 101 | # ip -6 route add fc00:5::/64 via fc00:14::4 102 | 103 | # # Configure SRv6 End.D6 behaviour for traffic going to BR1 and BR2 104 | # ip -6 route add local fc00:1::d6/128 dev lo 105 | -------------------------------------------------------------------------------- /config/config_r3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | # Configure Interfaces 5 | ifconfig eth1 up 6 | ip addr add 10.0.1.2/24 dev eth1 7 | 8 | ifconfig eth2 up 9 | ip -6 addr add 2001:23::2/64 dev eth2 10 | 11 | ifconfig eth3 up 12 | ip -6 addr add 2001:b::1/64 dev eth3 13 | 14 | ifconfig lo up 15 | ip -6 addr add fc00:3::3/64 dev lo 16 | 17 | 18 | # Enable forwarding 19 | sysctl -w net.ipv4.ip_forward=1 20 | sysctl -w net.ipv6.conf.all.forwarding=1 21 | 22 | # Accept SRv6 traffic 23 | sysctl -w net.ipv6.conf.all.seg6_enabled=1 24 | sysctl -w net.ipv6.conf.lo.seg6_enabled=1 25 | sysctl -w net.ipv6.conf.eth1.seg6_enabled=1 26 | sysctl -w net.ipv6.conf.eth2.seg6_enabled=1 27 | sysctl -w net.ipv6.conf.eth3.seg6_enabled=1 28 | 29 | 30 | # Configure Routing 31 | ip -6 route del default 32 | 33 | ip -6 route add default via 2001:23::1 34 | ip -6 route add fc00:b::/64 via 2001:b::2 35 | 36 | 37 | # Enable forwarding 38 | sysctl -w net.ipv4.ip_forward=1 39 | sysctl -w net.ipv6.conf.all.forwarding=1 40 | 41 | 42 | # # Configure SR policies 43 | ip -6 route add fc00:3::a/128 encap seg6local action End.DX4 nh4 10.0.1.1 dev eth1 44 | ip route add 10.0.0.0/24 encap seg6 mode encap segs fc00:1::a dev eth2 45 | 46 | 47 | # # Install required softwares 48 | # export DEBIAN_FRONTEND=noninteractive 49 | # apt-get -y update 50 | # apt-get -y upgrade 51 | # apt-get -y install build-essential libpcap-dev git wget libdumbnet-dev zlib1g-dev liblzma-dev openssl libssl-dev libnghttp2-dev libpcre3 \ 52 | # libpcre3-dev flex bison libdnet-dev libghc-zlib-dev dh-autoreconf libnet-dev gcc automake autoconf make libyaml-dev g++ binutils autotools-dev libtool pkg-config \ 53 | # libcunit1-dev libxml2-dev libev-dev libjansson-dev libc-ares-dev libjemalloc-dev libsystemd-dev cython python3-dev python-setuptools 54 | 55 | # # Install nghttp2 56 | # cd ~/ 57 | # git clone https://github.com/nghttp2/nghttp2 58 | # cd nghttp2/ 59 | # git submodule update --init && autoreconf -i && automake && autoconf && ./configure && make && make install 60 | 61 | # # Install SR-tcpdump 62 | # cd ~/ 63 | # git clone https://github.com/srouting/sr-tcpdump 64 | # cd sr-tcpdump 65 | # ./configure && make && make install 66 | 67 | # # Configure Interfaces 68 | # ifconfig eth1 up 69 | # ip -6 addr add fc00:23::3/64 dev eth1 70 | 71 | # ifconfig eth2 up 72 | # ip -6 addr add fc00:36::3/64 dev eth2 73 | 74 | # # Enable forwarding 75 | # sysctl -w net.ipv6.conf.all.forwarding=1 76 | 77 | # # Accept SRv6 traffic 78 | # sysctl -w net.ipv6.conf.all.seg6_enabled=1 79 | # sysctl -w net.ipv6.conf.lo.seg6_enabled=1 80 | # sysctl -w net.ipv6.conf.eth1.seg6_enabled=1 81 | # sysctl -w net.ipv6.conf.eth2.seg6_enabled=1 82 | 83 | # # Configure VNFs 84 | # cd ~/ 85 | # rm -rf sr-sfc-demo/ 86 | # git clone https://github.com/SRouting/sr-sfc-demo 87 | # cd sr-sfc-demo/config/ 88 | # sh deploy-vnf.sh add f2 veth0 veth1 fd00:3:0::f2:1/64 fd00:3:1::f2:1/64 fd00:3:0::f2:2/64 fd00:3:1::f2:2/64 89 | 90 | # # Install and configure srext (SR proxy) 91 | # cd ~/ 92 | # git clone https://github.com/SRouting/SRv6-net-prog 93 | # cd SRv6-net-prog/srext/ 94 | # make && make install && depmod -a && modprobe srext 95 | # srconf localsid add fc00:3::f2:AD60 end.ad6 ip fd00:3:0::f2:2 veth0 veth1 96 | # srconf localsid add fc00:3::f2:AD61 end.ad6 ip fd00:3:1::f2:2 veth1 veth0 97 | 98 | # # Configure Routing 99 | # ip -6 route add fc00:6::/64 via fc00:36::6 100 | # ip -6 route add fc00:2::/64 via fc00:23::2 101 | 102 | # # Install Snort 103 | # cd ~/ 104 | # wget https://snort.org/downloads/snort/daq-2.0.6.tar.gz 105 | # wget https://snort.org/downloads/snort/snort-2.9.11.1.tar.gz 106 | 107 | # tar xvzf daq-2.0.6.tar.gz 108 | # cd daq-2.0.6 109 | # ./configure && make && sudo make install 110 | 111 | # cd ~/ 112 | # tar xvzf snort-2.9.11.1.tar.gz 113 | # cd snort-2.9.11.1 114 | # ./configure --enable-sourcefire && make && sudo make install 115 | 116 | # # Update shared libraries (mandatory according to Snort documentation) 117 | # sudo ldconfig 118 | 119 | # # configure snort rules 120 | # sudo mkdir -p /etc/snort/ /etc/snort/rules/ /var/log/snort 121 | 122 | # touch /etc/snort/snort.conf /etc/snort/rules/local.rule 123 | # echo 'var RULE_PATH rules' >> /etc/snort/snort.conf 124 | # echo 'include $RULE_PATH/local.rule' >> /etc/snort/snort.conf 125 | # echo 'alert icmp any any -> any any (msg:"ICMP detected"; sid:1000)' >> /etc/snort/rules/local.rule 126 | -------------------------------------------------------------------------------- /config/deploy-vnf-v4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | usage () { 4 | echo "" 5 | echo "+-----------------------------------------------------------------------+" 6 | echo "+---------------------+ VNF deploy script +-----------------------------+" 7 | echo "+-----------------------------------------------------------------------+" 8 | echo "+-- This script Adds/cleans network namespace (VNF) --+" 9 | echo "+-- Usage: --+" 10 | echo "+-- $ ./deploy-vnf.sh help --+" 11 | echo "+-- $ ./deploy-vnf.sh add VNF_NAME NFV_IFACE1 NFV_IFACE2 NFV_IFACE1\ --+" 12 | echo "+-- NFV_IFACE1_IP NFV_IFACE2_IP VNF_IFACE1_IP VNF_IFACE2_IP --+" 13 | echo "+-- $ ./deploy-vnf.sh del VNF_NAME NFV_IFACE1 NFV_IFACE2 --+" 14 | echo "+-- N.B: --+" 15 | echo "+-- IP Addresses should be in the form ADDR/MASK 'A::2/64' --+" 16 | echo "+-- Clean the VNF before re-trying to add (in case of error) --+" 17 | echo "+-- $./deploy-vnf.sh del VNF_NAME NFV_IFACE1 NFV_IFACE2 --+" 18 | echo "+-----------------------------------------------------------------------+" 19 | echo "" 20 | exit 21 | } 22 | 23 | if [ $# -eq 0 ] 24 | then 25 | echo "ERROR: No command specified. please try \"$0 help\" " 26 | exit 27 | fi 28 | 29 | if [ $1 = "help" ] 30 | then 31 | usage 32 | fi 33 | 34 | if [ $1 != "add" ] && [ $1 != "del" ] 35 | then 36 | echo "ERROR: unrecognized coomand. please try \"$0 help\" " 37 | exit 38 | fi 39 | 40 | if [ $# -lt 4 ] 41 | then 42 | echo "ERROR: too few parameters. please try \"$0 help\" " 43 | exit 44 | fi 45 | 46 | COMMAND=$1 47 | VNF_NAME=$2 48 | NFV_IFACE1=$3 49 | NFV_IFACE2=$4 50 | 51 | if [ $COMMAND = "del" ] 52 | then 53 | echo "DELETING \"${VNF_NAME}\"........." 54 | ip link delete dev ${NFV_IFACE1} 55 | ip link delete dev ${NFV_IFACE2} 56 | ip netns del $VNF_NAME 57 | exit 58 | fi 59 | 60 | if [ $# -lt 8 ] 61 | then 62 | echo "ERROR: too few parameters. please try \"$0 help\" " 63 | exit 64 | fi 65 | 66 | VNF_IFACE1="veth0-${VNF_NAME}" 67 | VNF_IFACE2="veth1-${VNF_NAME}" 68 | 69 | NFV_IP1=$5 70 | NFV_IP2=$6 71 | VNF_IP1=$7 72 | VNF_IP2=$8 73 | 74 | NH1=`echo ${NFV_IP1} | cut -d'/' -f1` 75 | NH2=`echo ${NFV_IP2} | cut -d'/' -f1` 76 | 77 | # create VNF 78 | ip netns add $VNF_NAME 79 | 80 | # Create links between NFV and VNF 81 | ip link add ${NFV_IFACE1} type veth peer name ${VNF_IFACE1} 82 | ip link add ${NFV_IFACE2} type veth peer name ${VNF_IFACE2} 83 | 84 | # Assign virtual interfaces to VNF 85 | ip link set ${VNF_IFACE1} netns ${VNF_NAME} 86 | ip link set ${VNF_IFACE2} netns ${VNF_NAME} 87 | 88 | ifconfig ${NFV_IFACE1} up 89 | ifconfig ${NFV_IFACE2} up 90 | 91 | ip netns exec ${VNF_NAME} ifconfig lo up 92 | ip netns exec ${VNF_NAME} ifconfig ${VNF_IFACE1} up 93 | ip netns exec ${VNF_NAME} ifconfig ${VNF_IFACE2} up 94 | 95 | ip netns exec ${VNF_NAME} sysctl -w net.ipv6.conf.all.forwarding=1 96 | 97 | ip addr add ${NFV_IP1} dev ${NFV_IFACE1} 98 | ip addr add ${NFV_IP2} dev ${NFV_IFACE2} 99 | 100 | ip netns exec ${VNF_NAME} ip addr add ${VNF_IP1} dev ${VNF_IFACE1} 101 | ip netns exec ${VNF_NAME} ip addr add ${VNF_IP2} dev ${VNF_IFACE2} 102 | 103 | # Configure Policy Based Routing in the VNF 104 | ip netns exec ${VNF_NAME} bash -c "echo '201 forward' >> /etc/iproute2/rt_tables" 105 | ip netns exec ${VNF_NAME} bash -c "ip rule add iif '${VNF_IFACE1}' lookup forward" 106 | ip netns exec ${VNF_NAME} bash -c "ip route add default via '${NH2}' table forward" 107 | ip netns exec ${VNF_NAME} bash -c "echo '202 reverse' >> /etc/iproute2/rt_tables" 108 | ip netns exec ${VNF_NAME} bash -c "ip rule add iif '${VNF_IFACE2}' lookup reverse" 109 | ip netns exec ${VNF_NAME} bash -c "ip route add default via '${NH1}' table reverse" 110 | 111 | 112 | echo "" 113 | echo "+----------------------------------+" 114 | echo "+---- VNF successfully created ----+" 115 | echo "+----------------------------------+" 116 | echo "+-- NAME : " $VNF_NAME 117 | echo "+-- HOST Iface1 : " $NFV_IFACE1 118 | echo "+-- HOST Iface2 : " $NFV_IFACE2 119 | echo "+-- HOST Iface1 addr : " $NFV_IP1 120 | echo "+-- HOST Iface2 addr : " $NFV_IP2 121 | echo "+-- VNF Iface1 : " $VNF_IFACE1 122 | echo "+-- VNF Iface2 : " $VNF_IFACE2 123 | echo "+-- VNF Iface1 addr : " $VNF_IP1 124 | echo "+-- VNF Iface2 addr : " $VNF_IP2 125 | echo "+----------------------------------+" 126 | echo "" 127 | exit 128 | -------------------------------------------------------------------------------- /config/deploy-vnf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | usage () { 4 | echo "" 5 | echo "+-----------------------------------------------------------------------+" 6 | echo "+---------------------+ VNF deploy script +-----------------------------+" 7 | echo "+-----------------------------------------------------------------------+" 8 | echo "+-- This script Adds/cleans network namespace (VNF) --+" 9 | echo "+-- Usage: --+" 10 | echo "+-- $ ./deploy-vnf.sh help --+" 11 | echo "+-- $ ./deploy-vnf.sh add VNF_NAME NFV_IFACE1 NFV_IFACE2 NFV_IFACE1\ --+" 12 | echo "+-- NFV_IFACE1_IP NFV_IFACE2_IP VNF_IFACE1_IP VNF_IFACE2_IP --+" 13 | echo "+-- $ ./deploy-vnf.sh del VNF_NAME NFV_IFACE1 NFV_IFACE2 --+" 14 | echo "+-- N.B: --+" 15 | echo "+-- IP Addresses should be in the form ADDR/MASK 'A::2/64' --+" 16 | echo "+-- Clean the VNF before re-trying to add (in case of error) --+" 17 | echo "+-- $./deploy-vnf.sh del VNF_NAME NFV_IFACE1 NFV_IFACE2 --+" 18 | echo "+-----------------------------------------------------------------------+" 19 | echo "" 20 | exit 21 | } 22 | 23 | if [ $# -eq 0 ] 24 | then 25 | echo "ERROR: No command specified. please try \"$0 help\" " 26 | exit 27 | fi 28 | 29 | if [ $1 = "help" ] 30 | then 31 | usage 32 | fi 33 | 34 | if [ $1 != "add" ] && [ $1 != "del" ] 35 | then 36 | echo "ERROR: unrecognized coomand. please try \"$0 help\" " 37 | exit 38 | fi 39 | 40 | if [ $# -lt 4 ] 41 | then 42 | echo "ERROR: too few parameters. please try \"$0 help\" " 43 | exit 44 | fi 45 | 46 | COMMAND=$1 47 | VNF_NAME=$2 48 | NFV_IFACE1=$3 49 | NFV_IFACE2=$4 50 | 51 | if [ $COMMAND = "del" ] 52 | then 53 | echo "DELETING \"${VNF_NAME}\"........." 54 | ip link delete dev ${NFV_IFACE1} 55 | ip link delete dev ${NFV_IFACE2} 56 | ip netns del $VNF_NAME 57 | exit 58 | fi 59 | 60 | if [ $# -lt 8 ] 61 | then 62 | echo "ERROR: too few parameters. please try \"$0 help\" " 63 | exit 64 | fi 65 | 66 | VNF_IFACE1="veth0-${VNF_NAME}" 67 | VNF_IFACE2="veth1-${VNF_NAME}" 68 | 69 | NFV_IP1=$5 70 | NFV_IP2=$6 71 | VNF_IP1=$7 72 | VNF_IP2=$8 73 | 74 | NH1=`echo ${NFV_IP1} | cut -d'/' -f1` 75 | NH2=`echo ${NFV_IP2} | cut -d'/' -f1` 76 | 77 | # create VNF 78 | ip netns add $VNF_NAME 79 | 80 | # Create links between NFV and VNF 81 | ip link add ${NFV_IFACE1} type veth peer name ${VNF_IFACE1} 82 | ip link add ${NFV_IFACE2} type veth peer name ${VNF_IFACE2} 83 | 84 | # Assign virtual interfaces to VNF 85 | ip link set ${VNF_IFACE1} netns ${VNF_NAME} 86 | ip link set ${VNF_IFACE2} netns ${VNF_NAME} 87 | 88 | ifconfig ${NFV_IFACE1} up 89 | ifconfig ${NFV_IFACE2} up 90 | 91 | ip netns exec ${VNF_NAME} ifconfig lo up 92 | ip netns exec ${VNF_NAME} ifconfig ${VNF_IFACE1} up 93 | ip netns exec ${VNF_NAME} ifconfig ${VNF_IFACE2} up 94 | 95 | ip netns exec ${VNF_NAME} sysctl -w net.ipv6.conf.all.forwarding=1 96 | 97 | ip -6 addr add ${NFV_IP1} dev ${NFV_IFACE1} 98 | ip -6 addr add ${NFV_IP2} dev ${NFV_IFACE2} 99 | 100 | ip netns exec ${VNF_NAME} ip -6 addr add ${VNF_IP1} dev ${VNF_IFACE1} 101 | ip netns exec ${VNF_NAME} ip -6 addr add ${VNF_IP2} dev ${VNF_IFACE2} 102 | 103 | # Configure Policy Based Routing in the VNF 104 | ip netns exec ${VNF_NAME} bash -c "echo '201 forward' >> /etc/iproute2/rt_tables" 105 | ip netns exec ${VNF_NAME} bash -c "ip -6 rule add iif '${VNF_IFACE1}' lookup forward" 106 | ip netns exec ${VNF_NAME} bash -c "ip -6 route add default via '${NH2}' table forward" 107 | ip netns exec ${VNF_NAME} bash -c "echo '202 reverse' >> /etc/iproute2/rt_tables" 108 | ip netns exec ${VNF_NAME} bash -c "ip -6 rule add iif '${VNF_IFACE2}' lookup reverse" 109 | ip netns exec ${VNF_NAME} bash -c "ip -6 route add default via '${NH1}' table reverse" 110 | 111 | 112 | echo "" 113 | echo "+----------------------------------+" 114 | echo "+---- VNF successfully created ----+" 115 | echo "+----------------------------------+" 116 | echo "+-- NAME : " $VNF_NAME 117 | echo "+-- HOST Iface1 : " $NFV_IFACE1 118 | echo "+-- HOST Iface2 : " $NFV_IFACE2 119 | echo "+-- HOST Iface1 addr : " $NFV_IP1 120 | echo "+-- HOST Iface2 addr : " $NFV_IP2 121 | echo "+-- VNF Iface1 : " $VNF_IFACE1 122 | echo "+-- VNF Iface2 : " $VNF_IFACE2 123 | echo "+-- VNF Iface1 addr : " $VNF_IP1 124 | echo "+-- VNF Iface2 addr : " $VNF_IP2 125 | echo "+----------------------------------+" 126 | echo "" 127 | exit 128 | -------------------------------------------------------------------------------- /config/deploy-term.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | usage () { 4 | echo "" 5 | echo "+------------------------------------------------------------------------+" 6 | echo "+-------------------+ Terminal deploy script +---------------------------+" 7 | echo "+------------------------------------------------------------------------+" 8 | echo "+-- A script to add/clean a network namespace to be used as a terminal --+" 9 | echo "+-- The terminal can be IPv4, IPv6, or dual network stack. --+" 10 | echo "+-- Usage: --+" 11 | echo "+-- $ ./deploy-term.sh help --+" 12 | echo "+-- $ ./deploy-term.sh add TERM_NAME NFV_IFACE MODE --+" 13 | echo "+-- MODE := inet NFV_ADDR4 TERM_ADDR4 --+" 14 | echo "+-- inet6 NFV_ADDR6 TERM_ADDR6 --+" 15 | echo "+-- dual NFV_ADDR4 TERM_ADDR4 NFV_ADDR6 TERM_ADDR6 --+" 16 | echo "+-- $ ./deploy-term.sh del TERM_NAME NFV_IFACE --+" 17 | echo "+-- N.B: --+" 18 | echo "+-- IP Addresses should be in the form ADDR/MASK 'A::2/64' --+" 19 | echo "+-- Clean the TERM before re-trying to add (in case of error) --+" 20 | echo "+-- $./deploy-term.sh del TERM_NAME NFV_IFACE --+" 21 | echo "+-----------------------------------------------------------------------+" 22 | echo "" 23 | exit 24 | } 25 | 26 | if [ $# -eq 0 ] 27 | then 28 | echo "ERROR: No command specified. please try \"$0 help\" " 29 | exit 30 | fi 31 | 32 | if [ $1 = "help" ] 33 | then 34 | usage 35 | fi 36 | 37 | if [ $1 != "add" ] && [ $1 != "del" ] 38 | then 39 | echo "ERROR: unrecognized coomand. please try \"$0 help\" " 40 | exit 41 | fi 42 | 43 | if [ $# -lt 3 ] 44 | then 45 | echo "ERROR: too few parameters. please try \"$0 help\" " 46 | exit 47 | fi 48 | 49 | COMMAND=$1 50 | TERM_NAME=$2 51 | NFV_IFACE=$3 52 | 53 | if [ $COMMAND = "del" ] 54 | then 55 | echo "DELETING \"${TERM_NAME}\"........." 56 | ip link delete dev ${NFV_IFACE} 57 | ip netns del $TERM_NAME 58 | exit 59 | fi 60 | 61 | 62 | if [ $# -ge 4 ] 63 | then 64 | MODE=$4 65 | if [ $MODE != "inet" ] && [ $MODE != "inet6" ] && [ $MODE != "dual" ] 66 | then 67 | echo " ERROR: Mode ${MODE} is not a valid inet mode many. please try \"$0 help\" " 68 | exit 69 | fi 70 | fi 71 | 72 | if [ $# -lt 6 ] 73 | then 74 | echo "ERROR: too few parameters for add command. please try \"$0 help\" " 75 | exit 76 | fi 77 | 78 | TERM_IFACE="veth0-${TERM_NAME}" 79 | 80 | if [ $MODE = "inet" ] || [ $MODE = "inet6" ] 81 | then 82 | if [ $# -gt 8 ] 83 | then 84 | echo "ERROR: too many parameters for inet or inet6 mode. please try \"$0 help\" " 85 | exit 86 | fi 87 | 88 | NFV_IP=$5 89 | TERM_IP=$6 90 | NH=`echo ${NFV_IP} | cut -d'/' -f1` 91 | 92 | # create TERM 93 | ip netns add $TERM_NAME 94 | #create link between NFV and TERM 95 | ip link add ${NFV_IFACE} type veth peer name ${TERM_IFACE} 96 | #assign virtual interface to TERM 97 | ip link set ${TERM_IFACE} netns ${TERM_NAME} 98 | ifconfig ${NFV_IFACE} up 99 | ip netns exec ${TERM_NAME} ifconfig ${TERM_IFACE} up 100 | 101 | if [ $MODE = "inet" ] 102 | then 103 | #configure NFV Interface 104 | ip addr add ${NFV_IP} dev ${NFV_IFACE} 105 | #configure TERM interfcae 106 | ip netns exec ${TERM_NAME} ip addr add ${TERM_IP} dev ${TERM_IFACE} 107 | #enable forwarding in TERM 108 | ip netns exec ${TERM_NAME} sysctl -w net.ipv4.conf.all.forwarding=1 >/dev/null 109 | ip netns exec ${TERM_NAME} ip route add default via ${NH} 110 | 111 | else 112 | ip netns exec ${TERM_NAME} sysctl -w net.ipv6.conf.all.forwarding=1 >/dev/null 113 | ip -6 addr add ${NFV_IP} dev ${NFV_IFACE} 114 | ip netns exec ${TERM_NAME} ip -6 addr add ${TERM_IP} dev ${TERM_IFACE} 115 | ip netns exec ${TERM_NAME} ip -6 route add default via ${NH} 116 | fi 117 | 118 | else 119 | if [ $# -lt 8 ] 120 | then 121 | echo "ERROR: too few parameters for dual mode. please try \"$0 help\" " 122 | exit 123 | fi 124 | 125 | if [ $# -gt 10 ] 126 | then 127 | echo "ERROR: too many parameters for dual mode. please try \"$0 help\" " 128 | exit 129 | fi 130 | 131 | NFV_IPv4=$5 132 | TERM_IPv4=$6 133 | NFV_IPv6=$7 134 | TERM_IPv6=$8 135 | 136 | # create TERM 137 | ip netns add $TERM_NAME 138 | #create link between NFV and TERM 139 | ip link add ${NFV_IFACE} type veth peer name ${TERM_IFACE} 140 | #assign virtual interface to TERM 141 | ip link set ${TERM_IFACE} netns ${TERM_NAME} 142 | ifconfig ${NFV_IFACE} up 143 | ip netns exec ${TERM_NAME} ifconfig ${TERM_IFACE} up 144 | 145 | #configure NFV Interface 146 | ip addr add ${NFV_IPv4} dev ${NFV_IFACE} 147 | ip -6 addr add ${NFV_IPv6} dev ${NFV_IFACE} 148 | 149 | #configure TERM interfcae 150 | ip netns exec ${TERM_NAME} ip addr add ${TERM_IPv4} dev ${TERM_IFACE} 151 | ip netns exec ${TERM_NAME} ip -6 addr add ${TERM_IPv6} dev ${TERM_IFACE} 152 | 153 | #enable forwarding in TERM 154 | ip netns exec ${TERM_NAME} sysctl -w net.ipv4.conf.all.forwarding=1 >/dev/null 155 | ip netns exec ${TERM_NAME} sysctl -w net.ipv6.conf.all.forwarding=1 >/dev/null 156 | NH4=`echo ${NFV_IPv4} | cut -d'/' -f1` 157 | NH6=`echo ${NFV_IPv6} | cut -d'/' -f1` 158 | 159 | ip netns exec ${TERM_NAME} ip route add default via ${NH4} 160 | ip netns exec ${TERM_NAME} ip -6 route add default via ${NH6} 161 | 162 | fi 163 | 164 | echo "" 165 | echo "+---------------------------------------+" 166 | echo "+---- Terminal successfully created ----+" 167 | echo "+---------------------------------------+" 168 | echo "+-- NAME : " $TERM_NAME 169 | echo "+-- HOST Iface : " $NFV_IFACE 170 | echo "+-- HOST Iface addr : " $NFV_IP 171 | echo "+-- TERM Iface : " $TERM_IFACE 172 | echo "+-- TERM Iface addr : " $TERM_IP 173 | echo "+----------------------------------+" 174 | echo "" 175 | exit 176 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | # Node R1 configuration 6 | config.vm.define "hosta" do |hosta| 7 | hosta.vm.box = "srouting/srv6-net-prog" 8 | hosta.vm.box_version = "0.4.14" 9 | hosta.vm.synced_folder(".", nil, :disabled => true, :id => "vagrant-root") 10 | hosta.vm.network "private_network", ip: "10.0.0.1", virtualbox__intnet: "netv4a" 11 | hosta.vm.provider "virtualbox" do |virtualbox| 12 | virtualbox.memory = "256" 13 | virtualbox.customize ['modifyvm', :id, '--nictrace2', 'on'] 14 | virtualbox.customize ['modifyvm', :id, '--nictracefile2', 'tracea.pcap'] 15 | virtualbox.customize ['modifyvm', :id, '--cableconnected1', 'on'] 16 | virtualbox.customize ['modifyvm', :id, '--cableconnected2', 'on'] 17 | end 18 | hosta.vm.provision "shell", path: "config/config_a.sh" 19 | end 20 | 21 | config.vm.define "hostb" do |hostb| 22 | hostb.vm.box = "srouting/srv6-net-prog" 23 | hostb.vm.box_version = "0.4.14" 24 | hostb.vm.synced_folder(".", nil, :disabled => true, :id => "vagrant-root") 25 | hostb.vm.network "private_network", ip: "10.0.1.1", virtualbox__intnet: "netv4b" 26 | hostb.vm.provider "virtualbox" do |virtualbox| 27 | virtualbox.memory = "256" 28 | virtualbox.customize ['modifyvm', :id, '--nictrace2', 'on'] 29 | virtualbox.customize ['modifyvm', :id, '--nictracefile2', 'traceb.pcap'] 30 | virtualbox.customize ['modifyvm', :id, '--cableconnected1', 'on'] 31 | virtualbox.customize ['modifyvm', :id, '--cableconnected2', 'on'] 32 | end 33 | hostb.vm.provision "shell", path: "config/config_b.sh" 34 | end 35 | 36 | # Node R1 configuration 37 | config.vm.define "r1" do |r1| 38 | r1.vm.box = "srouting/srv6-net-prog" 39 | r1.vm.box_version = "0.4.14" 40 | r1.vm.synced_folder(".", nil, :disabled => true, :id => "vagrant-root") 41 | r1.vm.network "private_network", ip: "10.0.0.2", virtualbox__intnet: "netv4a" 42 | r1.vm.network "private_network", ip: "2001:12::1",netmask: "64", virtualbox__intnet: "net12" 43 | 44 | r1.vm.provider "virtualbox" do |virtualbox| 45 | virtualbox.memory = "256" 46 | virtualbox.customize ['modifyvm', :id, '--nictrace2', 'on'] 47 | virtualbox.customize ['modifyvm', :id, '--nictracefile2', 'trace1.pcap'] 48 | virtualbox.customize ['modifyvm', :id, '--nictrace3', 'on'] 49 | virtualbox.customize ['modifyvm', :id, '--nictracefile3', 'trace12.pcap'] 50 | virtualbox.customize ['modifyvm', :id, '--cableconnected1', 'on'] 51 | virtualbox.customize ['modifyvm', :id, '--cableconnected2', 'on'] 52 | virtualbox.customize ['modifyvm', :id, '--cableconnected3', 'on'] 53 | 54 | end 55 | r1.vm.provision "shell", path: "config/config_r1.sh" 56 | end 57 | 58 | # Node R2 configuration 59 | config.vm.define "r2" do |r2| 60 | r2.vm.box = "srouting/srv6-net-prog" 61 | r2.vm.box_version = "0.4.14" 62 | r2.vm.synced_folder(".", nil, :disabled => true, :id => "vagrant-root") 63 | r2.vm.network "private_network", ip: "2001:12::2",netmask: "64", virtualbox__intnet: "net12" 64 | r2.vm.network "private_network", ip: "2001:23::1",netmask: "64", virtualbox__intnet: "net23" 65 | r2.vm.network "private_network", ip: "2001:a::1",netmask: "64", virtualbox__intnet: "netserver1" 66 | 67 | r2.vm.provider "virtualbox" do |virtualbox| 68 | virtualbox.memory = "256" 69 | virtualbox.cpus = "1" 70 | virtualbox.customize ['modifyvm', :id, '--nictrace2', 'on'] 71 | virtualbox.customize ['modifyvm', :id, '--nictracefile2', 'trace2.pcap'] 72 | virtualbox.customize ['modifyvm', :id, '--nictrace3', 'on'] 73 | virtualbox.customize ['modifyvm', :id, '--nictracefile3', 'trace21.pcap'] 74 | virtualbox.customize ['modifyvm', :id, '--nictrace4', 'on'] 75 | virtualbox.customize ['modifyvm', :id, '--nictracefile4', 'trace22.pcap'] 76 | virtualbox.customize ['modifyvm', :id, '--cableconnected1', 'on'] 77 | virtualbox.customize ['modifyvm', :id, '--cableconnected2', 'on'] 78 | virtualbox.customize ['modifyvm', :id, '--cableconnected3', 'on'] 79 | end 80 | r2.vm.provision "shell", path: "config/config_r2.sh" 81 | end 82 | 83 | # Node R3 configuration 84 | config.vm.define "r3" do |r3| 85 | r3.vm.box = "srouting/srv6-net-prog" 86 | r3.vm.box_version = "0.4.14" 87 | r3.vm.synced_folder(".", nil, :disabled => true, :id => "vagrant-root") 88 | r3.vm.network "private_network", ip: "10.0.1.2", virtualbox__intnet: "netv4b" 89 | r3.vm.network "private_network", ip: "2001:23::2",netmask: "64", virtualbox__intnet: "net23" 90 | r3.vm.network "private_network", ip: "2001:b::1",netmask: "64", virtualbox__intnet: "netserver2" 91 | r3.vm.provider "virtualbox" do |virtualbox| 92 | virtualbox.memory = "256" 93 | virtualbox.customize ['modifyvm', :id, '--nictrace2', 'on'] 94 | virtualbox.customize ['modifyvm', :id, '--nictracefile2', 'trace3.pcap'] 95 | virtualbox.customize ['modifyvm', :id, '--nictrace3', 'on'] 96 | virtualbox.customize ['modifyvm', :id, '--nictracefile3', 'trace31.pcap'] 97 | virtualbox.customize ['modifyvm', :id, '--nictrace4', 'on'] 98 | virtualbox.customize ['modifyvm', :id, '--nictracefile4', 'trace32.pcap'] 99 | 100 | virtualbox.customize ['modifyvm', :id, '--cableconnected1', 'on'] 101 | virtualbox.customize ['modifyvm', :id, '--cableconnected2', 'on'] 102 | virtualbox.customize ['modifyvm', :id, '--cableconnected3', 'on'] 103 | virtualbox.customize ['modifyvm', :id, '--cableconnected4', 'on'] 104 | 105 | end 106 | r3.vm.provision "shell", path: "config/config_r3.sh" 107 | end 108 | # server1 configuration 109 | config.vm.define "server1" do |server1| 110 | server1.vm.box = "srouting/srv6-net-prog" 111 | server1.vm.box_version = "0.4.14" 112 | server1.vm.synced_folder(".", nil, :disabled => true, :id => "vagrant-root") 113 | server1.vm.network "private_network", ip: "2001:a::2",netmask: "64", virtualbox__intnet: "netserver1" 114 | server1.vm.provider "virtualbox" do |virtualbox| 115 | virtualbox.memory = "256" 116 | virtualbox.customize ['modifyvm', :id, '--nictrace2', 'on'] 117 | virtualbox.customize ['modifyvm', :id, '--nictracefile2', 'traceserver1.pcap'] 118 | virtualbox.customize ['modifyvm', :id, '--cableconnected1', 'on'] 119 | virtualbox.customize ['modifyvm', :id, '--cableconnected2', 'on'] 120 | end 121 | server1.vm.provision "shell", path: "config/config_server1.sh" 122 | end 123 | 124 | # server2 configuration 125 | config.vm.define "server2" do |server2| 126 | server2.vm.box = "srouting/srv6-net-prog" 127 | server2.vm.box_version = "0.4.14" 128 | server2.vm.synced_folder(".", nil, :disabled => true, :id => "vagrant-root") 129 | server2.vm.network "private_network", ip: "2001:b::2",netmask: "64", virtualbox__intnet: "netserver2" 130 | server2.vm.provider "virtualbox" do |virtualbox| 131 | virtualbox.memory = "256" 132 | virtualbox.customize ['modifyvm', :id, '--nictrace2', 'on'] 133 | virtualbox.customize ['modifyvm', :id, '--nictracefile2', 'traceserver2.pcap'] 134 | virtualbox.customize ['modifyvm', :id, '--cableconnected1', 'on'] 135 | virtualbox.customize ['modifyvm', :id, '--cableconnected2', 'on'] 136 | end 137 | server2.vm.provision "shell", path: "config/config_server2.sh" 138 | end 139 | end 140 | -------------------------------------------------------------------------------- /topo.py: -------------------------------------------------------------------------------- 1 | from mininet.log import lg 2 | 3 | import ipmininet 4 | from ipmininet.cli import IPCLI 5 | from ipmininet.ipnet import IPNet 6 | from ipmininet.iptopo import IPTopo 7 | from ipmininet.router.config import StaticRoute 8 | from ipmininet.router.config.base import RouterConfig 9 | from ipmininet.router.config.zebra import Zebra 10 | 11 | """ 12 | 13 | a ---- r1 ---- r2 ---- r3 ---- c 14 | | + | 15 | ------- r4 ------ 16 | + 17 | b 18 | 19 | """ 20 | 21 | # R1 R3 R4 are Segment Routing Enabled Server. 22 | 23 | ipv6_address={ 24 | 1:"2001:1a::/64", 25 | 3:"2001:3c::/64", 26 | 4:"2001:4b::/64" 27 | } 28 | ipv4_address={ 29 | 1:"10.0.0.0/24", 30 | 3:"10.0.1.0/24", 31 | 4:"10.0.2.0/24" 32 | } 33 | 34 | ipv4_gw={ 35 | 1:"10.0.0.1", 36 | 3:"10.0.1.1", 37 | 4:"10.0.2.1" 38 | } 39 | 40 | 41 | 42 | 43 | class SimpleTopo(IPTopo): 44 | 45 | def build(self, *args, **kwargs): 46 | """ 47 | """ 48 | r1_routes = [StaticRoute("fc00:4::/64", "2001:14::2"),StaticRoute("::/0", "2001:12::2")] 49 | r3_routes = [StaticRoute("fc00:4::/64", "2001:34::2"),StaticRoute("::/0", "2001:23::1")] 50 | r4_routes = [StaticRoute("fc00:1::/64", "2001:14::1"),StaticRoute("fc00:3::/64", "2001:34::1"), 51 | StaticRoute("::/0", "2001:24::1")] 52 | r2_routes = [StaticRoute("fc00:1::/64", "2001:12::1"), 53 | StaticRoute("fc00:3::/64", "2001:23::2"), 54 | StaticRoute("fc00:4::/64", "2001:24::2")] 55 | 56 | r1 = self.addRouter_v('r1', r1_routes) 57 | r3 = self.addRouter_v('r3', r3_routes) 58 | r4 = self.addRouter_v('r4', r4_routes) 59 | 60 | r2 = self.addRouter_v6('r2', r2_routes) # Pure IPv6 Router 61 | 62 | a_routes = [StaticRoute("0.0.0.0/0", "10.0.0.2"),StaticRoute("::/0", "2001:1a::1/64")] 63 | b_routes = [StaticRoute("0.0.0.0/0", "10.0.2.2"),StaticRoute("::/0", "2001:4b::1/64")] 64 | c_routes = [StaticRoute("0.0.0.0/0", "10.0.1.2"),StaticRoute("::/0", "2001:3c::1/64")] 65 | 66 | 67 | a = self.addRouter_v('a',a_routes) 68 | b = self.addRouter_v('b',b_routes) 69 | c = self.addRouter_v('c',c_routes) 70 | 71 | # Links between Routers 72 | 73 | self.addLink(r1, r2, params1={"ip": "2001:12::1/64"}, 74 | params2={"ip": "2001:12::2/64"}) 75 | self.addLink(r2, r3, params1={"ip": "2001:23::1/64"}, 76 | params2={"ip": "2001:23::2/64"}) 77 | self.addLink(r2, r4, params1={"ip": "2001:24::1/64"}, 78 | params2={"ip": "2001:24::2/64"}) 79 | 80 | self.addLink(r1, r4, params1={"ip": "2001:14::1/64"}, 81 | params2={"ip": "2001:14::2/64"}) 82 | self.addLink(r3, r4, params1={"ip": "2001:34::1/64"}, 83 | params2={"ip": "2001:34::2/64"}) 84 | 85 | 86 | # Links between Router and Hosts (IPv4) 87 | 88 | self.addLink(r1, a, 89 | params1={"ip": "10.0.0.2/24"}, 90 | params2={"ip": "10.0.0.1/24"}) 91 | self.addLink(r4, b, 92 | params1={"ip": "10.0.2.2/24"}, 93 | params2={"ip": "10.0.2.1/24"}) 94 | self.addLink(r3, c, 95 | params1={"ip": "10.0.1.2/24"}, 96 | params2={"ip": "10.0.1.1/24"}) 97 | 98 | # Links between Router and Hosts (IPv6) 99 | self.addLink(r1, a, 100 | params1={"ip": "2001:1a::1/64"}, 101 | params2={"ip": "2001:1a::2/64"}) 102 | self.addLink(r4, b, 103 | params1={"ip": "2001:4b::1/64"}, 104 | params2={"ip": "2001:4b::2/64"}) 105 | self.addLink(r3, c, 106 | params1={"ip": "2001:3c::1/64"}, 107 | params2={"ip": "2001:3c::2/64"}) 108 | 109 | super(SimpleTopo, self).build(*args, **kwargs) 110 | 111 | def addRouter_v6(self, name, staticRoutes): 112 | return self.addRouter(name, use_v4=False, use_v6=True, config=(RouterConfig, {'daemons': [(Zebra, {"static_routes": staticRoutes})]})) 113 | 114 | def addRouter_v(self, name, staticRoutes): 115 | return self.addRouter(name, use_v4=True, use_v6=True, config=(RouterConfig, {'daemons': [(Zebra, {"static_routes": staticRoutes})]})) 116 | 117 | class RouterConfiguration(object): 118 | def __init__(self,host,host_num): 119 | self.host=host 120 | self.host_num=host_num 121 | self.configure() 122 | 123 | def exec_cmd(self,cmd): 124 | if type(cmd)==list: 125 | for c in cmd: 126 | print(c) 127 | self.host.cmd(c) 128 | return None 129 | else: 130 | print(cmd) 131 | result = self.host.cmd(cmd) 132 | return result 133 | 134 | def configure(self): 135 | # Config IPv6 Loopback address first. 136 | self.exec_cmd("ip -6 addr add fc00:{0}::{0}/64 dev lo".format(self.host_num)) 137 | self.host_loc="fc00:{}::".format(self.host_num) 138 | # Get all the interface 139 | intf_list = [i.strip().strip(":") for i in self.exec_cmd("ifconfig -a | sed 's/[ \t].*//;/^$/d'").split('\r\n')] 140 | print(intf_list) 141 | # Config Systemctl 142 | cmds = ["sysctl -w net.ipv6.conf.{}.seg6_enabled=1".format(i) for i in intf_list] 143 | self.exec_cmd(cmds) 144 | # Config SR addr 145 | self.exec_cmd("ip sr tunsrc set fc00:{0}::{0}".format(self.host_num)) 146 | 147 | @staticmethod 148 | def build_dx4_tunnel(host1,host2,id,segs_12=None,segs_21=None): 149 | """ 150 | This function is used to build a DX4 Tunnel with optional TE 151 | """ 152 | # In order to build a End.DX4 Tunnel, we need lots of Info 153 | # First build the commands 154 | seg_list_12 = "" 155 | seg_list_21 = "" 156 | 157 | if segs_12: 158 | for host in segs_12: 159 | segtag = SegmentHost(host,id).segid 160 | seg_list_12=seg_list_12 + segtag + "," 161 | if segs_21: 162 | for host in segs_21: 163 | segtag = SegmentHost(host,id).segid 164 | seg_list_21=seg_list_21 + segtag + "," 165 | 166 | 167 | 168 | cmd_h1 = ["ip -6 route add {}{}/128 encap seg6local action End.DX4 nh4 {} dev r{}-eth1" 169 | .format(host1.host_loc,id,ipv4_gw[host1.host_num],host1.host_num), 170 | "ip route add {} encap seg6 mode encap segs {}{}{} dev r{}-eth1" 171 | .format(ipv4_address[host2.host_num],seg_list_12,host2.host_loc,id,host1.host_num)] 172 | 173 | cmd_h2 = ["ip -6 route add {}{}/128 encap seg6local action End.DX4 nh4 {} dev r{}-eth1" 174 | .format(host2.host_loc,id,ipv4_gw[host2.host_num],host2.host_num), 175 | "ip route add {} encap seg6 mode encap segs {}{}{} dev r{}-eth1" 176 | .format(ipv4_address[host1.host_num],seg_list_21,host1.host_loc,id,host2.host_num)] 177 | host1.exec_cmd(cmd_h1) 178 | host2.exec_cmd(cmd_h2) 179 | 180 | @staticmethod 181 | def build_dx6_tunnel(host1,host2,id,segs_12=None,segs_21=None): 182 | """ 183 | This function is used to build a DX6 Tunnel with optional TE 184 | """ 185 | # In order to build a End.DX4 Tunnel, we need lots of Info 186 | # First build the commands 187 | 188 | seg_list_12 = "" 189 | seg_list_21 = "" 190 | 191 | if segs_12: 192 | for host in segs_12: 193 | segtag = SegmentHost(host,id).segid 194 | seg_list_12=seg_list_12 + segtag + "," 195 | if segs_21: 196 | for host in segs_21: 197 | segtag = SegmentHost(host,id).segid 198 | seg_list_21=seg_list_21 + segtag + "," 199 | 200 | 201 | cmd_h1 = ["ip -6 route add {}{}/128 encap seg6local action End.DX6 nh6 :: dev r{}-eth1" 202 | .format(host1.host_loc,id,host1.host_num), 203 | "ip -6 route add {} encap seg6 mode encap segs {}{}{} dev r{}-eth1" 204 | .format(ipv6_address[host2.host_num],seg_list_12,host2.host_loc,id,host1.host_num)] 205 | 206 | cmd_h2 = ["ip -6 route add {}{}/128 encap seg6local action End.DX6 nh6 :: dev r{}-eth1" 207 | .format(host2.host_loc,id,host2.host_num), 208 | "ip route add {} encap seg6 mode encap segs {}{}{} dev r{}-eth1" 209 | .format(ipv6_address[host1.host_num],seg_list_21,host1.host_loc,id,host2.host_num)] 210 | host1.exec_cmd(cmd_h1) 211 | host2.exec_cmd(cmd_h2) 212 | 213 | class HostConfiguration(object): 214 | def __init__(self,host,host_name,host_num): 215 | self.host=host 216 | self.host_num=host_num 217 | self.host_name = host_name 218 | self.configure() 219 | 220 | def exec_cmd(self,cmd): 221 | if type(cmd)==list: 222 | for c in cmd: 223 | print(c) 224 | self.host.cmd(c) 225 | return None 226 | else: 227 | print(cmd) 228 | result = self.host.cmd(cmd) 229 | return result 230 | 231 | def configure(self): 232 | # Config IPv6 Default route. 233 | self.exec_cmd("ip -6 route add default via 2001:{}{}::1".format(self.host_num,self.host_name)) 234 | 235 | 236 | 237 | class SegmentHost(object): 238 | def __init__(self,host,id): 239 | self.host=host 240 | self.id=id 241 | self.segid = "fc00:{}::{}".format(self.host.host_num,self.id) 242 | self.configure() 243 | 244 | def configure(self): 245 | # Configure the End Point host. 246 | cmd= "ip -6 route add {}/128 encap seg6local action End dev r{}-eth0".format(self.segid,self.host.host_num) 247 | self.host.exec_cmd(cmd) 248 | 249 | 250 | if __name__ == '__main__': 251 | ipmininet.DEBUG_FLAG = True 252 | lg.setLogLevel("info") 253 | 254 | # Start network 255 | net = IPNet(topo=SimpleTopo(), use_v4=True, allocate_IPs=False) 256 | 257 | try: 258 | net.start() 259 | # Execute Commands 260 | 261 | # Enable SRv6 On Routers. 262 | r1 = RouterConfiguration(net.get('r1'),1) 263 | r3 = RouterConfiguration(net.get('r3'),3) 264 | r4 = RouterConfiguration(net.get('r4'),4) 265 | HostConfiguration(net.get('a'),'a',1) 266 | HostConfiguration(net.get('b'),'b',4) 267 | HostConfiguration(net.get('c'),'c',3) 268 | 269 | 270 | # RouterConfiguration.build_dx4_tunnel(r1,r3,"a") 271 | # RouterConfiguration.build_dx4_tunnel(r3,r4,"b") 272 | # RouterConfiguration.build_dx4_tunnel(r1,r4,"c") 273 | 274 | # RouterConfiguration.build_dx6_tunnel(r1,r3,"a1") 275 | # RouterConfiguration.build_dx6_tunnel(r3,r4,"b1") 276 | # RouterConfiguration.build_dx6_tunnel(r1,r4,"c1") 277 | 278 | IPCLI(net) 279 | finally: 280 | net.stop() 281 | -------------------------------------------------------------------------------- /topo_new.py: -------------------------------------------------------------------------------- 1 | from mininet.log import lg 2 | 3 | import ipmininet 4 | from ipmininet.cli import IPCLI 5 | from ipmininet.ipnet import IPNet 6 | from ipmininet.iptopo import IPTopo 7 | from ipmininet.router.config import StaticRoute 8 | from ipmininet.router.config.base import RouterConfig 9 | from ipmininet.router.config.zebra import Zebra 10 | 11 | """ 12 | 13 | If your Quagga is not adding Static Routes normally, use this script instead. 14 | 15 | a ---- r1 ---- r2 ---- r3 ---- c 16 | | + | 17 | ------- r4 ------ 18 | + 19 | b 20 | 21 | """ 22 | 23 | # R1 R3 R4 are Segment Routing Enabled Server. 24 | 25 | ipv6_address={ 26 | 1:"2001:1a::/64", 27 | 3:"2001:3c::/64", 28 | 4:"2001:4b::/64" 29 | } 30 | ipv4_address={ 31 | 1:"10.0.0.0/24", 32 | 3:"10.0.1.0/24", 33 | 4:"10.0.2.0/24" 34 | } 35 | 36 | ipv4_gw={ 37 | 1:"10.0.0.1", 38 | 3:"10.0.1.1", 39 | 4:"10.0.2.1" 40 | } 41 | 42 | r1_routes = [StaticRoute("fc00:4::/64", "2001:14::2"),StaticRoute("::/0", "2001:12::2")] 43 | r3_routes = [StaticRoute("fc00:4::/64", "2001:34::2"),StaticRoute("::/0", "2001:23::1")] 44 | r4_routes = [StaticRoute("fc00:1::/64", "2001:14::1"),StaticRoute("fc00:3::/64", "2001:34::1"), 45 | StaticRoute("::/0", "2001:24::1")] 46 | r2_routes = [StaticRoute("fc00:1::/64", "2001:12::1"), 47 | StaticRoute("fc00:3::/64", "2001:23::2"), 48 | StaticRoute("fc00:4::/64", "2001:24::2")] 49 | a_routes = [StaticRoute("::/0", "2001:1a::1/64")] 50 | b_routes = [StaticRoute("::/0", "2001:4b::1/64")] 51 | c_routes = [StaticRoute("::/0", "2001:3c::1/64")] 52 | 53 | 54 | 55 | class SimpleTopo(IPTopo): 56 | 57 | def build(self, *args, **kwargs): 58 | """ 59 | """ 60 | 61 | r1 = self.addRouter_v('r1', r1_routes) 62 | r3 = self.addRouter_v('r3', r3_routes) 63 | r4 = self.addRouter_v('r4', r4_routes) 64 | 65 | r2 = self.addRouter_v6('r2', r2_routes) # Pure IPv6 Router 66 | 67 | 68 | 69 | a = self.addHost('a',defaultRoute='via 10.0.0.2') 70 | b = self.addHost('b', defaultRoute='via 10.0.2.2') 71 | c = self.addHost('c', defaultRoute='via 10.0.1.2') 72 | 73 | # Links between Routers 74 | 75 | self.addLink(r1, r2, params1={"ip": "2001:12::1/64"}, 76 | params2={"ip": "2001:12::2/64"}) 77 | self.addLink(r2, r3, params1={"ip": "2001:23::1/64"}, 78 | params2={"ip": "2001:23::2/64"}) 79 | self.addLink(r2, r4, params1={"ip": "2001:24::1/64"}, 80 | params2={"ip": "2001:24::2/64"}) 81 | 82 | self.addLink(r1, r4, params1={"ip": "2001:14::1/64"}, 83 | params2={"ip": "2001:14::2/64"}) 84 | self.addLink(r3, r4, params1={"ip": "2001:34::1/64"}, 85 | params2={"ip": "2001:34::2/64"}) 86 | 87 | 88 | # Links between Router and Hosts (IPv4) 89 | 90 | self.addLink(r1, a, 91 | params1={"ip": "10.0.0.2/24"}, 92 | params2={"ip": "10.0.0.1/24"}) 93 | self.addLink(r4, b, 94 | params1={"ip": "10.0.2.2/24"}, 95 | params2={"ip": "10.0.2.1/24"}) 96 | self.addLink(r3, c, 97 | params1={"ip": "10.0.1.2/24"}, 98 | params2={"ip": "10.0.1.1/24"}) 99 | 100 | # Links between Router and Hosts (IPv6) 101 | self.addLink(r1, a, 102 | params1={"ip": "2001:1a::1/64"}, 103 | params2={"ip": "2001:1a::2/64"}) 104 | self.addLink(r4, b, 105 | params1={"ip": "2001:4b::1/64"}, 106 | params2={"ip": "2001:4b::2/64"}) 107 | self.addLink(r3, c, 108 | params1={"ip": "2001:3c::1/64"}, 109 | params2={"ip": "2001:3c::2/64"}) 110 | 111 | super(SimpleTopo, self).build(*args, **kwargs) 112 | 113 | def addRouter_v6(self, name, staticRoutes): 114 | return self.addRouter(name, use_v4=False, use_v6=True, config=(RouterConfig, {'daemons': [(Zebra, {"static_routes": staticRoutes})]})) 115 | 116 | def addRouter_v(self, name, staticRoutes): 117 | return self.addRouter(name, use_v4=True, use_v6=True, config=(RouterConfig, {'daemons': [(Zebra, {"static_routes": staticRoutes})]})) 118 | 119 | 120 | class RouterConfiguration(object): 121 | def __init__(self,host,host_num,routes,srv6=True): 122 | self.host=host 123 | self.host_num=host_num 124 | self.routes=routes 125 | self.srv6=srv6 126 | self.configure() 127 | 128 | def exec_cmd(self,cmd): 129 | if type(cmd)==list: 130 | for c in cmd: 131 | print(c) 132 | self.host.cmd(c) 133 | return None 134 | else: 135 | print(cmd) 136 | result = self.host.cmd(cmd) 137 | return result 138 | 139 | def configure(self): 140 | # Config IPv6 Loopback address first. 141 | self.exec_cmd("ip -6 addr add fc00:{0}::{0}/64 dev lo".format(self.host_num)) 142 | self.host_loc="fc00:{}::".format(self.host_num) 143 | # Get all the interface 144 | intf_list = [i.strip().strip(":") for i in self.exec_cmd("ifconfig -a | sed 's/[ \t].*//;/^$/d'").split('\r\n')] 145 | print(intf_list) 146 | 147 | # Config IPv6 Routes 148 | self.configure_static_route() 149 | 150 | # Config SR 151 | if self.srv6: 152 | # Config Systemctl 153 | cmds = ["sysctl -w net.ipv6.conf.{}.seg6_enabled=1".format(i) for i in intf_list] 154 | self.exec_cmd(cmds) 155 | self.exec_cmd("ip sr tunsrc set fc00:{0}::{0}".format(self.host_num)) 156 | 157 | def configure_static_route(self): 158 | print("Configuring Routes") 159 | for route in self.routes: 160 | self.exec_cmd("ip -6 route add {} via {}".format(route.prefix, route.nexthop)) 161 | 162 | 163 | @staticmethod 164 | def build_dx4_tunnel(host1,host2,id,segs_12=None,segs_21=None): 165 | """ 166 | This function is used to build a DX4 Tunnel with optional TE 167 | """ 168 | # In order to build a End.DX4 Tunnel, we need lots of Info 169 | # First build the commands 170 | seg_list_12 = "" 171 | seg_list_21 = "" 172 | 173 | if segs_12: 174 | for host in segs_12: 175 | segtag = SegmentHost(host,id).segid 176 | seg_list_12=seg_list_12 + segtag + "," 177 | if segs_21: 178 | for host in segs_21: 179 | segtag = SegmentHost(host,id).segid 180 | seg_list_21=seg_list_21 + segtag + "," 181 | 182 | 183 | 184 | cmd_h1 = ["ip -6 route add {}{}/128 encap seg6local action End.DX4 nh4 {} dev r{}-eth1" 185 | .format(host1.host_loc,id,ipv4_gw[host1.host_num],host1.host_num), 186 | "ip route add {} encap seg6 mode encap segs {}{}{} dev r{}-eth1" 187 | .format(ipv4_address[host2.host_num],seg_list_12,host2.host_loc,id,host1.host_num)] 188 | 189 | cmd_h2 = ["ip -6 route add {}{}/128 encap seg6local action End.DX4 nh4 {} dev r{}-eth1" 190 | .format(host2.host_loc,id,ipv4_gw[host2.host_num],host2.host_num), 191 | "ip route add {} encap seg6 mode encap segs {}{}{} dev r{}-eth1" 192 | .format(ipv4_address[host1.host_num],seg_list_21,host1.host_loc,id,host2.host_num)] 193 | host1.exec_cmd(cmd_h1) 194 | host2.exec_cmd(cmd_h2) 195 | 196 | @staticmethod 197 | def build_dx6_tunnel(host1,host2,id,segs_12=None,segs_21=None): 198 | """ 199 | This function is used to build a DX6 Tunnel with optional TE 200 | """ 201 | # In order to build a End.DX4 Tunnel, we need lots of Info 202 | # First build the commands 203 | 204 | seg_list_12 = "" 205 | seg_list_21 = "" 206 | 207 | if segs_12: 208 | for host in segs_12: 209 | segtag = SegmentHost(host,id).segid 210 | seg_list_12=seg_list_12 + segtag + "," 211 | if segs_21: 212 | for host in segs_21: 213 | segtag = SegmentHost(host,id).segid 214 | seg_list_21=seg_list_21 + segtag + "," 215 | 216 | 217 | cmd_h1 = ["ip -6 route add {}{}/128 encap seg6local action End.DX6 nh6 :: dev r{}-eth1" 218 | .format(host1.host_loc,id,host1.host_num), 219 | "ip -6 route add {} encap seg6 mode encap segs {}{}{} dev r{}-eth1" 220 | .format(ipv6_address[host2.host_num],seg_list_12,host2.host_loc,id,host1.host_num)] 221 | 222 | cmd_h2 = ["ip -6 route add {}{}/128 encap seg6local action End.DX6 nh6 :: dev r{}-eth1" 223 | .format(host2.host_loc,id,host2.host_num), 224 | "ip route add {} encap seg6 mode encap segs {}{}{} dev r{}-eth1" 225 | .format(ipv6_address[host1.host_num],seg_list_21,host1.host_loc,id,host2.host_num)] 226 | host1.exec_cmd(cmd_h1) 227 | host2.exec_cmd(cmd_h2) 228 | 229 | class HostConfiguration(object): 230 | def __init__(self,host,host_name,host_num): 231 | self.host=host 232 | self.host_num=host_num 233 | self.host_name = host_name 234 | self.configure() 235 | 236 | def exec_cmd(self,cmd): 237 | if type(cmd)==list: 238 | for c in cmd: 239 | print(c) 240 | self.host.cmd(c) 241 | return None 242 | else: 243 | print(cmd) 244 | result = self.host.cmd(cmd) 245 | return result 246 | 247 | def configure(self): 248 | # Config IPv6 Default route. 249 | self.exec_cmd("ip -6 route add default via 2001:{}{}::1".format(self.host_num,self.host_name)) 250 | 251 | 252 | 253 | class SegmentHost(object): 254 | def __init__(self,host,id): 255 | self.host=host 256 | self.id=id 257 | self.segid = "fc00:{}::{}".format(self.host.host_num,self.id) 258 | self.configure() 259 | 260 | def configure(self): 261 | # Configure the End Point host. 262 | cmd= "ip -6 route add {}/128 encap seg6local action End dev r{}-eth0".format(self.segid,self.host.host_num) 263 | self.host.exec_cmd(cmd) 264 | 265 | 266 | if __name__ == '__main__': 267 | ipmininet.DEBUG_FLAG = True 268 | lg.setLogLevel("info") 269 | 270 | # Start network 271 | net = IPNet(topo=SimpleTopo(), use_v4=True, allocate_IPs=False) 272 | 273 | try: 274 | net.start() 275 | # Execute Commands 276 | 277 | # Enable SRv6 On Routers. 278 | r1 = RouterConfiguration(net.get('r1'),1,r1_routes) 279 | r2 = RouterConfiguration(net.get('r2'),2,r2_routes,False) 280 | r3 = RouterConfiguration(net.get('r3'),3,r3_routes) 281 | r4 = RouterConfiguration(net.get('r4'),4,r4_routes) 282 | HostConfiguration(net.get('a'),'a',1) 283 | HostConfiguration(net.get('b'),'b',4) 284 | HostConfiguration(net.get('c'),'c',3) 285 | 286 | 287 | # RouterConfiguration.build_dx4_tunnel(r1,r3,"a") 288 | # RouterConfiguration.build_dx4_tunnel(r3,r4,"b") 289 | # RouterConfiguration.build_dx4_tunnel(r1,r4,"c") 290 | 291 | # RouterConfiguration.build_dx6_tunnel(r1,r3,"a1") 292 | # RouterConfiguration.build_dx6_tunnel(r3,r4,"b1") 293 | # RouterConfiguration.build_dx6_tunnel(r1,r4,"c1") 294 | 295 | IPCLI(net) 296 | finally: 297 | net.stop() 298 | -------------------------------------------------------------------------------- /topo2.py: -------------------------------------------------------------------------------- 1 | from mininet.log import lg 2 | 3 | import ipmininet 4 | from ipmininet.cli import IPCLI 5 | from ipmininet.ipnet import IPNet 6 | from ipmininet.iptopo import IPTopo 7 | from ipmininet.router.config import StaticRoute 8 | from ipmininet.router.config.base import RouterConfig 9 | from ipmininet.router.config.zebra import Zebra 10 | 11 | """ 12 | fw 13 | | 14 | a ---- r1 ---- r2 ---- r3 ---- c 15 | | + | 16 | ------- r4 ------ 17 | + 18 | b 19 | 20 | """ 21 | 22 | # R1 R3 R4 are Segment Routing Enabled Server. 23 | # FW is R5 24 | 25 | ipv6_address={ 26 | 1:"2001:1a::/64", 27 | 3:"2001:3c::/64", 28 | 4:"2001:4b::/64" 29 | } 30 | ipv4_address={ 31 | 1:"10.0.0.0/24", 32 | 3:"10.0.1.0/24", 33 | 4:"10.0.2.0/24" 34 | } 35 | 36 | ipv4_gw={ 37 | 1:"10.0.0.1", 38 | 3:"10.0.1.1", 39 | 4:"10.0.2.1" 40 | } 41 | 42 | 43 | 44 | 45 | class SimpleTopo(IPTopo): 46 | 47 | def build(self, *args, **kwargs): 48 | """ 49 | """ 50 | r1_routes = [StaticRoute("fc00:4::/64", "2001:14::2"),StaticRoute("::/0", "2001:12::2")] 51 | r3_routes = [StaticRoute("fc00:4::/64", "2001:34::2"),StaticRoute("fc00:5::/64", "2001:35::2"),StaticRoute("::/0", "2001:23::1")] 52 | r4_routes = [StaticRoute("fc00:1::/64", "2001:14::1"),StaticRoute("fc00:3::/64", "2001:34::1"), 53 | StaticRoute("::/0", "2001:24::1")] 54 | r2_routes = [StaticRoute("fc00:1::/64", "2001:12::1"), 55 | StaticRoute("fc00:3::/64", "2001:23::2"), 56 | StaticRoute("fc00:4::/64", "2001:24::2")] 57 | 58 | fw_routes = [StaticRoute("::/0","2001:35::1")] 59 | 60 | r1 = self.addRouter_v('r1', r1_routes) 61 | r3 = self.addRouter_v('r3', r3_routes) 62 | r4 = self.addRouter_v('r4', r4_routes) 63 | fw = self.addRouter_v('fw', fw_routes) 64 | 65 | 66 | r2 = self.addRouter_v6('r2', r2_routes) # Pure IPv6 Router 67 | 68 | a_routes = [StaticRoute("0.0.0.0/0", "10.0.0.2"),StaticRoute("::/0", "2001:1a::1/64")] 69 | b_routes = [StaticRoute("0.0.0.0/0", "10.0.2.2"),StaticRoute("::/0", "2001:4b::1/64")] 70 | c_routes = [StaticRoute("0.0.0.0/0", "10.0.1.2"),StaticRoute("::/0", "2001:3c::1/64")] 71 | 72 | 73 | a = self.addRouter_v('a',a_routes) 74 | b = self.addRouter_v('b',b_routes) 75 | c = self.addRouter_v('c',c_routes) 76 | 77 | # Links between Routers 78 | 79 | self.addLink(r1, r2, params1={"ip": "2001:12::1/64"}, 80 | params2={"ip": "2001:12::2/64"}) 81 | self.addLink(r2, r3, params1={"ip": "2001:23::1/64"}, 82 | params2={"ip": "2001:23::2/64"}) 83 | self.addLink(r2, r4, params1={"ip": "2001:24::1/64"}, 84 | params2={"ip": "2001:24::2/64"}) 85 | 86 | self.addLink(r1, r4, params1={"ip": "2001:14::1/64"}, 87 | params2={"ip": "2001:14::2/64"}) 88 | self.addLink(r3, r4, params1={"ip": "2001:34::1/64"}, 89 | params2={"ip": "2001:34::2/64"}) 90 | 91 | 92 | # Links between Router and Hosts (IPv4) 93 | 94 | self.addLink(r1, a, 95 | params1={"ip": "10.0.0.2/24"}, 96 | params2={"ip": "10.0.0.1/24"}) 97 | self.addLink(r4, b, 98 | params1={"ip": "10.0.2.2/24"}, 99 | params2={"ip": "10.0.2.1/24"}) 100 | self.addLink(r3, c, 101 | params1={"ip": "10.0.1.2/24"}, 102 | params2={"ip": "10.0.1.1/24"}) 103 | 104 | # Links between Router and Hosts (IPv6) 105 | self.addLink(r1, a, 106 | params1={"ip": "2001:1a::1/64"}, 107 | params2={"ip": "2001:1a::2/64"}) 108 | self.addLink(r4, b, 109 | params1={"ip": "2001:4b::1/64"}, 110 | params2={"ip": "2001:4b::2/64"}) 111 | self.addLink(r3, c, 112 | params1={"ip": "2001:3c::1/64"}, 113 | params2={"ip": "2001:3c::2/64"}) 114 | 115 | self.addLink(r3, fw, 116 | params1={"ip": "2001:35::1/64"}, 117 | params2={"ip": "2001:35::2/64"}) 118 | 119 | 120 | super(SimpleTopo, self).build(*args, **kwargs) 121 | 122 | def addRouter_v6(self, name, staticRoutes): 123 | return self.addRouter(name, use_v4=False, use_v6=True, config=(RouterConfig, {'daemons': [(Zebra, {"static_routes": staticRoutes})]})) 124 | 125 | def addRouter_v(self, name, staticRoutes): 126 | return self.addRouter(name, use_v4=True, use_v6=True, config=(RouterConfig, {'daemons': [(Zebra, {"static_routes": staticRoutes})]})) 127 | 128 | class RouterConfiguration(object): 129 | def __init__(self,host,host_num): 130 | self.host=host 131 | self.host_num=host_num 132 | self.configure() 133 | 134 | def exec_cmd(self,cmd): 135 | if type(cmd)==list: 136 | for c in cmd: 137 | print(c) 138 | self.host.cmd(c) 139 | return None 140 | else: 141 | print(cmd) 142 | result = self.host.cmd(cmd) 143 | return result 144 | 145 | def configure(self): 146 | # Config IPv6 Loopback address first. 147 | self.exec_cmd("ip -6 addr add fc00:{0}::{0}/64 dev lo".format(self.host_num)) 148 | self.host_loc="fc00:{}::".format(self.host_num) 149 | # Get all the interface 150 | intf_list = [i.strip().strip(":") for i in self.exec_cmd("ifconfig -a | sed 's/[ \t].*//;/^$/d'").split('\r\n')] 151 | print(intf_list) 152 | # Config Systemctl 153 | cmds = ["sysctl -w net.ipv6.conf.{}.seg6_enabled=1".format(i) for i in intf_list] 154 | self.exec_cmd(cmds) 155 | # Config SR addr 156 | self.exec_cmd("ip sr tunsrc set fc00:{0}::{0}".format(self.host_num)) 157 | 158 | @staticmethod 159 | def build_dx4_tunnel(host1,host2,id,segs_12=None,segs_21=None): 160 | """ 161 | This function is used to build a DX4 Tunnel with optional TE 162 | """ 163 | # In order to build a End.DX4 Tunnel, we need lots of Info 164 | # First build the commands 165 | seg_list_12 = "" 166 | seg_list_21 = "" 167 | 168 | if segs_12: 169 | for host in segs_12: 170 | segtag = SegmentHost(host,id).segid 171 | seg_list_12=seg_list_12 + segtag + "," 172 | if segs_21: 173 | for host in segs_21: 174 | segtag = SegmentHost(host,id).segid 175 | seg_list_21=seg_list_21 + segtag + "," 176 | 177 | 178 | 179 | cmd_h1 = ["ip -6 route add {}{}/128 encap seg6local action End.DX4 nh4 {} dev r{}-eth1" 180 | .format(host1.host_loc,id,ipv4_gw[host1.host_num],host1.host_num), 181 | "ip route add {} encap seg6 mode encap segs {}{}{} dev r{}-eth1" 182 | .format(ipv4_address[host2.host_num],seg_list_12,host2.host_loc,id,host1.host_num)] 183 | 184 | cmd_h2 = ["ip -6 route add {}{}/128 encap seg6local action End.DX4 nh4 {} dev r{}-eth1" 185 | .format(host2.host_loc,id,ipv4_gw[host2.host_num],host2.host_num), 186 | "ip route add {} encap seg6 mode encap segs {}{}{} dev r{}-eth1" 187 | .format(ipv4_address[host1.host_num],seg_list_21,host1.host_loc,id,host2.host_num)] 188 | host1.exec_cmd(cmd_h1) 189 | host2.exec_cmd(cmd_h2) 190 | 191 | @staticmethod 192 | def build_dx6_tunnel(host1,host2,id,segs_12=None,segs_21=None): 193 | """ 194 | This function is used to build a DX6 Tunnel with optional TE 195 | """ 196 | # In order to build a End.DX4 Tunnel, we need lots of Info 197 | # First build the commands 198 | 199 | seg_list_12 = "" 200 | seg_list_21 = "" 201 | 202 | if segs_12: 203 | for host in segs_12: 204 | segtag = SegmentHost(host,id).segid 205 | seg_list_12=seg_list_12 + segtag + "," 206 | if segs_21: 207 | for host in segs_21: 208 | segtag = SegmentHost(host,id).segid 209 | seg_list_21=seg_list_21 + segtag + "," 210 | 211 | 212 | cmd_h1 = ["ip -6 route add {}{}/128 encap seg6local action End.DX6 nh6 :: dev r{}-eth1" 213 | .format(host1.host_loc,id,host1.host_num), 214 | "ip -6 route add {} encap seg6 mode encap segs {}{}{} dev r{}-eth1" 215 | .format(ipv6_address[host2.host_num],seg_list_12,host2.host_loc,id,host1.host_num)] 216 | 217 | cmd_h2 = ["ip -6 route add {}{}/128 encap seg6local action End.DX6 nh6 :: dev r{}-eth1" 218 | .format(host2.host_loc,id,host2.host_num), 219 | "ip route add {} encap seg6 mode encap segs {}{}{} dev r{}-eth1" 220 | .format(ipv6_address[host1.host_num],seg_list_21,host1.host_loc,id,host2.host_num)] 221 | host1.exec_cmd(cmd_h1) 222 | host2.exec_cmd(cmd_h2) 223 | 224 | class HostConfiguration(object): 225 | def __init__(self,host,host_name,host_num): 226 | self.host=host 227 | self.host_num=host_num 228 | self.host_name = host_name 229 | self.configure() 230 | 231 | def exec_cmd(self,cmd): 232 | if type(cmd)==list: 233 | for c in cmd: 234 | print(c) 235 | self.host.cmd(c) 236 | return None 237 | else: 238 | print(cmd) 239 | result = self.host.cmd(cmd) 240 | return result 241 | 242 | def configure(self): 243 | # Config IPv6 Default route. 244 | self.exec_cmd("ip -6 route add default via 2001:{}{}::1".format(self.host_num,self.host_name)) 245 | 246 | 247 | 248 | class SegmentHost(object): 249 | def __init__(self,host,id): 250 | self.host=host 251 | self.id=id 252 | self.segid = "fc00:{}::{}".format(self.host.host_num,self.id) 253 | self.configure() 254 | 255 | def configure(self): 256 | # Configure the End Point host. 257 | cmd= "ip -6 route add {}/128 encap seg6local action End dev r{}-eth0".format(self.segid,self.host.host_num) 258 | self.host.exec_cmd(cmd) 259 | 260 | 261 | if __name__ == '__main__': 262 | ipmininet.DEBUG_FLAG = True 263 | lg.setLogLevel("info") 264 | 265 | # Start network 266 | net = IPNet(topo=SimpleTopo(), use_v4=True, allocate_IPs=False) 267 | 268 | try: 269 | net.start() 270 | # Execute Commands 271 | 272 | # Enable SRv6 On Routers. 273 | r1 = RouterConfiguration(net.get('r1'),1) 274 | r2 = RouterConfiguration(net.get('r2'),2) 275 | r3 = RouterConfiguration(net.get('r3'),3) 276 | r4 = RouterConfiguration(net.get('r4'),4) 277 | fw = RouterConfiguration(net.get('fw'),5) 278 | 279 | HostConfiguration(net.get('a'),'a',1) 280 | HostConfiguration(net.get('b'),'b',4) 281 | HostConfiguration(net.get('c'),'c',3) 282 | 283 | 284 | # RouterConfiguration.build_dx4_tunnel(r1,r3,"a") 285 | # RouterConfiguration.build_dx4_tunnel(r3,r4,"b") 286 | # RouterConfiguration.build_dx4_tunnel(r1,r4,"c") 287 | 288 | # RouterConfiguration.build_dx6_tunnel(r1,r3,"a1") 289 | # RouterConfiguration.build_dx6_tunnel(r3,r4,"b1") 290 | # RouterConfiguration.build_dx6_tunnel(r1,r4,"c1") 291 | 292 | IPCLI(net) 293 | finally: 294 | net.stop() 295 | -------------------------------------------------------------------------------- /topo2_new.py: -------------------------------------------------------------------------------- 1 | from mininet.log import lg 2 | 3 | import ipmininet 4 | from ipmininet.cli import IPCLI 5 | from ipmininet.ipnet import IPNet 6 | from ipmininet.iptopo import IPTopo 7 | from ipmininet.router.config import StaticRoute 8 | from ipmininet.router.config.base import RouterConfig 9 | from ipmininet.router.config.zebra import Zebra 10 | 11 | """ 12 | ids 13 | | 14 | a ---- r1 ---- r2 ---- r3 ---- c 15 | | + | 16 | ------- r4 ------ 17 | + 18 | b 19 | 20 | """ 21 | 22 | # R1 R3 R4 are Segment Routing Enabled Server. 23 | # IDS is R5 24 | 25 | ipv6_address={ 26 | 1:"2001:1a::/64", 27 | 3:"2001:3c::/64", 28 | 4:"2001:4b::/64" 29 | } 30 | ipv4_address={ 31 | 1:"10.0.0.0/24", 32 | 3:"10.0.1.0/24", 33 | 4:"10.0.2.0/24" 34 | } 35 | 36 | ipv4_gw={ 37 | 1:"10.0.0.1", 38 | 3:"10.0.1.1", 39 | 4:"10.0.2.1" 40 | } 41 | r1_routes = [StaticRoute("fc00:4::/64", "2001:14::2"),StaticRoute("::/0", "2001:12::2")] 42 | r3_routes = [StaticRoute("fc00:4::/64", "2001:34::2"),StaticRoute("fc00:5::/64", "2001:35::2"),StaticRoute("::/0", "2001:23::1")] 43 | r4_routes = [StaticRoute("fc00:1::/64", "2001:14::1"),StaticRoute("fc00:3::/64", "2001:34::1"), 44 | StaticRoute("::/0", "2001:24::1")] 45 | r2_routes = [StaticRoute("fc00:1::/64", "2001:12::1"), 46 | StaticRoute("fc00:3::/64", "2001:23::2"), 47 | StaticRoute("fc00:4::/64", "2001:24::2"), 48 | StaticRoute("fc00:5::/64", "2001:23::2"), 49 | ] 50 | 51 | ids_routes = [StaticRoute("::/0","2001:35::1")] 52 | 53 | a_routes = [StaticRoute("::/0", "2001:1a::1/64")] 54 | b_routes = [StaticRoute("::/0", "2001:4b::1/64")] 55 | c_routes = [StaticRoute("::/0", "2001:3c::1/64")] 56 | 57 | 58 | 59 | class SimpleTopo(IPTopo): 60 | 61 | def build(self, *args, **kwargs): 62 | """ 63 | """ 64 | 65 | r1 = self.addRouter_v('r1', r1_routes) 66 | r3 = self.addRouter_v('r3', r3_routes) 67 | r4 = self.addRouter_v('r4', r4_routes) 68 | ids = self.addRouter_v('ids', ids_routes) 69 | 70 | 71 | r2 = self.addRouter_v6('r2', r2_routes) # Pure IPv6 Router 72 | 73 | 74 | 75 | a = self.addHost('a',defaultRoute='via 10.0.0.2') 76 | b = self.addHost('b', defaultRoute='via 10.0.2.2') 77 | c = self.addHost('c', defaultRoute='via 10.0.1.2') 78 | 79 | # Links between Routers 80 | 81 | self.addLink(r1, r2, params1={"ip": "2001:12::1/64"}, 82 | params2={"ip": "2001:12::2/64"}) 83 | self.addLink(r2, r3, params1={"ip": "2001:23::1/64"}, 84 | params2={"ip": "2001:23::2/64"}) 85 | self.addLink(r2, r4, params1={"ip": "2001:24::1/64"}, 86 | params2={"ip": "2001:24::2/64"}) 87 | 88 | self.addLink(r1, r4, params1={"ip": "2001:14::1/64"}, 89 | params2={"ip": "2001:14::2/64"}) 90 | self.addLink(r3, r4, params1={"ip": "2001:34::1/64"}, 91 | params2={"ip": "2001:34::2/64"}) 92 | 93 | 94 | # Links between Router and Hosts (IPv4) 95 | 96 | self.addLink(r1, a, 97 | params1={"ip": "10.0.0.2/24"}, 98 | params2={"ip": "10.0.0.1/24"}) 99 | self.addLink(r4, b, 100 | params1={"ip": "10.0.2.2/24"}, 101 | params2={"ip": "10.0.2.1/24"}) 102 | self.addLink(r3, c, 103 | params1={"ip": "10.0.1.2/24"}, 104 | params2={"ip": "10.0.1.1/24"}) 105 | 106 | # Links between Router and Hosts (IPv6) 107 | self.addLink(r1, a, 108 | params1={"ip": "2001:1a::1/64"}, 109 | params2={"ip": "2001:1a::2/64"}) 110 | self.addLink(r4, b, 111 | params1={"ip": "2001:4b::1/64"}, 112 | params2={"ip": "2001:4b::2/64"}) 113 | self.addLink(r3, c, 114 | params1={"ip": "2001:3c::1/64"}, 115 | params2={"ip": "2001:3c::2/64"}) 116 | 117 | self.addLink(r3, ids, 118 | params1={"ip": "2001:35::1/64"}, 119 | params2={"ip": "2001:35::2/64"}) 120 | 121 | 122 | super(SimpleTopo, self).build(*args, **kwargs) 123 | 124 | def addRouter_v6(self, name, staticRoutes): 125 | return self.addRouter(name, use_v4=False, use_v6=True, config=(RouterConfig, {'daemons': [(Zebra, {"static_routes": staticRoutes})]})) 126 | 127 | def addRouter_v(self, name, staticRoutes): 128 | return self.addRouter(name, use_v4=True, use_v6=True, config=(RouterConfig, {'daemons': [(Zebra, {"static_routes": staticRoutes})]})) 129 | 130 | 131 | class RouterConfiguration(object): 132 | def __init__(self,host,host_num,routes,srv6=True): 133 | self.host=host 134 | self.host_num=host_num 135 | self.routes=routes 136 | self.srv6=srv6 137 | self.configure() 138 | 139 | def exec_cmd(self,cmd): 140 | if type(cmd)==list: 141 | for c in cmd: 142 | print(c) 143 | self.host.cmd(c) 144 | return None 145 | else: 146 | print(cmd) 147 | result = self.host.cmd(cmd) 148 | return result 149 | 150 | def configure(self): 151 | # Config IPv6 Loopback address first. 152 | self.exec_cmd("ip -6 addr add fc00:{0}::{0}/64 dev lo".format(self.host_num)) 153 | self.host_loc="fc00:{}::".format(self.host_num) 154 | # Get all the interface 155 | intf_list = [i.strip().strip(":") for i in self.exec_cmd("ifconfig -a | sed 's/[ \t].*//;/^$/d'").split('\r\n')] 156 | print(intf_list) 157 | 158 | # Config IPv6 Routes 159 | self.configure_static_route() 160 | 161 | # Config SR 162 | if self.srv6: 163 | # Config Systemctl 164 | cmds = ["sysctl -w net.ipv6.conf.{}.seg6_enabled=1".format(i) for i in intf_list] 165 | self.exec_cmd(cmds) 166 | self.exec_cmd("ip sr tunsrc set fc00:{0}::{0}".format(self.host_num)) 167 | 168 | def configure_static_route(self): 169 | print("Configuring Routes") 170 | for route in self.routes: 171 | self.exec_cmd("ip -6 route add {} via {}".format(route.prefix, route.nexthop)) 172 | 173 | 174 | @staticmethod 175 | def build_dx4_tunnel(host1,host2,id,segs_12=None,segs_21=None): 176 | """ 177 | This function is used to build a DX4 Tunnel with optional TE 178 | """ 179 | # In order to build a End.DX4 Tunnel, we need lots of Info 180 | # First build the commands 181 | seg_list_12 = "" 182 | seg_list_21 = "" 183 | 184 | if segs_12: 185 | for host in segs_12: 186 | segtag = SegmentHost(host,id).segid 187 | seg_list_12=seg_list_12 + segtag + "," 188 | if segs_21: 189 | for host in segs_21: 190 | segtag = SegmentHost(host,id).segid 191 | seg_list_21=seg_list_21 + segtag + "," 192 | 193 | 194 | 195 | cmd_h1 = ["ip -6 route add {}{}/128 encap seg6local action End.DX4 nh4 {} dev r{}-eth1" 196 | .format(host1.host_loc,id,ipv4_gw[host1.host_num],host1.host_num), 197 | "ip route add {} encap seg6 mode encap segs {}{}{} dev r{}-eth1" 198 | .format(ipv4_address[host2.host_num],seg_list_12,host2.host_loc,id,host1.host_num)] 199 | 200 | cmd_h2 = ["ip -6 route add {}{}/128 encap seg6local action End.DX4 nh4 {} dev r{}-eth1" 201 | .format(host2.host_loc,id,ipv4_gw[host2.host_num],host2.host_num), 202 | "ip route add {} encap seg6 mode encap segs {}{}{} dev r{}-eth1" 203 | .format(ipv4_address[host1.host_num],seg_list_21,host1.host_loc,id,host2.host_num)] 204 | host1.exec_cmd(cmd_h1) 205 | host2.exec_cmd(cmd_h2) 206 | 207 | @staticmethod 208 | def build_dx6_tunnel(host1,host2,id,segs_12=None,segs_21=None): 209 | """ 210 | This function is used to build a DX6 Tunnel with optional TE 211 | """ 212 | # In order to build a End.DX4 Tunnel, we need lots of Info 213 | # First build the commands 214 | 215 | seg_list_12 = "" 216 | seg_list_21 = "" 217 | 218 | if segs_12: 219 | for host in segs_12: 220 | segtag = SegmentHost(host,id).segid 221 | seg_list_12=seg_list_12 + segtag + "," 222 | if segs_21: 223 | for host in segs_21: 224 | segtag = SegmentHost(host,id).segid 225 | seg_list_21=seg_list_21 + segtag + "," 226 | 227 | 228 | cmd_h1 = ["ip -6 route add {}{}/128 encap seg6local action End.DX6 nh6 :: dev r{}-eth1" 229 | .format(host1.host_loc,id,host1.host_num), 230 | "ip -6 route add {} encap seg6 mode encap segs {}{}{} dev r{}-eth1" 231 | .format(ipv6_address[host2.host_num],seg_list_12,host2.host_loc,id,host1.host_num)] 232 | 233 | cmd_h2 = ["ip -6 route add {}{}/128 encap seg6local action End.DX6 nh6 :: dev r{}-eth1" 234 | .format(host2.host_loc,id,host2.host_num), 235 | "ip route add {} encap seg6 mode encap segs {}{}{} dev r{}-eth1" 236 | .format(ipv6_address[host1.host_num],seg_list_21,host1.host_loc,id,host2.host_num)] 237 | host1.exec_cmd(cmd_h1) 238 | host2.exec_cmd(cmd_h2) 239 | 240 | 241 | class HostConfiguration(object): 242 | def __init__(self,host,host_name,host_num): 243 | self.host=host 244 | self.host_num=host_num 245 | self.host_name = host_name 246 | self.configure() 247 | 248 | def exec_cmd(self,cmd): 249 | if type(cmd)==list: 250 | for c in cmd: 251 | print(c) 252 | self.host.cmd(c) 253 | return None 254 | else: 255 | print(cmd) 256 | result = self.host.cmd(cmd) 257 | return result 258 | 259 | def configure(self): 260 | # Config IPv6 Default route. 261 | self.exec_cmd("ip -6 route add default via 2001:{}{}::1".format(self.host_num,self.host_name)) 262 | 263 | 264 | 265 | class SegmentHost(object): 266 | def __init__(self,host,id): 267 | self.host=host 268 | self.id=id 269 | self.segid = "fc00:{}::{}".format(self.host.host_num,self.id) 270 | self.configure() 271 | 272 | def configure(self): 273 | # Configure the End Point host. 274 | cmd= "ip -6 route add {}/128 encap seg6local action End dev r{}-eth0".format(self.segid,self.host.host_num) 275 | self.host.exec_cmd(cmd) 276 | 277 | 278 | if __name__ == '__main__': 279 | ipmininet.DEBUG_FLAG = True 280 | lg.setLogLevel("info") 281 | 282 | # Start network 283 | net = IPNet(topo=SimpleTopo(), use_v4=True, allocate_IPs=False) 284 | 285 | try: 286 | net.start() 287 | # Execute Commands 288 | 289 | # Enable SRv6 On Routers. 290 | r1 = RouterConfiguration(net.get('r1'),1,r1_routes) 291 | r2 = RouterConfiguration(net.get('r2'),2,r2_routes) 292 | r3 = RouterConfiguration(net.get('r3'),3,r3_routes) 293 | r4 = RouterConfiguration(net.get('r4'),4,r4_routes,False) 294 | ids = RouterConfiguration(net.get('ids'),5,ids_routes) 295 | 296 | HostConfiguration(net.get('a'),'a',1) 297 | HostConfiguration(net.get('b'),'b',4) 298 | HostConfiguration(net.get('c'),'c',3) 299 | 300 | 301 | # RouterConfiguration.build_dx4_tunnel(r1,r3,"a") 302 | # RouterConfiguration.build_dx4_tunnel(r3,r4,"b") 303 | # RouterConfiguration.build_dx4_tunnel(r1,r4,"c") 304 | 305 | # RouterConfiguration.build_dx6_tunnel(r1,r3,"a1") 306 | # RouterConfiguration.build_dx6_tunnel(r3,r4,"b1") 307 | # RouterConfiguration.build_dx6_tunnel(r1,r4,"c1") 308 | 309 | IPCLI(net) 310 | finally: 311 | net.stop() 312 | --------------------------------------------------------------------------------