Skip to content
Snippets Groups Projects
Verified Commit afea3f75 authored by iliya.saroukha's avatar iliya.saroukha :first_quarter_moon:
Browse files

feat: finished part about multiple virtual routers

parent 5411d19a
No related branches found
No related tags found
No related merge requests found
......@@ -192,7 +192,7 @@ ssh H1 ip route add default via 10.0.0.2
![TTL du paquet via R2](./figs/h1_ping_with_bridge.png)
![TTL du paquet avec configuration initiale (i.e. R1 sans namespace)](./figs/h1_ping_without_bridge.png)
![TTL du paquet avec configuration initiale (i.e. R1 sans namespace)](./figs/h1_ping_without_bridge.png){#fig-ping-baseline}
Comme nous pouvons le remarquer sur les deux captures d'écrans précédentes, le
TTL ne change pas entre la baseline (i.e. topologie avec R1 sans namespace) et
......@@ -202,3 +202,106 @@ l'existence de R1 par celle de R2, donc le paquet traversera le même nombre
de routeurs que si le namespace n'existait pas.
# Instanciation de plusieurs routeurs virtuels sur R1
### Script `bash`
```{bash}
#!/usr/bin/env bash
echo "======= R1: Creating ns2 and ns3 namespaces ======="
ssh R1 ip netns add ns2
ssh R1 ip netns add ns3
echo "======= R2: Activating IP forwarding ======="
ssh R1 ip netns exec ns2 sysctl net.ipv4.ip_forward=1
echo "======= R3: Activating IP forwarding ======="
ssh R1 ip netns exec ns3 sysctl net.ipv4.ip_forward=1
echo "======= R1: Creating veth pair (for default-veth1 and ns3-veth1) for ns-default and ns3 ======="
ssh R1 ip link add default-veth1 type veth peer name ns3-veth1 netns ns3
echo "======= R1: Creating veth pair (for ns3-veth0 and ns2-veth1) for ns3 and ns2 ======="
ssh R1 ip link add ns3-veth0 type veth peer name ns2-veth1 netns ns2
ssh R1 ip link set ns3-veth0 netns ns3
echo "======= R1: Creating veth pair (for default-veth0 and ns3-veth0) for ns-default and ns2 ======="
ssh R1 ip link add default-veth0 type veth peer name ns2-veth0 netns ns2
echo "======= R1: Creating and upping br1 bridge ======="
ssh R1 ip link add name br1 type bridge
ssh R1 ip link set dev br1 up
echo "======= R1: Connecting and upping default-veth1 to br1 ======="
ssh R1 ip link set default-veth1 master br1
ssh R1 ip link set dev default-veth1 up
echo "======= R1: Connecting and upping eth1 to br1 ======="
ssh R1 ip link set eth1 master br1
ssh R1 ip link set dev eth1 up
echo "======= R1: Creating and upping br0 bridge ======="
ssh R1 ip link add name br0 type bridge
ssh R1 ip link set dev br0 up
echo "======= R1: Connecting and upping default-veth0 to br0 ======="
ssh R1 ip link set default-veth0 master br0
ssh R1 ip link set dev default-veth0 up
echo "======= R1: Connecting and upping eth0 to br0 ======="
ssh R1 ip link set eth0 master br0
ssh R1 ip link set dev eth0 up
echo "======= R3: Upping the veths in ns3 ======="
ssh R1 ip netns exec ns3 ip link set dev ns3-veth0 up
ssh R1 ip netns exec ns3 ip link set dev ns3-veth1 up
echo "======= R2: Upping the veths in ns2 ======="
ssh R1 ip netns exec ns2 ip link set dev ns2-veth0 up
ssh R1 ip netns exec ns2 ip link set dev ns2-veth1 up
echo "======= R2: Obtaining IP for ns2-veth0 via DHCP ======="
ssh R1 ip netns exec ns2 dhclient -v ns2-veth0
echo "======= R3: Configuring static 10.0.0.2 IP for ns3-veth1 ======="
ssh R1 ip netns exec ns3 ip addr add 10.0.0.2/24 dev ns3-veth1
echo "======= R3: Configuring static 192.168.0.1 IP for ns3-veth0 ======="
ssh R1 ip netns exec ns3 ip addr add 192.168.0.1/24 dev ns3-veth0
echo "======= R2: Configuring static 192.168.0.2 IP for ns2-veth1 ======="
ssh R1 ip netns exec ns2 ip addr add 192.168.0.2/24 dev ns2-veth1
echo "======= R3: Setting up default route ======="
ssh R1 ip netns exec ns3 ip r add default via 192.168.0.2 dev ns3-veth0
echo "======= R2: Setting up route for 10.0.0.0/24 via 192.168.0.1 ======="
ssh R1 ip netns exec ns2 ip route add 10.0.0.0/24 via 192.168.0.1 dev ns2-veth1
echo "======= R2: Implementing NAT inside ns2 ======"
scp ./r2_nat.ruleset root@R1:/root
ssh R1 ip netns exec ns2 nft -f ./r2_nat.ruleset
echo "======= H1: Setting up static 10.0.0.1/24 IP for eth0 ======="
ssh H1 ip addr add 10.0.0.1/24 dev eth0
ssh H1 ip link set dev eth0 up
echo "======= H1: Setting default route via R1 (i.e. 10.0.0.2) ======="
ssh H1 ip route add default via 10.0.0.2
```
## Vérification
La capture d'écran ci-dessous, illustre le fait que le trafic passe initialement
par le R3 via l'ip 10.0.0.2/24 sur l'interface ns3-veth1, puis le second saut
arrive sur R2 via l'IP 192.168.0.2/24 sur l'interface ns2-veth1. Par conséquent,
l'implémentation des deux routeurs virtuels est fonctionnelle.
![`traceroute` depuis H1 démontrant le passage via R3 et R2](./figs/r3_r2_bridge_traceroute.png)
Au niveau du TTL lors d'un ping, l'image ci-dessous illustre le fait que
celui-ci fut décrémenté d'une valeur en plus (53 à présent) comparé à la @fig-ping-baseline
(_baseline_ de la topologie de la partie 1 du laboratoire) du fait que le ping
passe à présent par un routeur additionnel.
![TTL du paquet via R3 et R2](./figs/h1_ping_r3_r2.png)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment