Instructions
- Create two network namespaces
ip netns add ns0
ip netns add ns1
- Assign interfaces to namespaces
ip link set enp23s0 netns ns0
ip link set enp101s0 netns ns1
- Enter network namespace(s), assign IPs and create a default route if desired
ip netns exec ns0 bash # Drops into a subshell, in the context of network namespace ns0
ip a a 10.1.1.1/24 dev enp23s0
ip link set up enp23s0 # Bring up the interface (will be brought down when moved into the namespace)
exit # Don't forget to exit the subshell before moving on
- Repeat step 3 for the remaining interfaces/namespaces:
ip netns exec ns1 ip a a 10.1.1.2/24 dev enp101s0 # Can execute single commands at a time for a given namespace
ip netns exec ns1 ip link set up enp101s0
- In the context of either namespace, send traffic between interfaces and verify using an external device/libexanic that traffic really is being physically sent/received on each interface.
ip netns exec ns0 ping 10.1.1.2
ip netns exec ns0 exanic-capture -i exanic0:0 -w - | tcpdump -r -
reading from file -, link-type EN10MB (Ethernet)
14:58:12.358488 IP 10.1.1.2 > 10.1.1.1: ICMP echo reply, id 27967, seq 1, length 64
14:58:13.357655 IP 10.1.1.2 > 10.1.1.1: ICMP echo reply, id 27967, seq 2, length 64
14:58:14.357654 IP 10.1.1.2 > 10.1.1.1: ICMP echo reply, id 27967, seq 3, length 64