I'm trying to understand how routers make their routing decisions. This is what I'v come up with and I'd like to know whether I'm right or not:

  1. First check whether there is an entry in the routing table for that destination address.
  2. If there is none, send it to the default route.
  3. If there is one, make a longest-route-match, then check administrative distance and then metrics.

Is that correct?

1 Answer 1

Is that correct?


You need to understand the difference between routing (control plane) e forwarding (data plane).

Routing builds the routing table by performing route selection from protocols like OSPF, BGP, static routes, so on.

Forwarding looks up packet destination by querying the routing table.

Back to your question:

  1. "Metric" usually is a parameter for selecting a route within routing process for SPECIFIC protocol.
  2. "Administrative distance" is a parameter for selecting a route among DISTINCT protocols.

Both "metric" and "administrative distance" lie in the control plane (routing). Thus, they are used to choose the best routes for BUILDING the routing table.

  1. "Prefix length". Longest match first is a route lookup strategy of the data plane. For every received packet, the forwarding engine queries the routing table using the longest match algorithm in order to pick the best route FROM the routing table.

  2. The "default route" can be seen just as the 'shortest prefix ever' (encompassing all other prefixes), useful as last resort option for the longest match lookup.

  • Does that mean that there will be no two entries in a routing table with the same network+subnet mask but different values for administrative distance/metric because the router will only accept one into its routing table?
    – rosix
    Commented Jan 5, 2016 at 13:59
  • @rosix Yes, you shouldn't see multiple instances of the same prefix installed in the routing table with different metric/distance.
    – Everton
    Commented Jan 5, 2016 at 14:04
  • @Everton Multiple prefixes may exist in routing table and forwarding table if ECMP is enabled
    – Soumen Das
    Commented Jan 6, 2016 at 5:43
  • @soumen Notice the comment is specifying multiple identical prefixes with distinct metric or administrative distance. That should not exist.
    – Everton
    Commented Jan 6, 2016 at 5:52
  • I don't think this is universally true. For instance, in Linux routes in the routing table have a metric field, which seem to be used for forwarding.
    – LatinSuD
    Commented Nov 26, 2023 at 10:58

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.