Commit 97aed358 authored by Binh Nguyen's avatar Binh Nguyen

Basic SR set up with 4 nodes

parents
This folder includes scripts to set up a basic topology and do Segment Routing between 2 nodes.
----------------------------------------------------------------------------------------------
1. Topology in PhantomNet (or CloudLab): name "sripv6"
https://www.phantomnet.org/show-profile.php?uuid=1a298a72-22fc-11e7-91c5-90e2ba22fee4
2. How to run:
- Change the file net_info.sh manually to include the correct IPV6, MAC address, and device name for all of the nodes in the topology. This information is used to install routes on the node for SR.
- Install globally routable IPV6 addresses for interfaces on the nodes: ./add_global_ipv6.sh
- Install the "uplink" path (from node1 to node4's netd): ./install_uplink_path.sh
- Install the "downlink" returning path (from node4's netc directly to node1's netc): ./install_downlink_path.sh
3. Caviats:
- As the "downlink" uses a different interface (netc) instead of the incomming interface (netd), ONLY stateless connections work (eg, ICMP, UDP). Iperf won't work because it uses stateful TCP connections.
#!/bin/bash
source net_info.sh
SSH_SD="ssh -t -t"
DOMAIN=$(hostname | awk -F'.' '{print $2"."$3"."$4"."$5}')
#----------node1---------
echo "Add IPv6 addresses on node 1"
$SSH_SD "node1.$DOMAIN" "sudo ip -6 addr add $n1_a dev $n1_a_dev"
$SSH_SD "node1.$DOMAIN" "sudo ip -6 addr add $n1_c dev $n1_c_dev"
#----------node2---------
echo "Add IPv6 addresses on node 2"
$SSH_SD "node2.$DOMAIN" "sudo ip -6 addr add $n2_a dev $n2_a_dev"
$SSH_SD "node2.$DOMAIN" "sudo ip -6 addr add $n2_b dev $n2_b_dev"
#----------node3---------
echo "Add IPv6 addresses on node 3"
$SSH_SD "node3.$DOMAIN" "sudo ip -6 addr add $n3_b dev $n3_b_dev"
$SSH_SD "node3.$DOMAIN" "sudo ip -6 addr add $n3_d dev $n3_d_dev"
#----------node4---------
echo "Add IPv6 addresses on node 4"
$SSH_SD "node4.$DOMAIN" "sudo ip -6 addr add $n4_d dev $n4_d_dev"
$SSH_SD "node4.$DOMAIN" "sudo ip -6 addr add $n4_c dev $n4_c_dev"
#!/bin/bash
source net_info.sh
SSH_SD="ssh -t -t"
#Node name for SSH
DOMAIN=$(hostname | awk -F'.' '{print $2"."$3"."$4"."$5}')
SRC_NODE="node1.$DOMAIN"
MID_NODES=("node2.$DOMAIN")
EGRESS_NODE="node3.$DOMAIN"
DST_NODE="node4.$DOMAIN"
#IP and interfaces
SRC_IP=$n1_a
SRC_MAC=$n1_c_mac
DST_DEV=$n4_c_dev #going back on node4's netc.
#----------dst node-----------------
echo ""
echo "Install rules on destination node for returning path $DST_NODE"
echo "--------------------------------------"
#ip route to node 4:
$SSH_SD $DST_NODE "sudo ip -6 route add $SRC_IP/128 dev $DST_DEV"
#arp to node 4 via node 2:
$SSH_SD $DST_NODE "sudo ip -6 neigh add $SRC_IP lladdr $SRC_MAC dev $DST_DEV"
#!/bin/bash
source net_info.sh
SSH_SD="ssh -t -t"
#Node name for SSH
DOMAIN=$(hostname | awk -F'.' '{print $2"."$3"."$4"."$5}')
SRC_NODE="node1.$DOMAIN"
MID_NODES=("node2.$DOMAIN")
EGRESS_NODE="node3.$DOMAIN"
#IP and interfaces
SRC_IP=$n1_a
SRC_MAC=$n1_a_mac
SRC_DEV=$n1_a_dev
DST_IP=$n4_d
DST_MAC=$n4_d_mac
DST_DEV=$n4_d_dev
#segments
MID_SEGS="$n3_b" #via this node(s).
MID_SEG_MACS=($n3_b_mac)
MID_SEG_DEVS=($n2_b_dev)
MID_NODE_SRH_INFS=($n3_b_dev)
#egress DEV (to destination)
EGRESS_DEV=$n3_d_dev
#egress DEV (receiving)
EGRESS_DEV_IN=$n3_b_dev
#----------node1-----------------
echo ""
echo "Install rules on source node $SRC_NODE"
echo "--------------------------------------"
#ip route to node 4:
$SSH_SD $SRC_NODE "sudo ip -6 route add $DST_IP/128 dev $SRC_DEV"
#arp to node 4 via node 2:
$SSH_SD $SRC_NODE "sudo ip -6 neigh add $DST_IP lladdr $n2_a_mac dev $SRC_DEV"
#----------node2 (ingress)-------------
echo ""
echo "Install rules on middle nodes $MID_NODES"
echo "--------------------------------------"
#enable IPV6 forwarding
$SSH_SD ${MID_NODES[0]} "sudo sysctl net.ipv6.conf.all.forwarding=1"
#enable SRH processing flag on node
$SSH_SD ${MID_NODES[0]} "sudo sysctl net.ipv6.conf.all.seg6_enabled=1"
#enable SRH processing flag on interface
$SSH_SD ${MID_NODES[0]} "sudo sysctl net.ipv6.conf.${MID_NODE_SRH_INFS[0]}.seg6_enabled=1"
#ip forwarding for pkts to DST_IP
$SSH_SD ${MID_NODES[0]} "sudo ip -6 route add $DST_IP/128 dev ${MID_SEG_DEVS[0]} encap seg6 mode encap segs $MID_SEGS"
#arp for DST_IP
$SSH_SD ${MID_NODES[0]} "sudo ip -6 neigh add $DST_IP lladdr ${MID_SEG_MACS[0]} dev ${MID_SEG_DEVS[0]}"
#ip forwarding for pkts to next-hop (encapsulated pkt's destination)
$SSH_SD ${MID_NODES[0]} "sudo ip -6 route add ${MID_SEGS[0]}/128 dev ${MID_SEG_DEVS[0]}"
#--------node3 (egress)--------------
echo ""
echo "Install rules on egress node $EGRESS_NODE"
echo "--------------------------------------"
#enable IPV6 forwarding
$SSH_SD $EGRESS_NODE "sudo sysctl net.ipv6.conf.all.forwarding=1"
#enable SRH processing flag on node
$SSH_SD $EGRESS_NODE "sudo sysctl net.ipv6.conf.all.seg6_enabled=1"
#enable SRH processing flag on interface
$SSH_SD $EGRESS_NODE "sudo sysctl net.ipv6.conf.$EGRESS_DEV_IN.seg6_enabled=1"
#ip forwarding for pkts to DST_IP.
$SSH_SD $EGRESS_NODE "sudo ip -6 route add $DST_IP/128 dev $EGRESS_DEV"
#arp for DST_IP
$SSH_SD $EGRESS_NODE "sudo ip -6 neigh add $DST_IP lladdr $DST_MAC dev $EGRESS_DEV"
iproute2 @ 7e9d2e13
Subproject commit 7e9d2e1307ae0e8799b097932c773b779aeb123c
#!/bin/bash
#IPv6 and MAC
#node1
n1_a="2001::204:23ff:feb7:23a0"
n1_a_mac="00:04:23:b7:23:a0"
n1_a_dev="enp9s4f0"
n1_c="2001::204:23ff:feb7:23a1"
n1_c_mac="00:04:23:b7:23:a1"
n1_c_dev="enp9s4f1"
#node2
n2_a="2001::204:23ff:feb7:2046"
n2_a_mac="00:04:23:b7:20:46"
n2_a_dev="enp9s4f0"
n2_b="2001::204:23ff:feb7:23a1"
n2_b_mac="00:04:23:b7:23:a1"
n2_b_dev="enp9s4f1"
#node3
n3_b="2001::204:23ff:feb7:176c"
n3_b_mac="00:04:23:b7:17:6c"
n3_b_dev="enp9s4f0"
n3_d="2001::204:23ff:feb7:176d"
n3_d_mac="00:04:23:b7:17:6d"
n3_d_dev="enp9s4f1"
#node4
n4_c="2001::204:23ff:feb7:1df4"
n4_c_mac="00:04:23:b7:1d:f4"
n4_c_dev="enp9s4f0"
n4_d="2001::204:23ff:feb7:1df5"
n4_d_mac="00:04:23:b7:1d:f5"
n4_d_dev="enp9s4f1"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment