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 netmask  
    ip route add dev r1-eth0   
    ip route add dev r1-eth0 

On the h1 terminal (xterm)

    ifconfig h1-eth0 netmask
    ip route add via
    route add default gw

On the h2 terminal (xterm)

    ifconfig h2-eth0 netmask
    ip route add via
    route add default gw

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.

  • Please never post text as screenshots. Instead, post text as text using the editor's {} preformat function.
    – Zac67
    Apr 28 at 20:50
  • I tried doing that. But for some reason, xterm wouldn't let me copy text. Hence the screenshots.Sorry for the inconvenience. Apr 28 at 20:54
  • Please don't change the question totally around after it's been answered.
    – Zac67
    Apr 29 at 19:28
  • Apologies.Made a blunder.I have reverted back to the original. Apr 29 at 19:46
  • Unfortunately, questions about hosts/servers/VMs are off-topic here. You could try to ask this question on Super User.
    – Ron Maupin
    Apr 30 at 0:03

1 Answer 1


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

ifconfig h1-eth0 netmask


ifconfig h2-eth0 netmask

are on the same subnet. Both try to ARP each other, failing due to lack of a common broadcast domain. Increase netmask to = /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.

  • I have started again from scratch following your instructions: router terminal(xterm): ifconfig r1-eth0 netmask <br/> ifconfig r1-eth1 netmask <br/> ip route add dev r1-eth0 <br/> ` Ip route add dev r1-eth1` <br/> 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. Apr 28 at 22:17
  • You need different subnets on the router interfaces, each matching the attached host's. Please get your subnetting right first: networkengineering.stackexchange.com/questions/7106/…
    – Zac67
    Apr 28 at 22:20
  • I did it @Zac67, the solution worked. Thank you so very much! Apr 28 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? Apr 29 at 16:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.