0

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 - h2

The host Machine 'h1' has the following configuration: h1 ifconfig

The host Machine 'h2' has the following config: h2 ifconfig

The router r1 has the following config: r1 ifconfig

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 router terminal(xterm):

    ifconfig r1-eth0 192.168.3.0 netmask 255.0.0.0  
    ip route add 192.168.0.0/24 dev r1-eth0   
    ip route add 192.168.1.0/24 dev r1-eth0 

On the h1 terminal (xterm)

    ifconfig h1-eth0 192.168.0.103 netmask 255.0.0.0
    ip route add 192.168.1.0/24 via 192.168.3.0
    route add default gw 192.168.3.0

On the h2 terminal (xterm)

    ifconfig h2-eth0 192.168.1.2 netmask 255.0.0.0
    ip route add 192.168.0.0/24 via 192.168.3.0
    route add default gw 192.168.3.0

The updated routing tables for h1, h2 and r1 are as follows:

h1 IP routes
h2 IP routes
r1 IP routes

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.

P.S.: I would appreciate any good resources on static IP routing.

Zac67
  • 84,333
  • 4
  • 69
  • 133

1 Answers1

0

For routing to work, h1 and h2 need to be on separate subnets.

ifconfig h1-eth0 192.168.0.103 netmask 255.0.0.0

and

ifconfig h2-eth0 192.168.1.2 netmask 255.0.0.0

are on the same 192.0.0.0/8 subnet. Both try to ARP each other, failing due to lack of a common broadcast domain. Increase netmask to 255.255.255.0 = /24.

Also, the router needs to have two interfaces - one for facing and sharing a subnet with each host. The hosts need to use their respective router interface as default gateway. Generally, you can't have a (default) gateway that is outside of a host's subnet.

Zac67
  • 84,333
  • 4
  • 69
  • 133
  • I have started again from scratch following your instructions:

    router terminal(xterm): ifconfig r1-eth0 192.168.3.0 netmask 255.255.255.0
    ifconfig r1-eth1 192.168.3.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 dev r1-eth1

    After setting up the configuration for h1(same IP different netmask), I failed to add an IP route via r1-eth0's inet. I get a SIOCART: Network is unreachable error.

    – Toshitt Ahuja Apr 28 '23 at 22:17
  • You need different subnets on the router interfaces, each matching the attached host's. Please get your subnetting right first: https://networkengineering.stackexchange.com/questions/7106/how-do-you-calculate-the-prefix-network-subnet-and-host-numbers – Zac67 Apr 28 '23 at 22:20
  • I did it @Zac67, the solution worked. Thank you so very much! – Toshitt Ahuja Apr 28 '23 at 23:05
  • Hi. My problem has a slight addition to it now.Should I create a new post altogether or should I carry on here? – Toshitt Ahuja Apr 29 '23 at 16:36