9

There are 2 cases that I would like to point out:

  1. When the router is directly connected with 2 PCs like this,

    "Router 1" has two connections, one to "PC2" and one to "PC3"

    In this case, PC2 is able to ping PC3. I just configured the IP address of PC2 and PC3 and a default gateway for them, in this case there is no need to add a routing table.

  2. When two routers are connected like this,

    "Router 2" has a connection to "Switch 0", which itself is connected to "PC4" and "PC5". "Router 4" has a connection to "Switch 1", which itself is connected to "PC6" and "PC7". "Router 2" and "Router 4" are connected to each other.

    Here PC4 is not able to ping PC6 or Router4 (192.168.3.3).

Why do we have to explicitly add entries for routing table in the second case when it was not needed in the first case?

9
  • 2
    How do you expect R4 to know anything about networks on other routers?
    – Ricky
    Nov 12, 2021 at 16:39
  • @Ricky Yes, your point is right. But Router4 is connected with 192.168.3.0/24 also, then why PC4 is not able to ping 192.168.3.3?
    – anonymous
    Nov 13, 2021 at 17:42
  • 1
    Because R4 does not know about 192.168.0.0/24. Run a few debug's; you'll see R4 receive the packet, but has no route to send the reply.
    – Ricky
    Nov 13, 2021 at 18:38
  • @Ricky Sorry but I made a mistake in the previoous comment, I was asking that Router2 is connected with 192.168.3.0/24, then why PC4 is not able to ping 192.168.3.3/24?
    – anonymous
    Nov 14, 2021 at 7:42
  • 1
    How many times do I have to say it? 3.3 cannot answer 0.11 because it has no route to 0 The packet from 0.11 will get to 3.3, but it can't respond.
    – Ricky
    Nov 14, 2021 at 13:31

5 Answers 5

9

You don't have to add anything in the 1st case because it's automatic. As there's only one router, it obviously knows everything directly connected to it. When that becomes more than one router, some process needs to be in place to tell the others what isn't local. (either static routes, or any number of dynamic routing protocols.)

Thanks to Comments on this question by @Ricky; I'm editing this answer to clear the point. In the 1st case, there is only one router; it knows about both networks (192.168.0.0/24 and 10.0.0.0/8)

But In the 2nd case, there are three networks (192.168.0.0/24, 192.168.1.0/24, and 192.168.3.0/24) If PC4 tries to ping 192.168.3.3/24, packets from 192.168.0.11/24 will get to 192.168.3.3/24, but R4 cannot route back to 192.168.0.0/24. So That's why PC4 will be able to ping 192.168.3.2/24 but not 192.168.3.3/24.

9

Why in the first case, There was no need of adding Routing table

Because it's not really true that there was no need of adding a routing table.

When you configured the IP addresses and subnets of the two interfaces, you implicitly added two entries to the routing table, one for each interface/subnet.

4

In the second setup there are 3 ip-subnets involved:
192.168.0.0/24, 192.168.1.0/24 and 192.168.3.0/24.

Router2 knows about 192.168.0.0/24 and 192.168.3.0/24 because it has a interface in each. Router4 knows about 192.168.1.0/24 and 192.168.3.0/24 because it has a interface in each.

But there is nothing to tie them together so that Router2 knows were to send packets intended for 192.168.1.0/24 (and similarly Router4 has the same problem with 192.168.0.0/24).

So on Router2 you have to define a static route for 192.168.1.0/24 that points to 192.168.3.3. That will forward any packets for 192.168.1.0/24 to Router4 and Router4 knows what to do with those.
(And on Router4 you need to setup a static route for 192.168.0.0/24 via 192.168.3.2.)

The alternative is to setup a dynamic routing protocol (e.g RIP, IGRP, BGP, OSPF) on both routers that lets them learn the whole ip-subnet topology.
These can be quite complicated to configure except for RIP. RIP is by far the easiest to setup (just enable it, no config neccessary), but it is quite outdated and doesn't perform well in large (many subnets/routers) deployments. For a small network like this it would do just fine.

4
  • Router2 knows about 192.168.0.0/24 and 192.168.3.0/24 Then why PC4 is not able to ping 192.168.3.3
    – anonymous
    Nov 13, 2021 at 17:37
  • @developer Did you actually ENABLE routing on Router2? Because some routers (and Layer3 capable switches) don't do that automatically. Especially Cisco devices tend to default to "routing = off". That has given me a couple of WTF moments in the past, because it is the last thing you expect on a router, that you have to explicitly tell it to do its job.
    – Tonny
    Nov 13, 2021 at 18:28
  • Yes, I have enabled routing on R2. If I just add routing table for R2, it will start working, PC4 will be able to ping 192.168.3.3, but that's not the point here for me, because If PC4 can ping 192.168.3.2 (without adding Routing table), It should be able to ping 192.168.3.3 also, because they are both in the same network. but that's not the case here.
    – anonymous
    Nov 14, 2021 at 8:05
  • @anonymous Wait a sec. Has Router4 a route (for 192.168.0.0/24) or default gateway set to Router2 when the PC is unable to ping 192.168.3.3? If not that would explain it. The ping would have reached 192.168.3.3 (because Router2 can figure that much out on its own) but Router4 can't respond because it doesn't know the path back to the originating ip-address.
    – Tonny
    Nov 14, 2021 at 10:44
3

To add to AndreKR's answer. There are actually 4 routes that are implicitly added.

  1. 10.0.0.1/32 - to CPU route. (Also called punt route) Packets that are destined to this IP address will travel to the router's CPU. For example ping to 10.0.0.1 will be handled by the ICMP application on the router.

  2. 10.0.0.0/24 - This is called glean route. Every packet that arrives to this address range (that doesn't match the more specific 10.0.0.1/32) will be trapped to router's CPU to trigger an ARP request (unless an ARP entry already exists) and eventually (after MAC address is known) will be sent to this destination IP directly out of this interface using the MAC address located in ARP database.

  3. 192.168.0.1/32 - similar to 1

  4. 192.168.0.0/24 - similar to 2

Note that usually a router doesn't issue an ARP request to resolve the destination IP address from data packets - it only happenes (as far as I know) when the destination is directly connected to the router.

Also note, that after the MAC addresses of the connected PCs are resolved (using the mechanism described in 2.), a 5th and a 6th routes are added:

  1. 10.0.0.2/32 via gig0/1

  2. 192.168.0.11/32 via gig0/0

If ARP cache is cleared, or ARP cache entries are expired - these routes are removed.

2

The point is that each node needs to have a route to all the subnets, either a default route (hosts) or a specific route to each subnet (routers).

When a node is directly attached to a subnet, a specific route is set up automatically. Otherwise it needs to be set manually by the admin, or learned via a routing protocol from peer gateways. (Hosts often have a default gateway set by DHCP.)

Case 1 is trivial - likely the hosts have their default gateway set to their router's southward interface. That single router is directly attached to all subnets, so all necessary routing table entries are added automatically.

In case 2, hosts are likely using their router interface as default gateway as well. But unless you've explicitly set up the routers, they don't know the subnet behind the other router. Each router has got an automatic entry for the directly attached subnets - the client subnet below and the link to the other router. However, there's no route to the subnet behind the neighbor router, so that is unreachable.

You could set up each router on the other one as default gateway, but that would prevent any more routers to be added.

Much better, you either set up a static route to the remote network or you set up a routing protocol like OSPF between the routers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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