2

enter image description here

I wanted to make this network fully connected, so I need to assign IP addresses to all interfaces of routers and to all hosts. However, I should assign a default gateway address to every host, but, how am I supposed to do that for PC0 host, as it is connected to switch, and the switch is connected to two routers, is this maybe a situation where default gateway is not required? Or is there something else that I should do here? Any help appreciated!

3
  • Have you tried VRRP? It is a first hop redundancy protocol. Feb 14 '19 at 10:16
  • Hello 22 and welcome. VRRP won't help here, as there are no redundant paths. The question is about what happens with a single default route on PC0, which sends some packets non-optimally.
    – jonathanjo
    Feb 14 '19 at 10:36
  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can provide and accept your own answer.
    – Ron Maupin
    Dec 14 '19 at 20:20
5

Because you have not a star-shaped network, you have to define a route to reach each network.

Your routes can be :

192.168.2.0/24 via 192.168.1.254
Default via 192.168.1.253

or

192.168.2.0/24 via 192.168.1.254
10.0.1.0/30 via 192.168.1.253
192.168.3.0/24 via 192.168.1.253

or

Default via 192.168.1.254
10.0.1.0/30 via 192.168.1.253
192.168.3.0/24 via 192.168.1.253

Depending on what part of your network you consider as "outside" from PC0.

The other solution is to connect PC0 to 192.168.1.0/24 via a router and set default route to it and theses routing tables will be on this router.

5
  • Ok, i created routes, but i asked about default gateway of host PC0, i think i figured it out, i set Router2 to be default gateway for PC0, so even when i am trying to reach network on the right side, Router2 will recognize that it needs to send packet to the Router0 if i create correct static route, ofcourse i could do vice-versa. I hope that this makes sense.
    – cdummie
    Feb 13 '19 at 13:05
  • Yes, assign to PC0 a default route to one router will work and you will be able to reach the whole network. But this is clearly not a good way to reach a network because sometimes your packet will pass trough 192.168.1.0/24 network two times. Is this an exercise from studies or personal to learn about routing possibilities?
    – redheness
    Feb 13 '19 at 13:11
  • 1
    @redheness no, this is what ICMP Redirect is for.
    – JFL
    Feb 13 '19 at 13:15
  • I do study computer networks, but this particular network i created by myself to practice a little bit, to see what kinds of things can happen with various configurations. Ok, so my idea will work, but it is not good in practice, so what am i supposed to choose for default gateway of my PC0 host?
    – cdummie
    Feb 13 '19 at 13:32
  • 1
    @cdummie, there is a section in this two-part answer titled Selecting an IPv4 Network Gateway (Router) Address.
    – Ron Maupin
    Feb 13 '19 at 14:42
2

You say you "should assign a default gateway address to every host", but there is no requirement to do this.

Instead, a host only needs to have routes for every host it needs to connect to. In your particular network, there are 10 IP addresses (assuming a management address for the switch). Which means that the host PC0 could have nine host routes and no other routes at all. Or alternatively any method of aggregating them, as suggested in the other answer.

A host only needs a default route if it needs the potential to send packets to every host in its network. Of course, most hosts are in the internet, and so the number of potential hosts is enormous, so we make use of default routes.

In your particular network, you could put a default route on PC0 to one of its two connected routers, and have that router forward if it has a full-enough routing table. This is often considered bad routing as it's certainly non-optimal for the packet. But it's sometimes seen in networks where simplicity of management is more important that packet efficiency.

It's worth noting that the "core" of the internet is widely considered to be the "default-free zone": a subset of the internet where no router has a default route. Instead, they have routes to every known public network. (And, it can be assumed, the private networks of their operators.) Wikipedia article.

[EDIT] There are a couple of questions overlapping here.

  1. Default routes are not in themselves important: what's important is whether the routing tables of the devices have routes for everything, and whether they are good routes.
  2. It's uncommon for end-user computers to have more sophisticated routes than simply a single default route, typically acquired by DHCP. It's very common for routers to have complex, often dynamic, routing tables.

If your constraint is that PC0, 1 and 2 have only a single default route, and the routers have the minimal number of routes, then the usual way is to ensure that all routers have full connectivity for all addresses of interest. Then point all hosts at any locally attached router.

There are a lots of ways of solving the routing for the three routers in a row, but here's one of the simplest.

R0: 192.168.2.0/24 -> R2,  192.168.3.0/24 -> R1, no default route
R1: default -> R0
R2: default -> R0

(In the actual routes, you need to use the near-side IP address of the router. I'm using the names just because it's easier to read.)

Additionally, all three routers will automatically have two interface routes, one for each of their enabled interfaces. (Ie, they know their local routes.)

Two end-hosts are have only a single choice:

PC1: default -> R2 # your PC and router names are funny way round
PC2: default -> R1

The last one is where the question is.

Unless we put suitable multiple routes on PC0, some of its outgoing packets will go the "wrong" way. Eg, with default -> R0, a packet from PC0 to PC1 will go PC0->R0->R2->PC1. This is perfectly fine from the point of view of the packet: it gets to where it's going, albeit a little slower than if it went directly. When a router notices it has a sent a packet out of the same interface as it arrived on, it will normally issue an ICMP Redirect message, to tell the sender that a better route is a available. In this case it's R) telling PC0. PC0 can ignore this ICMP if it chooses, or use it to learn a new route. Be aware that many PC operating systems won't learn new routes by ICMP as this is a vector of attack; also, many routers have the ICMP redirect messages disabled.

If you put the default route on PC0 to the other router, the behaviour is symmetric.

1
  • Can you explain what exactly do you mean by "you could put a default route on PC0 to one of its two connected routers, and have that router forward if it has a full-enough routing table"? Are you trying to say that i should create default route to the network with PC0 so that whenever Router0 cannot determine where to send packet, it just sends it to the PC0's network? I don't understand how that can make this network completely connected? How will PC0 know where to send out packets when i want to send something from him to somewhere else in the network?
    – cdummie
    Feb 13 '19 at 17:26

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.