no tech support as those in ecs360. use at your own risk you need a (minimized) ubuntu server (no desktop/gui needed) virtual machine or docker container
Code: Select all
# delete h1 h2 r if any
ip netns del h1
ip netns del h2
ip netns del r
# create linux network namespaces (netns)
ip netns add h1
ip netns add h2
ip netns add r
# see the created namespaces
ip netns
# create virtual ethernet (veth) links
ip link add h1-eth0 type veth peer name r-eth0
ip link add h2-eth0 type veth peer name r-eth1
# see the created virtual links
ip link
# set each link in its network namespace
ip link set h1-eth0 netns h1
ip link set h2-eth0 netns h2
ip link set r-eth0 netns r
ip link set r-eth1 netns r
# configure each network interface with ip address by running ip address (a) in their namespace (netns exec)
ip netns exec h1 ip a add 192.168.1.100/24 dev h1-eth0
ip netns exec r ip a add 192.168.1.1/24 dev r-eth0
ip netns exec r ip a add 10.10.1.1/24 dev r-eth1
ip netns exec h2 ip a add 10.10.1.100/24 dev h2-eth0
# bring up each configured interface by ip link
ip netns exec h1 ip link set h1-eth0 up
ip netns exec r ip link set r-eth0 up
ip netns exec r ip link set r-eth1 up
ip netns exec h2 ip link set h2-eth0 up
# test each link for connectivity
ip netns exec h1 ping -c 5 192.168.1.1
ip netns exec h2 ping -c 5 10.10.1.1
# set routing on h1 and h2 properly by ip route
ip netns exec h1 ip route add default via 192.168.1.1
ip netns exec h2 ip route add default via 10.10.1.1
# test the entire path for connectivity
ip netns exec h1 ping -c 5 10.10.1.100
# traceroute the entire path
ip netns exec h1 traceroute -n 10.10.1.100
make sure /proc/sys/net/ipv4/ip_forward is set to 1, so r can invoke forwarding after the routing decision