3

When a IP sends something to another host outside the same subnet, it constructs a packet (L3) with the target IP being the IP of the target host, but the frame (L2) has the destination address = hardware address of the gateway. The IP address of the gateway seems never involved in a host-to-host communication.

It appears that theoretically the gateway doesn't need an IP address at all and it only needs a L2 address, and the following routing table should work identically as a legacy one:

default via <01:23:45:67:89:ab>
10.0.0.0/24 link-local

Is this theory true?

1
  • Many IPv6 routing protocols use the link-local IPv6 address as the next-hop. So an IPv6 network core would not have to have any internet routable IPv6 addresses (except for management). Jan 12 '20 at 16:50
1

For a point-to-multipoint interface (like an Ethernet NIC), the IP address of the next hop gateway is required - after all, the packet needs to finds its path through the network to that gateway.

On a point-to-point interface (like a simple serial interface), no gateway address is required. Just routing out of the interface is sufficient since each transmitted packet ends up on the partner hop.

The rest of your question is answered in this Q&A.

8
  • I'm still confused. Why is the IP address of the next hop required? It could just examine the target IP to determine how to route the packet (output port / output link) without needing an IP address of its own.
    – iBug
    Jan 12 '20 at 15:52
  • "it could just examine the target IP..." - that is exactly what happens: a sending node consults its routing table, determines the gateway and send the packet that way. Since the node needs to have some means to address the next hop on a p2mp network, it uses its IP address. On a MAC-based network, the IP address is used to determine the hop's MAC address. Other networks use different mechanisms.
    – Zac67
    Jan 12 '20 at 16:02
  • I nearly had the same question as the OP: Why should it not be possible to specify the MAC address directly (or another L3 protocol address)? Example: route 192.168.10.0/24 gw 2001:db8::2 Because the gateway address is only needed to get the MAC address of the router, it should be possible to implement an OS that works this way. Jan 12 '20 at 17:10
  • @MartinRosenau See the Q&A link, it's explained there.
    – Zac67
    Jan 12 '20 at 17:11
  • OK. But still it would be possible to specify another L3 protocol address (e.g. an IPv6 or even IPX address for routing IPv4 packets...)? Jan 12 '20 at 17:14
2

Setting an IP address as a default gateway provides two things:

  • allows the host to "find" (via ARP) the appropriate MAC address for L2 encapsulation
  • informs the host which interface to use to find the gateway (via Routing table)

Imagine a host has three network connections, each with unique IP address space. Typically, only one of those network connections will have the intended default gateway.

If you specify the gateway's MAC address, then the host doesn't know which interface to use to reach the gateway. That MAC address could exist on all three of the interfaces.

If you specify the gateway's IP address, then the host can use it's local routing table to determine where the gateway is. And then can use ARP to find the actual MAC address.

Technically, if you could specify both the Interface and the MAC address while setting the default gateway, you then (in theory) would not need an IP address on your default gateway.

But the key being, the MAC address by itself does not provide any indication of which interface to use.


While not strictly related to your question, it's worth noting: This is why when you set a default gateway using an IPv6 Link-Local address, you must also indicate which interface to use. Because the link-local scope exists on each interface, the host can not use a routing table to determine exactly which interface the intended gateway exists within.

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.