1

Assuming we have a router connecting 4 different networks, with the prefixes 00, 01, 10 and 11, the router would need to have an IP address with such a prefix in each network, to be addressable as the standard gateway, is that correct?

Now, I was wondering, the Link-Layer address that is needed to reach the standard gateway is gotten with ARP, by broadcasting for someone to reveal themselves as that address. However, couldn't we just have a router have just one IP that is in one of those networks? What would be the problem? If a device in a different network will want to talk to the router, it will just send a packet to that address, and the router will recognize that it has that particular address. So where is the need for each router to have one IP per network it is in?

1
2

Routers route packets between networks, so each network interface must be in a different network. Given a router with four interfaces, then the router would be connected to four different networks, with an address in each network.

One reason is that the router uses the its address and mask to determine which network is connected to the interface. Another reason is that it needs to send and receive frames on that network. For example, a router sending an IPv4 packet to a host connected to one of its networks may need to use ARP to determine the MAC address of the destination host (whether a PC, printer, etc. or even another router). The destination host must be able to respond on the same network, and if the router did not have an address in the network, then the destination host would need to use its configured gateway, which must be in the same network as the host.

That also applies to a source host. Its configured gateway must have an address in the same network as the source host, otherwise the source host would need a gateway to reach its gateway, and it does not work that way. The gateway is a host in the network that knows how to reach other networks.

If a router has four networks, and there are hosts on each network, then the hosts on each network need the router to have an address in the same network as the hosts. That means the router needs an address in each of the four networks.

3
  • The gateway MAC address is also discovered via ARP though, right? So assume we changed how we request the MAC address, and now ask for any address outside of the network when we want to receive the MAC address of the gateway - this would basically make it possible to not have 4 IPs, as asking for the gateway MAC. Just to clarify: I understand that this would not comply with how we want our networks to work, and it would seem like our router isn't in our network anymore, but I just want to know if this way we could save IP-addresses.
    – ShowyTool
    Apr 5 '20 at 23:41
  • You cannot go back and change how the IP networking works. You are trying to complicate things in the name of simplification, but your are really making things more complicated. For example, how do you deal with multiple routers on the same network? This is a common thing in business networks. The IETF went back and rethought everything when developing IPv6. ARP went away, but we have NDP that does that (among many other things) because it works and is simple.
    – Ron Maupin
    Apr 5 '20 at 23:45
  • I understand, thank you! Just looking at a picture of a simple network made it seem like we assign so many IPs for no reason, now I understand why :)
    – ShowyTool
    Apr 6 '20 at 0:14
0

Consider the routing table on a typical host. Here, a Raspberry Pi I have sitting on my desk:

pi@pi:~ $ ip route
default via 192.168.1.1 dev wlan0 proto dhcp src 192.168.1.114 metric 303 
192.168.1.0/24 dev wlan0 proto dhcp scope link src 192.168.1.114 metric 303 

This routing table says two things:

  1. To get to anything starting with 192.168.1..., just send that out on wlan0. No router needed, because those hosts will be on the same L2 network.
  2. For everything else, send it to 192.168.1.1 (which we already know how to contact).

Now technically we could assign the same IP address to all four interfaces on the router in you example. However this presents an unpleasant dilemma.

We could arbitrarily pick some IP address, like 169.254.33.122, and assign that to four interfaces. But none of the hosts would know how to reach it, because it would not be in the routing table like the example above. Someone could walk around and run ip route add 169.254.33.122 dev wlan0 on each host, but that's tedious. While one could conceive of some automated means for distributing such a route, it wouldn't have the ubiquity that DHCP has.

Or we avoid the need to add a route by picking some address which is already in the network the hosts are configured with (192.168.1.0/24 in the example above). But to have one address we can pick which is in each of the four networks, that means there must be address overlap between the four networks. That's no good: how then can the router determine to what network it should route a packet it receives?

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.