So given a theoretical scenario assuming there are three routers. There is no internet in this case, just a local network for the sake of understanding. One router (A) is connected to the next (B), and that next router is connected to the third router (C). In this case the router (B) would need a gateway for two interfaces. One gateway for router A and one gateway for router C. This way router B can communicate with router A and C. So if you can only set one default gateway on router B, lets say pointing to router C, then how is router B supposed to communicate with router A due to the fact that there is no default gateway for it? Is this a reason to have two routers on the same sub-net, for all intensive proposes?
how is router B supposed to communicate with router A?
- Network 1 has A and B interface 1
- Network 2 has B interface 2 and C
- Router A will have an interface route to B interface 1
- B will have interface routes to A and C
- C will have an interface route to B interface 2
B's default route has no part to play in this.
If A is to communicate with anything on network 2, it will need a route for a network which includes network 2 (ie could be network 2, could a default route), passing to B interface 1.
Symmetrically, if C is to communicate with anything on network 1, it needs a route, perhaps a default route, pointed to B interface 2.
Is this a reason to have two routers on the same sub-net, for all intensive proposes?
You have two routers on both your networks.
A router usually doesn't use just a default gateway. It has multiple interfaces, representing multiple, local routes.
Additionally, it often 'knows' about remote routes. These can be manually set up using static routes or learned from another router through a routing protocol such as OSPF. If the routers in your example would exchange routes in this way, each would learn the remote networks that the others see.
The default gateway on a router is only used for the Internet or, in a larger network, for the next higher level router.