Dynamic Routing: How BGP and OSPF Work
💡 Quick Tip
Fact: OSPF is used for internal corporate data; BGP is the protocol that holds the entire Internet together.
What is Dynamic Routing?
Dynamic routing allows routers to exchange information about the networks they know and the best path to reach them. If a cable is cut, protocols detect the failure and recalculate an alternative route in milliseconds.
OSPF: Link-State Protocol
OSPF (Open Shortest Path First) is an Interior Gateway Protocol (IGP). It is used within an Autonomous System. Every OSPF router creates a map of the network topology. It uses the Dijkstra algorithm to calculate the shortest path based on link "cost" (usually bandwidth). It converges extremely fast after a failure.
BGP: Path-Vector Protocol
BGP (Border Gateway Protocol) connects different Autonomous Systems. It is the "glue" of the Internet. BGP focuses on stable paths and policy compliance between countries and providers. BGP handles tables with over 800,000 routes. A configuration error here can disconnect entire countries from the Internet.
📊 Practical Example
Real-World Scenario: Network Recovery after a Fiber Cut
Step 1: OSPF Detection. Routers stop receiving "Hello" packets via the failed 10Gbps link. OSPF marks the interface as "Down".
Step 2: Database Recalculation. Routers send an LSA (Link State Advertisement). OSPF re-runs the Dijkstra algorithm.
Step 3: Routing Table Update. In under 2 seconds, the router switches the default route to the 1Gbps backup link. The network stays up without human intervention.
Step 4: Post-incident Analysis. The admin checks BGP logs to see if the cut affected Internet egress. If the ISP has BGP redundancy, traffic will automatically flow through another international transit node.