Hello, everyone!
I'd like to share the basics of IP routing today. Do you know how packets are forwarded in a network?
Let's start with an overview of IP routing.
IP Routing Overview

When a router receives an IP packet, the router searches the FIB table for a route based on the destination IP address of the IP packet.
If a matching route is found, the device forwards the route based on the outbound interface or next-hop of the route.
If no route is matched, the router discards the packet because it has no routing information to guide packet forwarding.
RIB and FIB
Network devices with routing functions maintain two important data tables:
Routing Table (RIB)
Forwarding table (FIB)

Routers maintain a local core routing table and, in addition, routers maintain routing tables for their respective routing protocols.
The router downloads the best route from the local core routing table into the FIB table.The forwarding chip of the router forwards IP packets according to the FIB table.
Routing Table
Each router has a routing table, which is divided into a local core routing table and a protocol routing table.
Protocol Routing Table

Local Core Routing Table

Longest match rule for IP route lookup
When the routing table searches the FIB table, it performs bitwise logically and on the destination IP address of the packet and the mask of each item in the FIB table.
Finally, a FIB entry with the longest mask is selected to forward the packet.
Source of Route
There are three main sources of routes.
Direct Route

Static Route

Dynamic Route

Dynamic Routing Protocol
Dynamic routing protocols can be classified into the following types:
Interior Gateway Protocol (IGP): It runs within an autonomous system. Common IGP protocols include OSPF and IS-IS.
External Gateway Protocol (EGP): runs between different autonomous systems. BGP is the most common EGP protocol.

Route Selection
A route must have a directly connected next hop to guide forwarding. The next hop of a static route or BGP route may not be a directly connected neighbor. Therefore, a directly connected next hop needs to be calculated. This process is called route selection.

Select a directly connected next-hop: In this example, we add a route to 11.x.x.2 for R1 so that the route to 192.168. 21.0/24 can be iterated.
Data Forwarding Process
The following figure shows the packet forwarding process.

Thank you so much for reading and hope it helps you.
Welcome to the comments section.







