3

It seems to me that it would make a lot more sense to specify a default gateway with a layer 2 address.

As I understand it, the default gateway is only used to find which MAC address should be filled in the destination for unknown IP destinations.

For example, let's say my PC with a public IP of 1.2.3.4 wants to connect 8.8.8.8, so to build the packet we have all the necessary information except the destination MAC address of the next hop. So we know the:

  1. Source MAC address
  2. Source IP address
  3. Destination IP address

And to figure out the destination MAC address we need to make an ARP lookup because the default gateway is specified as a layer 3 address.

Why not just use a MAC address for the default gateway and get rid of the seemingly unnecessary ARP table lookup for each packet that traverses the system?

1
  • 1
    The interfaces between the layers in the networking abstraction model have never been as clean as they draw them in the textbooks. Commented 11 hours ago

4 Answers 4

6

Why not just use a MAC address for the default gateway and get rid of the seemingly unnecessary ARP table lookup for each packet that traverses the system?

The ARP table lookup is not unnecessary. Sure, you could implement routing without it, but sometimes indirection is useful because of the indirection – ARP provides a useful abstraction here in the same way that it provides a useful abstraction when addressing a host directly.

As a practical example, relying on ARP allows the gateway to be physically changed without routes needing to be reconfigured, in much the same way as relying on ARP allows the destination IP address to be reassigned to a different host.

Such indirection also allows the routing table entry to look and behave the same way regardless of the medium. Not all links use a 48-bit MAC address – sometimes it's 16-bit, or 64-bit, or 128-bit, and sometimes it's a point-to-point link that doesn't use MAC-layer addressing at all (and therefore no ARP, with the only possible destination being "The other end of the link").

This applies to administration as well. If the routing table were to directly use MAC addresses, it would be the only place where the network administrator needs to specifically deal with lower-layer parameters for no good reason, given that regular IP destinations do not require that.

For example, when addressing a host on your local subnet, normally you do not treat it as a special case and specify its MAC address to avoid the "unnecessary" ARP lookup. Addressing an IP host is uniform whether it is local or not (and indeed it is the purpose of IP to isolate applications from such link-layer-specific details). It makes sense that the same uniformity extends to the routing table as well.


(And perhaps there would be more than just a raw translation involved in some cases – perhaps some hypothetical network, like IP-over-ATM, would require to establish an 'virtual circuit' for each local destination so the 'ARP' lookup result might be a temporary circuit ID instead of a static address.)


Though some platforms do allow nexthops that aren't just IP-resolved ARP addresses. For example, it is becoming increasingly common to support IPv6 nexthops for IPv4 route entries, so that purely IPv6-addressed routers could still forward IPv4 packets. (Allowing raw MAC address nexthops would perhaps make sense in some cases, but usually an IPv6 link-local address is good enough – and again keeps the uniformity.)

5
  • +1. But also OP alleges they want to "get rid of the seemingly unnecessary ARP table lookup for each packet that traverses the system". A key point is that due the ARP cache, the supposedly unnecessary ARP request is only made every many thousand (possibly many million) packets. ARP cache lookups are super optimised as every packet sent goes through them, and indeed on some OS's are effectively combined with the route lookup. So the extra overhead is minimal to zero. Commented 11 hours ago
  • 1
    OP did say "ARP table lookup", not "ARP request", so it seems that they've already accounted for the cache. Commented 11 hours ago
  • Yes, I did account for the cache, and while I imagine that it is super optimized it is still a lookup in some sort of hash table which does take time. But I get it now, the usage of layer 3 for a gateway is all about not needing to change software configuration when a hardware change occurs (i.e. abstraction). Commented 9 hours ago
  • 1
    Practical advantage of the abstraction was kind of my secondary point. The main point IMO is the layer isolation, to some extent at least. Commented 9 hours ago
  • Oh, gotcha! Thank you for clearing that up Commented 9 hours ago
4

A very good question - we need to use the link-layer address to use the gateway and it needs to be located within the local segment anyway - so why does a gateway even need a network-layer address?

A MAC address is just one of the possible ways to address a node in a link-layer network. It is by far the most used form of L2 address today, but remember that when TCP/IP was conceived, that wasn't the case.

Also, the network layer needs to be as agnostic as possible of the link layer, to ensure good separation and interchangeability. After all, MAC-based networks like Ethernet are not the only link layer that IP runs on top of, even today. PPP(oE), IPsec, or PPTP are common protocols that IP runs over, historically there were many more.

1
  • 2
    SLIP, PPP, HDLC, Frame Relay, ATM, SDH/SONET, PPPoA, X.25, Token RIng, Bluetooth, L2TP, MPLS, avian carriers... We had so much fun in those days! Commented 4 hours ago
3

Because not all transports of IP have Layer 2 MAC addressing.

One case would be SLIP/PPP. As the name implies, this is a transport of IP packets over a direct serial or point-to-point link. As a result, there are no MAC addresses exposed, the nodes must use the IP address of the gateway. Related question: Why two routers connected via PPP don't use ARP but Ethernet requires ARP?

Modern VPNs operating at Layer 3 would have a similar design.

Another case is transports which use a different addressing scheme. One example is IP over Firewire (IEEE 1394), since Firewire has its own addressing scheme, where addresses are dynamic, and thus has its own ARP protocol and table. The layer 2 addresses change when bridging between 1394 and Ethernet (or other 802-based networks).

1
  • FireWire is particularly weird – it does have fixed 64-bit MAC addresses (EUI-64) for all nodes, but there are also dynamic channels involved somehow, so the IP-over-FireWire spec uses 128-bit link-layer addresses to carry both the static EUI-64 and the dynamic parameters within the same ARP result... Commented 4 hours ago
0

How would you find where to forward to when gateway is specified in mac address?

You would still need some sort of broadcast mechanism to do so. You would then replace the arp lookup with another arp lookup

4
  • The interface + MAC address literally is "where to forward to". There's nothing else that needs to be looked up, as the gateway's IP address isn't used in forwarding, only the MAC address is (as was OP's point). Commented 11 hours ago
  • The interface + MAC address literally is "where to forward to" so it means you still need a boardcast mechanism to build a table that have a relation between mac address and interface. Yes, theortically you can have this table without L3 IP address...... oh wait you need to define the broadcast domain boundary which means you still need an IP Commented 9 hours ago
  • But route entries already have an 'interface' field alongside the IP nexthop. It's optional when it can be resolved from the IP address, but it's already there. Commented 9 hours ago
  • 3
    @jackychong, yes, specifying the GW with the L2 address instead of an IP address would require also specifying the interface. And it has to be given, there's no common way to discover L2 hosts so you couldn't broadcast to find it. And, re. "define the broadcast domain boundary which means you still need an IP", do note that IP addresses don't really have anything to do with defining broadcast domains, e.g. it's entirely possible to have multiple IP networks on the same L2 broadcast domain. Commented 8 hours ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.