IP Route with IP Address or Interface

The short of it is, it is almost always better to use an IP address as the next hop when creating static routes rather than using interface names. Look at the following:

ip route 0.0.0.0 0.0.0.0 10.10.10.12

versus

ip route 0.0.0.0 0.0.0.0 fa0/1

Both set a default route. Both might work fine, but they do different things and the second can be more problematic.

When forwarding packets a router must find the Layer 2 MAC address. This can be done using ARP. With the first example above, there is a single IP address involved (10.10.10.12) and the router has to find the MAC address of that IP and send the data to it.

In the second format, when using an interface name, the router also has to find a layer 2 MAC address, but this time it must also check to see what IP(s) are on that interface. An interface can either be point-to-point or point-to-multipoint. For point-to-point this will usually work as expected. There is only one possible next hop address.

For multipoint connections the router will attempt to find the layer 2 address of every destination address. This is not always possible and will lead to the router being unable to send out traffic to a destination. You can see more information about this here.

I recently came across something like this using IPv6. The configuration looked something like this:

!
ipv6 unicast-routing
!
interface GigabitEthernet3/0/0
  ipv6 address 2001:12:1:F1::1/126
  ipv6 enable
!
ipv6 route ::/0 GigabitEthernet3/0/0

But I could not ping past the next hop. Nor could I reach my IP from anywhere beyond the next hop. It was as if the default route was not working.

Changing the route command to

ipv6 route 2001:12:1:F1::2

Which was the next hop address fixed the issue and everything worked as expected.

So why did using the interface name rather than the IP not work? One reason may have been that IPv6 ports have multiple IPs on them. Maybe the interface was attempting to send out the local link address? I believe the multiple IP addresses on this port caused the issue.

Finally, another reason to use an IP address when creating a static route rather that an interface name is ease of change in the future. If a static route is created with an IP address and the IP address moves to a different port, then you do not have to go and change the static route. If on the other hand the static route is set to an interface then you have to manually change the static route is that connection is ever moved to a different port.

When creating static routes, you are usually better off using the next-hop IP address rather than the interface name.