When we talk about IP-Routing we talk about forwarding packets to its destination based on different informations provided by the routing table (RIB). This table is composed of many things, but the most important is the destination and its next-hop. To know where the packet needs to be forwarded.
How is the information fed in the routing table?
There are three different sources where the information could come from.
Connected routes
These routes are networks configured on the interface of the device.
Static routes
This are manually configured routes that points to a specific network over a manually selected gateway.
Dynamic Routing protocols
Router has the ability to run specific protocols to exchange information between devices connected sharing the same segments. This protocols can forward information to its neighbors containing routes of devices that are not directly connected. Therefore the devices has a better connectivity by choosing a shorter path to a specific destination.
1.2.a Administrative distance
What happens if we received the same route we configured manually with the same prefix length coming from a dynamic routing protocol?
there is only space for one entry in the routing table for a network with same prefix length coming from different routing protocols. The decision is made first by the AD also called Administrative Distance. Every routing protocol has its own defined value for the administrative distance. For example, connected routes has an AD of 0, a static
route has an AD of 1 and OSPF has an AD of 110. The lower the value, the most preferred the route is.
Example:
If we configured manually a static route (AD: 10), telling the routing device that the network 192.168.1.0/24 is reached by the next-hop 10.10.10.2 and we receive the same network advertised by OSPF, a dynamic routing protocol (AD: 110), then the router will put the manually configured network in its routing table, since it has the lower AD.