As a part of an experiment, my network has the following topology for two host machines connected to a router in mininet(on Ubuntu 22.04.02 Virtual Machine)
h1 - r1 - r2 - h2
The host Machine 'h1' has the following configuration:
h1-eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.103 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::70e9:dfff:fe2c:6242 prefixlen 64 scopeid 0x20<link>
ether 72:e9:df:2c:62:42 txqueuelen 1000 (Ethernet)
RX packets 14 bytes 1076 (1.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14 bytes 1076 (1.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
The host Machine 'h2' has the following config:
h2-eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::f429:9fff:fe6a:5211 prefixlen 64 scopeid 0x20<link>
ether f6:29:9f:6a:52:11 txqueuelen 1000 (Ethernet)
RX packets 14 bytes 1076 (1.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14 bytes 1076 (1.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
The router r1 has the following config:
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
r1-eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::10dc:6cff:feb2:1688 prefixlen 64 scopeid 0x20<link>
ether 12:dc:6c:b2:16:88 txqueuelen 1000 (Ethernet)
RX packets 14 bytes 1076 (1.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14 bytes 1076 (1.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
r1-eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.1 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::8cd5:99ff:fedf:e2a8 prefixlen 64 scopeid 0x20<link>
ether 8e:d5:99:df:e2:a8 txqueuelen 1000 (Ethernet)
RX packets 14 bytes 1076 (1.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 15 bytes 1146 (1.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
The router r2 has the following configuration:
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
r2-eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::87d:6aff:fee9:477 prefixlen 64 scopeid 0x20<link>
ether 0a:7d:6a:e9:04:77 txqueuelen 1000 (Ethernet)
RX packets 21 bytes 1398 (1.3 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 15 bytes 1146 (1.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
r2-eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.2 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::cc40:70ff:fe31:f96d prefixlen 64 scopeid 0x20<link>
ether ce:40:70:31:f9:6d txqueuelen 1000 (Ethernet)
RX packets 15 bytes 1146 (1.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 15 bytes 1146 (1.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
I am trying to setup the experimental topology such that both the hosts can access each other, which of course, is possible through configuring routing tables
I have taken the following steps:
On the r1 terminal(xterm):
ifconfig r1-eth0 192.168.0.1 netmask 255.255.255.0
ifconfig r1-eth1 192.168.2.1 netmask 255.255.255.0
ip route add 192.168.0.0/24 dev r1-eth0
ip route add 192.168.1.0/24 via 192.168.2.2
On the r2 terminal(xterm):
ifconfig r2-eth0 192.168.1.1 netmask 255.255.255.0
ifconfig r2-eth1 192.168.2.2 netmask 255.255.255.0
ip route add 192.168.0.0/24 via 192.168.2.1
On the h1 terminal (xterm)
ifconfig h1-eth0 192.168.0.103 netmask 255.255.255.0
route add default gw 192.168.0.1
ip route add 192.168.1.0/24 via 192.168.0.1
ip route add 192.168.2.0/24 via 192.168.0.1
On the h2 terminal (xterm)
ifconfig h2-eth0 192.168.1.2 netmask 255.255.255.0
route add default gw 192.168.1.1
ip route add 192.168.0.0/24 via 192.168.1.1
ip route add 192.168.2.0/24 via 192.168.1.1
The updated routing tables for h1, h2, r1 and r2 are as follows:
h1 Routes:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.0.1 0.0.0.0 UG 0 0 0 h1-eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 h1-eth0
192.168.1.0 192.168.0.1 255.255.255.0 UG 0 0 0 h1-eth0
192.168.2.0 192.168.0.1 255.255.255.0 UG 0 0 0 h1-eth0
h2 routes:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.1 0.0.0.0 UG 0 0 0 h2-eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 h2-eth0
192.168.2.0 192.168.1.1 255.255.255.0 UG 0 0 0 h2-eth0
r1 route tables:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 r1-eth0
192.168.1.0 192.168.2.2 255.255.255.0 UG 0 0 0 r1-eth1
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 r1-eth1
r2 route tables :
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 192.168.2.1 255.255.255.0 UG 0 0 0 r2-eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 r2-eth0
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 r2-eth1
When I try pinging h2 from h1 and vice versa I get destination host unreachable error.
where am I going wrong? Is there a step I have skipped? Any insight/help is appreciated.
PS: The following is my ping reachability matrix:
*** Ping: testing ping reachability
r1 -> r2 h1 X
r2 -> r1 X X
h1 -> r1 r2 X
h2 -> r1 r2 X