How routing works

When a packet comes into a router, the routing decision will be based on the destination IP address in the packet. First the router will consult the forwarding table (forwarding information base – FIB) and select the longest match in case of multiple match (longest match has the most bits in common). However if there is a host route match (/32), it will be the most preferred route regardless what the routing protocol is.

Say for example – the destination IP is 10.10.1.10

In the router, you type in #sh ip route 10.10.1.10 and you get 3 results:

10.0.0.0/8

10.10.0.0/16

10.10.1.0/24

Therefore, the third route is the longest match that has most bits in common.

One important thing to remember is FIB operates at the data plane level. FIB also called CEF table (Cisco Express Forwarding). To view the FIB you issue the command called #sh ip cef

Once the longest match found we need to go through route recursion (recursive lookup) process to decide the actual outgoing interface for the particular packet. Routing information base (RIB) is used for this purpose (#sh ip route). RIB operates at the control plane level on the router.

Recursion process:

10.10.1.10 via 76.10.55.96

76.10.55.96 via 128.100.2.10

128.100.2.10 directly connected GigabitEthernet2/6

This means the packet will egress via Gig2/6 on the router.

Notes: Routing get complicated if you have ACL, NAT translations, policy based routing like the upper layer techniques

RIB information is update regularly using routing protocols and other control plane information and RIB contains complete list of routes which is learned by the router.

How to enable CEF on all the interfaces on a router:

Router(config)# ip cef distributed

When you enable CEF FIB and adjacency table will be created in the router. At the same time all the routes will be downloaded in to the FIB from the RIB.