Skip to content
Home
Network Routing: OSPF, BGP, and How Packets Travel the Internet

Network Routing: OSPF, BGP, and How Packets Travel the Internet

Computer Networking Computer Networking 8 min read 1605 words Beginner ExcellentWiki Editorial Team

Routing is the mechanism that forwards data packets from a source network to a destination network across one or more intermediate routers. Without routing, networks would be isolated islands — routing connects them into the internet. Every packet that leaves a device travels through a series of routers, each making an independent forwarding decision based on its routing table. This guide covers routing table structure, static vs. dynamic routing, interior gateway protocols (OSPF, EIGRP, IS-IS), exterior gateway protocol (BGP), metrics, and operational routing concepts including MPLS and VRF.

How Routing Works

When a packet arrives at a router, the router examines the destination IP address and performs a longest-prefix match against its routing table. The entry with the most specific prefix that matches the destination wins. For example, for destination 10.1.2.3, a route for 10.1.2.0/24 is preferred over a route for 10.0.0.0/8. If no route exists, the packet is dropped and an ICMP Destination Unreachable (type 3, code 0) is sent back to the source.

Routing Table Structure

Each routing table entry contains the destination prefix (network address and mask), the next-hop IP address, the outgoing interface, a metric (cost) for that path, and the administrative distance (AD). AD measures the trustworthiness of the route source. Cisco defaults: directly connected = 0, static route = 1, OSPF = 110, IS-IS = 115, BGP (eBGP) = 20, BGP (iBGP) = 200. When a router learns the same prefix from two different protocols, the lower AD wins.

Forwarding Information Base

In modern router architectures, the routing table (RIB — Routing Information Base) is computed by the control plane and then distilled into a Forwarding Information Base (FIB) that is pushed to hardware forwarding engines (ASICs). The FIB is optimized for fast longest-prefix lookups at line rate (terabits per second). The separation between RIB and FIB is analogous to the control-plane/data-plane separation in SDN.

Static vs. Dynamic Routing

Static Routing

A static route is manually configured: ip route 10.0.0.0 255.255.255.0 192.168.1.1. Static routes are simple, consume no CPU cycles for neighbor discovery, and cannot be subverted by an attacker injecting false route updates. Disadvantages: they must be manually updated after topology changes, and they do not scale beyond a handful of networks. Static routing is appropriate for small networks (one or two routers) and for default routes pointing to an ISP.

Dynamic Routing

Dynamic routing protocols automatically exchange routing information between routers, building the routing table without manual intervention. They respond to topology changes — a link failure is detected and routes are recalculated in seconds or milliseconds. Dynamic routing adapts to congestion by preferring lower-cost paths and provides redundancy through automatic failover.

Interior Gateway Protocols

IGPs route within a single administrative domain (an autonomous system). Convergence speed and path optimality are the primary design goals.

OSPF

Open Shortest Path First (RFC 2328 for OSPFv2, RFC 5340 for OSPFv3) is the most widely deployed IGP. OSPF uses the Dijkstra SPF algorithm to compute the shortest path tree to every known destination. Key features: areas divide the domain into a backbone (area 0) and attached areas. Routers within an area have detailed topology; routers in other areas see only summary routes. This reduces SPF computation cost and limits the propagation of link-state changes. Multi-area OSPF uses ABRs (Area Border Routers) that connect areas to area 0 and ASBRs (Autonomous System Boundary Routers) that inject external routes.

OSPF supports equal-cost multi-path (ECMP) — up to 32 equal-cost paths to the same destination, providing load balancing. Hello packets (every 10 seconds by default) maintain neighbor state; dead interval is 40 seconds. OSPF authenticates updates using MD5 or SHA (RFC 5709, RFC 7474).

EIGRP

Enhanced Interior Gateway Routing Protocol is Cisco’s proprietary balanced hybrid protocol. It does not send periodic full-table updates like OSPF; instead, it sends partial updates only when topology changes. EIGRP maintains feasible successors — backup routes that pass the feasibility condition, enabling sub-second failover without recomputation. The composite metric combines bandwidth, delay, load, and reliability (bandwidth and delay are default). EIGRP is simpler to configure than OSPF in single-vendor Cisco environments (no area design required) but is not available on non-Cisco platforms.

IS-IS

Intermediate System to Intermediate System (ISO/IEC 10589) is structurally similar to OSPF — both are link-state protocols using SPF. IS-IS uses CLNS addressing natively (NET — Network Entity Title) and was adapted for IP (Integrated IS-IS, RFC 1195). IS-IS has a flat two-level hierarchy: Level 1 (intra-area), Level 2 (inter-area). IS-IS is the dominant IGP in large service provider networks because it handles a larger number of prefixes per router than OSPF in some implementations and does not require IP connectivity for adjacency formation.

Exterior Gateway Protocols

Exterior protocols route between autonomous systems. BGP is the only EGP in use on the public internet.

BGP Fundamentals

Border Gateway Protocol (RFC 4271 for BGP-4) exchanges reachability information between ASes. Each AS has a unique 16-bit (legacy) or 32-bit (RFC 6793) AS number. BGP is a path-vector protocol: routing updates include the full AS path to the destination, which prevents loops (a router discards an update containing its own AS number).

BGP peers establish TCP sessions on port 179. eBGP peers run between different ASes (typically directly connected). iBGP peers run within the same AS and must be fully meshed or use a route reflector (RFC 4456) or confederation (RFC 5065) to avoid the full-mesh requirement.

BGP Path Attributes and Decision Process

BGP selects the best route for a prefix through a multi-step decision process:

  1. Highest weight (Cisco proprietary, local to the router)
  2. Highest local preference (propagated throughout the AS)
  3. Prefer locally originated routes (network command, redistribution, aggregation)
  4. Shortest AS path (fewest AS numbers in the path)
  5. Lowest origin type (IGP < EGP < incomplete)
  6. Lowest multi-exit discriminator (MED)
  7. Prefer eBGP over iBGP
  8. Lowest IGP metric to the next hop
  9. Lowest router ID (tiebreaker)

Understanding this decision process is essential for traffic engineering — influencing which path inbound and outbound traffic takes.

BGP Communities

BGP communities (RFC 1997, RFC 8092 for large communities) are tags applied to prefixes to signal policy. Well-known communities: NO_EXPORT (65535:65281) prevents advertisement to eBGP peers; NO_ADVERTISE (65535:65282) prevents advertisement to any peer. Operators define custom communities: for example, ASN:70 might signal “prepend one AS to the AS path” to a provider, making the prefix less preferred.

MPLS

Multiprotocol Label Switching (RFC 3031) inserts a 4-byte label between the layer-2 header and the IP packet. Routers use label lookups (instead of IP prefix lookups) in the forwarding table, which is faster and enables services not possible with pure IP. MPLS underpins MPLS VPNs (RFC 4364), where labels isolate customer traffic; traffic engineering (RSVP-TE), where explicit paths are computed; and fast reroute, where a backup label-switched path is pre-established for sub-50 ms failover.

Troubleshooting Routing

Common routing failures: missing route (destination not in the routing table), incorrect next hop (next-hop IP unreachable), routing loop (packet TTL expires — traceroute shows the same routers repeating), asymmetric routing (forward and return paths differ, causing stateful firewall drops), and route flapping (a route is repeatedly added and withdrawn due to an unstable link or misconfiguration).

Diagnostic sequence: show ip route (or netstat -rn) to check the routing table. traceroute (or tracert) to map the actual path. ping to test reachability. show ip ospf neighbor / show ip bgp summary to verify protocol adjacency state.

FAQ

Q: What is the difference between routing and forwarding?
A: Routing is the control-plane process of computing the path (building the routing table). Forwarding is the data-plane process of moving the packet from input to output interface based on the routing table. Most routing failures are forwarding problems at the data plane.

Q: Why is BGP called a path-vector protocol?
A: BGP does not compute a shortest-path tree. It propagates reachability information plus the AS path vector. Each router selects the best path based on policy, not necessarily the shortest AS path. The AS path attribute is the vector that prevents loops.

Q: What is administrative distance?
A: AD is a Cisco concept that ranks the trustworthiness of routing information sources. When the same prefix is learned from OSPF (AD 110) and static (AD 1), the static route is preferred, regardless of metric. AD is not standardized — Juniper uses preference values with different defaults.

Q: How does OSPF ensure loop-free paths?
A: OSPF runs the SPF algorithm on the complete link-state database. The SPF tree is inherently loop-free because each node is visited only once. Split-horizon and poison-reverse (used by distance-vector protocols like RIP) are not needed.

Q: What is the difference between OSPF and BGP for internal routing?
A: OSPF discovers and computes paths based on link cost with fast convergence. BGP for internal routing (iBGP) carries customer VPN routes and internet routing tables but is not designed for fast convergence on internal link failures. Use OSPF/IS-IS for IGP, BGP for inter-domain.

Internal Links

References

  • RFC 2328, “OSPF Version 2”
  • RFC 4271, “A Border Gateway Protocol 4 (BGP-4)”
  • RFC 3031, “Multiprotocol Label Switching Architecture”
  • Doyle, J. and Carroll, J., Routing TCP/IP, Vol. 1 and 2, 2nd ed., Cisco Press, 2005
  • Kurose, J. F. and Ross, K. W., Computer Networking: A Top-Down Approach, 8th ed., Pearson, 2021, Section 5 (“The Network Layer: Control Plane”)
  • Tanenbaum, A. S. and Wetherall, D. J., Computer Networks, 6th ed., Pearson, 2021, Section 5.8 (“Routing in the Internet”)

For a comprehensive overview, read our article on Cabling Standards.

For a comprehensive overview, read our article on Cdn Guide.

Section: Computer Networking 1605 words 8 min read Beginner 756 articles in section Report inaccuracy Back to top