-1

When I ping an external unknown IP, I see the sent ICMP packet with the default gateway's MAC address as destination, as expected. The gateway's IP address however is not used anywhere - it's just that single packet which naturally has the external unknown IP as the destination.

So why do I (or DHCP) need to configure the IP address of the default gateway on the client? Is it really only to fire that single ARP request to find the gateway's mac address?

I know what a default gateway is. What surprises me is that the default gateway is always identified by an IP address, when in fact all you really need is its MAC address. For all I know, you could build a functioning gateway that doesn't even have an IP address.

kasperd
  • 30,455
  • 17
  • 76
  • 124
nkaleidoskop
  • 111
  • 3
  • Possible duplicate of [Does Default Gateway IP = Router IP?](https://serverfault.com/questions/186645/does-default-gateway-ip-router-ip) – Run CMD Jun 09 '17 at 09:17
  • 1
    `So why do I (or dhcp) need to configure the ip address of the default gateway on the client?` - All traffic that isn't destined for the local network goes to and through the Default Gateway. – joeqwerty Jun 09 '17 at 14:57
  • Yes it is mostly ND and interface discovery. I think it also uses the Ip to compare ICMP redirect origin (if secure_redirect is used) – eckes Jun 09 '17 at 21:14

2 Answers2

1

MAC address is defined for an interface. If an interface card at the default gateway router is changed, or the router itself is changed, MAC address changes.

An alternative would be to use a fixed MAC address on the gateway, that is, configuring the same MAC address on the interface of the new hardware. However, this is not always possible.

Therefore using only MAC address for the default gateway is not practical and therefore IP address is used.

This is also consistent with regards to OSI network layer division, where OSI layer 3 always handles routing, and layer 3 has its own address mechanisms.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
1

When a routing table entry is created the gateway IP address is used to decide which network interface the packets have to be send on. And after that the gateway IP address is used for ND or ARP to learn the MAC address of the destination.

There are other ways to specify which network interface a routing table entry is used for. So using the IP address for that could be avoided if you really wanted to. In that case the gateway IP address would only be used for ND or ARP.

It may seem redundant, but remember that every time a layer of indirection is introduced, it means there is something which can be changed (more or less dynamically) for added flexibility. The mapping from IP address to MAC address can change, for example if you have redundant gateways.

Though bypassing the ND/ARP step is possible, it is not directly supported by much software. The reason it isn't directly supported is that the standard way of doing things happens to be more useful.

If you really wanted to bypass the ND/ARP step the way you could do it is by manually creating an entry in the ND/ARP cache and use that. It would allow you to use a gateway knowing only its MAC and not its IP address, but that is a very uncommon scenario.

kasperd
  • 30,455
  • 17
  • 76
  • 124