Python · SQL · Web Dev · Java · AI/ML tracks launching soon — your one platform for all of IT

Routing Fundamentals

How packets find their way across networks — from static routes to dynamic routing protocols. Understand routing tables, Administrative Distance, Longest Prefix Match, and ECMP: the mechanisms that move data across the internet.

25–35 min May 2026

// CHAPTER 01

The Routing Problem

// REAL-WORLD SCENARIOYou send an email to someone in Tokyo. Your laptop sends it to your home router. Your home router sends it to your ISP. Your ISP sends it to a transit network. That transit network sends it to a different ISP in Japan. That ISP sends it to a data center. That data center's network sends it to the mail server. Six hops, six routing decisions. Each device along the path examined only the destination IP address and made a local forwarding decision. No device knew the entire path. No device communicated with Tokyo to ask for directions. Routing is fundamentally a distributed, local decision-making process — and that's exactly what makes it scale to the entire internet.

A router is a Layer 3 device that forwards packets between different IP networks. When a packet arrives on an interface, the router examines the destination IP address, looks it up in the routing table, and forwards the packet out the appropriate interface toward the next hop. This decision happens for every packet, billions of times per second on modern routers.

The fundamental question routing answers: given a destination IP address, which outgoing interface and next-hop IP address should this packet be sent to? The routing table is the data structure that answers this question. Each entry in the routing table contains: a destination prefix (network address + prefix length), a next-hop IP address (or outgoing interface for connected networks), and a metric (cost/preference).

🌐The BGP Default-Free Zone at Internet Scale
The global internet routing system — the BGP Default-Free Zone — contains approximately 900,000 IPv4 prefixes and 180,000 IPv6 prefixes. Every core internet router (there are hundreds of thousands) must hold all ~1.08 million routes in memory and perform TCAM-based Longest Prefix Match lookups at line rate — for terabit-per-second links, that means billions of route lookups per second per interface. The engineering behind making this work at internet scale is remarkable.

// CHAPTER 02

The Routing Table: Structure and Population

How Routes Enter the Routing Table

Routes enter the routing table through three mechanisms:

1. Connected routes (Administrative Distance = 0): automatically installed when an interface is configured with an IP address and the interface is up. If GigabitEthernet0/0 is configured with 192.168.1.1/24, the route 192.168.1.0/24 is instantly in the routing table as "Connected" via that interface.

2. Static routes (AD = 1): manually configured by the administrator. Example: ip route 10.0.0.0 255.0.0.0 192.168.1.254. Static routes don't update automatically when topology changes — they're fixed until manually removed.

3. Dynamic routes (various ADs): learned from routing protocols (OSPF, EIGRP, BGP, RIP). The protocol discovers the network topology and automatically installs routes. When topology changes (a link fails), the protocol reconverges and updates the routing table.

Administrative Distance

Administrative Distance (AD) is the "trustworthiness" of a routing information source, expressed as a number from 0 to 255. Lower is better. When multiple routing protocols learn a route to the same destination, the route from the lowest-AD source wins and is installed in the routing table.

AD is a tie-breaker between sources, not between routes within the same protocol. OSPF internal (AD=110) always loses to EIGRP internal (AD=90) when both know a route to the same prefix — regardless of OSPF's metric. The logic: some protocols are considered more reliable than others, and the administrator configures trustworthiness via AD.

Cisco IOS Default Administrative Distances:
Source                   AD
Connected                 0  (most trusted)
Static                    1
EIGRP summary route       5
eBGP                     20
EIGRP internal           90
IGRP                    100
OSPF                    110
IS-IS                   115
RIPv2                   120
EIGRP external          170
iBGP                    200
Unknown / untrustworthy 255  (never installed in routing table)

Metric

Within a routing protocol, the metric determines which of multiple paths to the same destination is best. Each protocol uses different metrics: OSPF uses cumulative interface cost (bandwidth-based, default cost = 10^8/bandwidth-bps), EIGRP uses a composite metric (bandwidth + delay + load + reliability), RIP uses hop count (number of routers crossed), BGP uses a complex set of attributes (AS path length, local preference, MED, etc.).

A route with a lower metric is preferred over a higher-metric route within the same routing protocol. If two routes have identical metrics, the router can use ECMP (Equal-Cost Multi-Path) — load balancing across multiple equal-cost paths.

Interactive — Routing Table Lookup

Enter a destination IP to see which routes match and which wins via Longest Prefix Match.

NetworkPrefixNext HopMetricProtocol
0.0.0.0/0203.0.113.11Static
10.0.0.0/810.0.0.1110OSPF
10.10.0.0/1610.10.0.1110OSPF
10.10.10.0/2410.10.10.1110OSPF
192.168.1.0/24192.168.1.11Connected
172.16.0.0/12172.16.1.11Static

// CHAPTER 03

Longest Prefix Match: The Core Algorithm

// REAL-WORLD SCENARIOA postal worker is sorting mail. The address says "100 Main Street, Springfield, IL 62701." The worker has three sorters: one for Illinois, one for Springfield, IL, and one for the specific ZIP code 62701. The most specific address wins — the ZIP-code sorter gets the mail, not the state-level sorter. Longest Prefix Match works identically: when multiple routing table entries match a destination IP, the most specific one (longest prefix) wins.

Longest Prefix Match (LPM) is the algorithm every router uses to select the best routing table entry for a destination IP address. Given multiple matching prefixes, the one with the longest (most specific) prefix length is selected.

Why LPM Enables Internet Scale

LPM enables hierarchical routing — the combination of specific routes and summary routes. An ISP can advertise a summary 10.0.0.0/8 to the internet while internally having specific routes for 10.10.10.0/24, 10.10.20.0/24, etc. Internet routers use the /8 summary; the ISP's own routers use the more specific /24 routes.

This is also how the default route (0.0.0.0/0) works. Every destination matches 0.0.0.0/0 because zero bits are checked — but any more specific route will always win via LPM. The default route is literally the "prefix of last resort" when no more specific route matches.

Floating Static Routes

A floating static route uses a higher-than-normal AD to act as a backup. Example: a primary route learned via OSPF (AD=110) and a backup static route with AD=200 to the same destination. Normally, the OSPF route wins (lower AD). If the OSPF route disappears (the dynamic routing protocol loses the route), the floating static route "floats" to the top and becomes active — automatic failover without any routing protocol reconfiguration.

! Primary route via OSPF (AD 110 — installed when OSPF learns it)
! Backup floating static (AD 200 — only installed when OSPF route gone)
ip route 10.0.0.0 255.0.0.0 192.168.2.1 200   ! AD=200

! Verify both routes
show ip route 10.0.0.0
! Should show OSPF route normally
! Disconnect OSPF neighbor — floating static appears automatically

// CHAPTER 04

Static Routing

// REAL-WORLD SCENARIOSmall networks don't need the overhead of routing protocols — a home router, a small office router, or a two-device WAN link. Static routes are the simplest form of routing: you tell the router exactly where to send traffic, no negotiation, no convergence, no CPU overhead. The downside: no automatic adaptation. A link fails, the static route stays, and traffic blackholes until a human fixes it. For simple topologies with few exit points and predictable traffic, static routing is elegant. For complex topologies, it becomes unmanageable.

Types of Static Routes

Standard static route: explicit next-hop IP and/or outgoing interface. Most common type.

Default route (0.0.0.0/0): matches all destinations with no more specific match. Every internet-connected router needs a default route pointing to the upstream ISP.

Null route: points to the null0 interface (a virtual drop interface). Packets forwarded to null0 are silently discarded. Used to create "aggregate" entries that prevent routing loops — advertise a summary /16 but route unroutable /24s to null0.

Floating static: high AD for backup when primary dynamic route disappears.

Summary static route: a single static route covering a range of more specific networks (supernet).

! Standard static route — send 10.0.0.0/8 via 192.168.1.1
ip route 10.0.0.0 255.0.0.0 192.168.1.1

! Default route — send all unmatched traffic to ISP
ip route 0.0.0.0 0.0.0.0 203.0.113.1

! Null route — discard traffic to unallocated parts of summary
ip route 10.0.0.0 255.0.0.0 null0 254   ! AD=254, only wins if no other route

! IPv6 static routes
ipv6 route 2001:db8::/32 2001:db8:1::1
ipv6 route ::/0 2001:db8::1              ! IPv6 default route

! Verify
show ip route static
show ip route 10.0.0.0

Recursive Routing and Recursion Depth

A static route specifying a next-hop IP (rather than an interface) may require recursive lookup. The router installs the route with next-hop 10.0.1.1, but must look up 10.0.1.1 in the routing table to find the outgoing interface. If that lookup yields another next-hop, the recursion deepens. If no route exists for the next-hop IP, the static route is inactive (doesn't appear in the routing table). Static routes pointing to IP addresses only work if the next-hop IP is reachable.

// CHAPTER 05

Dynamic Routing Protocols: An Overview

Dynamic routing protocols automate route distribution. Routers running the same protocol exchange routing information, build a picture of the network topology, and independently calculate the best paths. When topology changes (link failure, new subnet added), the protocol propagates the change, and all routers reconverge automatically.

Classification: Distance Vector vs. Link State vs. Path Vector

Distance Vector protocols (RIP, IGRP): each router knows only the distance (metric) to each destination and the direction (vector) to send traffic. Routers share their routing tables with neighbors. "Routing by rumor" — a router trusts its neighbor's distance without knowing the underlying topology. Slow convergence (routers don't know if a neighbor's route is loop-free) and limited scalability (15-hop max for RIP).

Link State protocols (OSPF, IS-IS): each router generates LSAs (Link State Advertisements) describing its directly connected links and neighbors. All routers flood LSAs throughout the topology. Every router has an identical Link State Database (LSDB) representing the complete topology. Each router independently runs Dijkstra's shortest-path-first (SPF) algorithm on the LSDB to calculate routing. Complete topology knowledge enables fast, loop-free convergence.

Path Vector protocols (BGP): each route advertisement includes the complete path (sequence of Autonomous Systems) to the destination. This provides loop detection (a router rejects advertisements containing its own AS). BGP is optimized for policy-based routing between organizational boundaries, not for fast convergence.

Interactive — Routing Protocol Comparator

Click a protocol to compare Administrative Distance, type, and use case.

ProtocolADTypeAlgorithmScope
Static1ManualNoneLocal only
OSPF110Link-StateDijkstra (SPF)Enterprise
EIGRP90Advanced DVDUALEnterprise (Cisco)
BGP20Path-VectorBest PathInternet
RIPv2120Distance-VectorBellman-FordSmall networks
IS-IS115Link-StateDijkstra (SPF)ISP / Datacenter
Connected0DirectNoneLocal

// CHAPTER 06

OSPF: Open Shortest Path First

// REAL-WORLD SCENARIOIn 1988, the internet was growing beyond what RIP could handle. RIP's 15-hop limit meant networks more than 15 router-hops away were unreachable. RIP's slow convergence (routers waited 30 seconds between updates) caused traffic to flow over failed paths for up to a minute. OSPF (RFC 1131, 1989) solved both problems. It was designed from the start for large networks: no hop limit, sub-second convergence, and hierarchical design via areas. Today, OSPF remains the standard interior gateway protocol for enterprise networks worldwide.

OSPF Fundamentals

OSPF forms adjacencies with neighboring routers on the same link. Adjacency formation requires: matching area ID, matching authentication (if configured), matching hello/dead timers, matching MTU (by default), and compatible subnet information. Routers exchange Hello packets (every 10 seconds on Ethernet, 30 seconds on serial by default) to establish and maintain adjacencies.

On broadcast networks (Ethernet), OSPF elects a DR (Designated Router) and BDR (Backup Designated Router) to reduce flooding overhead. All other routers (DROther) form adjacencies only with the DR and BDR, not with each other. The DR represents the network segment in the LSDB, reducing the n^2 adjacency problem to n adjacencies.

OSPF Areas

Large OSPF domains are divided into areas to limit LSA flooding and SPF calculation scope. Each area has a full LSDB; flooding of detailed LSAs is confined within the area boundary. Area 0 (the backbone area) is the hub — all other areas must connect to Area 0 (directly or via virtual links). Area border routers (ABRs) sit between areas and summarize routes at the boundary.

OSPF router types: Internal Router (all interfaces in same area), ABR (Area Border Router — connects multiple areas), ASBR (AS Boundary Router — redistributes external routes into OSPF), Backbone Router (has at least one Area 0 interface).

OSPF Cost

OSPF's metric is cost = 10^8 / bandwidth-in-bps. A 100 Mbps link has cost = 10^8 / 10^8 = 1. A 10 Mbps link has cost 10. A 1 Mbps link has cost 100. The total path cost is the sum of costs along the path. Problem: 10^8 / 10^9 (1 Gbps) = 0.1, rounded to 1 — same as 100 Mbps. OSPF can't distinguish between 100 Mbps and 1 Gbps with the default reference bandwidth. Fix: change the OSPF reference bandwidth to 10^10 (10 Gbps) or 10^12 (1 Tbps) with auto-cost reference-bandwidth 10000.

! OSPF basic configuration
router ospf 1
 router-id 1.1.1.1
 auto-cost reference-bandwidth 10000   ! 10 Gbps reference
 area 0 authentication message-digest  ! MD5 auth for area 0
 passive-interface default             ! don't send hello on access ports
 no passive-interface GigabitEthernet0/0  ! except this router link

interface GigabitEthernet0/0
 ip ospf 1 area 0
 ip ospf cost 10
 ip ospf hello-interval 10
 ip ospf dead-interval 40

! Verify OSPF
show ip ospf neighbor
show ip ospf database
show ip route ospf

// CHAPTER 07

BGP: The Internet's Routing Protocol

// REAL-WORLD SCENARIOEvery ISP, every cloud provider, every large organization that connects to the internet participates in BGP (Border Gateway Protocol). BGP is what makes the internet work as a collection of independently operated networks. When Cloudflare announces 1.1.1.0/24 to the internet, BGP propagates that announcement to every other network — within minutes, routers worldwide know to send DNS queries for 1.1.1.1 toward Cloudflare. When a cable cuts an undersea fiber link, BGP detects the failure and routes internet traffic along alternate paths — sometimes in seconds, sometimes in minutes, depending on network design.

Autonomous Systems

The internet is divided into Autonomous Systems (AS) — collections of IP prefixes under a single administrative control. Each AS has an AS Number (ASN) assigned by an RIR. Cisco's AS is 109. Google's is 15169. Cloudflare's is 13335. AWS has multiple: 16509, 14618, etc. BGP routes between autonomous systems.

eBGP (External BGP): sessions between routers in different ASes — typically over internet-facing connections. iBGP (Internal BGP): sessions within the same AS, used to distribute externally learned routes to all routers in the AS. iBGP requires a full mesh or route reflectors — every iBGP speaker needs to know all external routes.

BGP Path Selection

BGP is a policy-based protocol. When multiple paths exist to the same destination, BGP uses a 14-step selection process (the "BGP decision process") to choose the best path. Key attributes in order of precedence: Weight (Cisco proprietary, local significance), Local Preference (entire AS preference for egress paths, higher = preferred), AS Path Length (shorter = preferred), Origin (IGP preferred over EGP over Incomplete), MED (Multi-Exit Discriminator, hints to neighboring AS about preferred entry), eBGP preferred over iBGP, IGP metric to next-hop.

Network engineers manipulate BGP attributes to control traffic: increase Local Preference to prefer one ISP's paths; prepend your own AS number to make AS Path longer (encouraging neighbors to use a different path for inbound traffic); set MED to influence which of your router's IPs a neighboring AS uses as entry point.

Route Reflectors

iBGP requires all iBGP speakers to have sessions with each other (full mesh). At N routers: N×(N-1)/2 sessions. At 100 routers: 4,950 iBGP sessions. Unscalable. Route Reflectors (RR) break the full mesh requirement: instead of peering with every router, iBGP clients peer only with the Route Reflector. The RR reflects routes between clients. Large networks use hierarchical RR clusters for redundancy and scalability.

// CHAPTER 08

ECMP: Equal-Cost Multi-Path

When multiple paths to the same destination have identical metrics, most routing protocols install all of them in the routing table. ECMP (Equal-Cost Multi-Path) load balances traffic across these paths, multiplying effective bandwidth and providing automatic failover if one path goes down.

ECMP Load Balancing Methods

Per-packet: each packet is forwarded on the next path in round-robin. Maximizes bandwidth utilization but can cause packet reordering (TCP doesn't handle this well — out-of-order packets trigger retransmissions). Used primarily in high-throughput core networks where packet order is less critical.

Per-flow (5-tuple hashing): a hash of source IP, destination IP, source port, destination port, and protocol determines the path. All packets in the same flow (TCP connection, UDP session) use the same path, preserving order. Standard in most modern routers. Different flows are distributed across paths, providing aggregate load balancing while maintaining per-flow ordering.

Per-destination: all packets to the same destination IP use the same path. Simple but can cause uneven load if one destination generates significantly more traffic.

Interactive — ECMP Load Balancing

Toggle paths on/off and send flows to see ECMP routing in action.

Gi0/0ECMP
10.0.0.1 | metric: 100
Gi0/1ECMP
10.0.1.1 | metric: 100
Gi0/2ECMP
10.0.2.1 | metric: 100
Gi0/3inactive (higher metric)
10.0.3.1 | metric: 150
3 active ECMP paths — load balanced round-robin

Click "Send Flow" to simulate ECMP routing...

Unequal-Cost Load Balancing

EIGRP supports unequal-cost load balancing via the variance command. A variance of 2 means paths with metric up to 2× the best metric are eligible for load balancing. Traffic is distributed proportionally — a path with metric 200 (2× the best 100) carries half as much traffic as the best path. This is unique to EIGRP; OSPF and BGP support equal-cost only.

// CHAPTER 09

Route Redistribution

In enterprise networks, multiple routing protocols often coexist — OSPF for the campus, EIGRP for the WAN, BGP for internet connectivity. Redistribution imports routes from one routing protocol into another, allowing all routers to know all routes regardless of which protocol originally learned them.

Redistribution Mechanics

On the router running both protocols (the ASBR — Autonomous System Boundary Router), you configure redistribution in both directions. OSPF routes redistributed into EIGRP become EIGRP external routes (AD=170). EIGRP routes redistributed into OSPF become OSPF external type 2 (E2) routes.

Mutual redistribution and routing loopsRedistributing bidirectionally between two protocols creates routing loop risk. If OSPF learns a route from EIGRP redistribution, then that OSPF route is redistributed back into EIGRP, the original EIGRP route and the redistributed-back route compete for the same destination — potentially causing suboptimal paths or routing loops. Always use route-maps and distribute-lists to filter what gets redistributed, and apply route tags to mark redistributed routes so they're not redistributed back.

// CHAPTER 10

Policy-Based Routing

Destination-based routing (normal routing) forwards packets based solely on the destination IP address. Policy-Based Routing (PBR) can override routing table decisions and forward packets based on source IP, protocol, port, DSCP value, or any other packet attribute.

Use cases: force specific traffic (e.g., VoIP) to use a higher-quality link; route specific source IPs to a different ISP for legal/compliance reasons; redirect traffic for deep packet inspection; differentiate between internal and external traffic on the same destination subnet.

! PBR example: route traffic from 10.1.0.0/24 via a specific next-hop
ip access-list standard BRANCH-USERS
 permit 10.1.0.0 0.0.0.255

route-map BRANCH-PBR permit 10
 match ip address BRANCH-USERS
 set ip next-hop 192.168.2.1

interface GigabitEthernet0/1
 ip policy route-map BRANCH-PBR

// CHAPTER 11

Routing in Data Centers and Cloud

Leaf-Spine and BGP in the Underlay

Modern data center networks use a leaf-spine topology with fully routed (L3) underlay. Every link is a /31 or /30 routed link — no Spanning Tree, no L2 loops. OSPF or increasingly BGP unnumbered provides underlay routing. BGP unnumbered uses IPv6 link-local addresses for session establishment and distributes both IPv4 and IPv6 prefixes — simplifying addressing (no need for /31 subnets on every link).

EVPN-VXLAN Control and Data Plane

The overlay (tenant networks) uses VXLAN for data plane encapsulation and BGP EVPN for control plane. BGP EVPN distributes MAC/IP bindings between VTEPs, eliminating flooding. The underlay routes VXLAN UDP traffic; the overlay provides tenant L2 and L3 connectivity.

Cloud Routing: VPC Route Tables

In AWS, GCP, and Azure, routing is software-defined. Each VPC subnet has a route table. Routes are programmed via API — no routing protocol configuration. Static routes pointing to NAT gateways, transit gateways, VPC peering connections, and virtual private gateways fill the cloud route table. Cloud routing is fundamentally static, managed by control plane APIs, with automatic failover handled by the cloud platform.

// CHAPTER 12

Routing Troubleshooting

# Verify routing table
show ip route
show ip route 10.10.10.50       # lookup specific destination
show ip route summary           # count routes per protocol

# Trace the path
traceroute 8.8.8.8              # standard traceroute
traceroute 8.8.8.8 source 192.168.1.1  # source-specific

# OSPF troubleshooting
show ip ospf neighbor           # check adjacencies
show ip ospf database           # view LSDB
show ip ospf interface Gi0/0    # interface OSPF status
debug ip ospf adj               # watch adjacency formation

# BGP troubleshooting
show ip bgp summary             # BGP peer status
show ip bgp                     # BGP table
show ip bgp 8.8.8.0/24          # specific prefix details
show ip bgp neighbors 10.0.0.1  # specific peer details

# Test routing policy
ip route 10.99.99.0 255.255.255.0 null0  # inject test route
traceroute 10.99.99.1           # verify path
no ip route 10.99.99.0 255.255.255.0 null0  # cleanup

Common Routing Issues

Route not in table: check if the AD of the dynamic route is too high (another protocol's route is winning). Check if the subnet mask in the static route is wrong. Check if the next-hop IP is reachable (recursive lookup failure).

Routing loop: TTL expiry on packets cycling between routers. Traceroute shows the same pair of routers repeated. Common cause: mutual redistribution without proper filtering. Fix: add route tags, use distribute-lists to prevent redistributed routes from being redistributed back.

Asymmetric routing: packets flow via one path outbound, a different path returns. Causes stateful firewall failures (the firewall sees only one direction of a TCP session). Verify routing from both directions: check the remote router's route for the source subnet.

// CHAPTER 13

Common Misconceptions

✗ Common Mistake — Routers know the entire path to a destinationRouters only know the next hop — the immediate next router toward the destination. They have no visibility into what happens after the next hop. This is hop-by-hop routing: each router independently decides the next step based on its local routing table. The complete end-to-end path is only known from traceroute output, not from any individual router's configuration. This distributed design is what makes the internet resilient — no single failure point that "knows the route."
✗ Common Mistake — Lower metric = more trusted route sourceMetric and Administrative Distance are completely independent. AD determines which routing protocol's information is trusted (lower AD wins when multiple protocols learn the same destination). Metric determines the best path within a single routing protocol (lower metric = better path within OSPF, for example). A static route (AD=1) to 10.0.0.0/8 with any metric will always win over an OSPF route (AD=110) to the same prefix, regardless of OSPF's metric.
✗ Common Mistake — The default route is always 0.0.0.0/0The default route is technically 0.0.0.0/0 (or ::/0 for IPv6). But it is not a special route — it is simply the most general possible prefix (zero bits are checked, so every IP matches). It works by being the longest match only when no more specific route exists. "Default" just means "used when nothing else matches." There is nothing mechanically different about the default route — it's handled by the same LPM algorithm as every other route. A /0 doesn't mean "the entire internet" as some destinations; it means "any destination where I have no better information."
✗ Common Mistake — BGP is a fast routing protocolBGP is deliberately slow and conservative. It uses TCP for reliability, applies route filters and policies, and by default delays propagating route changes (MRAI — Minimum Route Advertisement Interval: 30 seconds for eBGP, 5 seconds for iBGP). BGP is designed for policy-based routing between organizations, not for fast convergence within a network. OSPF and EIGRP converge in seconds; BGP convergence after a major failure can take minutes. This is by design — BGP's policies and filtering must be processed carefully. Use IGPs (OSPF/EIGRP) inside networks; BGP is for inter-AS routing only.
✗ Common Mistake — ECMP doubles your available bandwidthECMP distributes flows across multiple equal-cost paths using per-flow hashing. In the best case (uniformly distributed traffic across many flows), aggregate bandwidth approaches N × link bandwidth. But a single elephant flow (one large TCP connection) can only use one path at a time — ECMP won't help a single flow exceed one link's capacity. The benefit is aggregate throughput across many concurrent connections, not individual flow throughput. Additionally, hash polarization — where the 5-tuple hash consistently maps flows to the same path — can cause uneven distribution.
✗ Common Mistake — Static routes are always safer than dynamic routingStatic routes don't adapt to topology changes. A failed link with a static route pointing through it causes a black hole — packets are silently discarded without any automatic recovery. Dynamic routing protocols detect failures and reconverge automatically, often within seconds. For production networks with redundant paths, dynamic routing provides both convenience and reliability that static routing cannot match. Static routes are appropriate for simple topologies (home networks, single-homed branch offices) or specific use cases (default routes, floating backup routes) — not as a general replacement for dynamic routing.

// CHAPTER 14

Interview Questions

Beginner
What is a routing table and what information does each entry contain?
A routing table is a data structure in a router that maps destination IP prefixes to next-hop information. Each entry contains: a destination network prefix (IP address + prefix length, e.g., 192.168.1.0/24), a next-hop IP address (the immediate next router) or outgoing interface (for directly connected networks), a metric (cost of the path, used to compare routes from the same protocol), the protocol source (Connected, Static, OSPF, EIGRP, BGP, etc.), and administrative distance (the trustworthiness of the route source). When a packet arrives, the router performs Longest Prefix Match on the destination IP across all table entries, selects the most specific matching prefix, and forwards the packet to the indicated next hop.
Beginner
What is Administrative Distance and how is it used?
Administrative Distance (AD) is a numeric value (0–255) representing the trustworthiness of a routing information source. Lower AD = more trusted. When multiple routing protocols learn a route to the same destination prefix, the route from the lowest-AD source is installed in the routing table; others are kept as backup. Examples: Connected = 0 (most trusted), Static = 1, OSPF = 110, RIPv2 = 120. AD is used only to break ties between different sources — it has no meaning within a single protocol (OSPF's metric is used to compare OSPF routes to each other). A floating static route uses AD=200+ so it's only used when the primary dynamic route disappears.
Intermediate
Explain Longest Prefix Match with a concrete example.
Longest Prefix Match (LPM) selects the most specific matching route table entry for a destination. Example routing table: 0.0.0.0/0 (default), 10.0.0.0/8, 10.10.0.0/16, 10.10.10.0/24. For destination 10.10.10.50: all four entries match (0.0.0.0/0 matches everything, 10.0.0.0/8 matches 10.x.x.x, 10.10.0.0/16 matches 10.10.x.x, 10.10.10.0/24 matches 10.10.10.x). LPM selects /24 — it has the longest (most specific) prefix. For destination 10.20.0.1: three entries match (0/0, 10.0.0.0/8, and 10.10.0.0/16 does NOT match since 10.20 ≠ 10.10). LPM selects /8. The default 0.0.0.0/0 is the "last resort" — only selected when no more specific route matches. TCAM hardware performs LPM in constant time regardless of table size.
Intermediate
What is the difference between distance-vector and link-state routing protocols?
Distance-vector protocols (RIP, IGRP): each router only knows distances and directions. Routes are exchanged between adjacent routers — routers propagate their routing tables. A router trusts its neighbor's distance without knowing the full topology. This "routing by rumor" creates slow convergence (changes propagate hop-by-hop) and loop risk (count-to-infinity problem). Limited by maximum hop count (RIP: 15). Link-state protocols (OSPF, IS-IS): each router generates LSAs describing its direct links and floods them throughout the network. Every router builds an identical complete topology map (LSDB). Each router independently runs Dijkstra's SPF algorithm on the LSDB to calculate shortest paths. Full topology knowledge enables fast convergence (directly detects changes rather than waiting for updates to propagate) and loop-free paths. Scales to large networks through area hierarchies.
Senior
A network engineer notices asymmetric routing — packets flow via one path but return via a different path. What causes this and why is it a problem?
Asymmetric routing occurs when forward and return paths differ. Causes: different routing policies at each end (source-based routing, different IGP configurations, different BGP policies), different AS path lengths or metrics for the two directions, PBR (Policy-Based Routing) applied in one direction only, or multiple ISP connections with outbound path controlled by one ISP's routes and inbound path controlled by another. Problems: (1) Stateful firewalls fail — they see the SYN on one interface but the SYN-ACK arrives on a different interface (or not at all from the firewall's perspective), causing the connection to be blocked or dropped. (2) NAT state tables become inconsistent — the translation is created on one firewall, return traffic arrives at a different firewall without a state entry. (3) QoS policies applied to one path don't apply to return traffic. (4) Intrusion detection systems can't correlate bidirectional traffic. Diagnosis: traceroute from both directions, compare routing tables at both endpoints, check for PBR with "show ip policy". Fix: align routing policies so both directions use the same path, or ensure stateful devices (firewalls, NAT) are in the symmetric path.
PhD
Explain how BGP controls internet traffic flow between ASes. How do operators use BGP attributes to engineer traffic paths?
BGP provides a rich set of path attributes that network operators manipulate to engineer traffic flows: Inbound traffic control (influencing how neighboring ASes reach you): AS Path Prepending — artificially lengthen the AS Path by repeating your own ASN. Neighbors prefer shorter paths, so prepended prefixes are less preferred — allows making one ISP connection "primary" and another "backup" for inbound traffic. MED (Multi-Exit Discriminator) — hints to neighboring ASes which of your routers they should use to enter your network (useful when you have multiple connections to the same neighbor AS). Communities — BGP communities (32-bit tags) allow operators to signal routing policies. Sending a community to an ISP can trigger the ISP to perform prepending or filtering on your behalf, influencing inbound paths without being at the ISP's routers. Outbound traffic control (influencing how you exit to other ASes): Local Preference — a BGP attribute shared among all iBGP peers in your AS. Higher = preferred. Set higher LP on routes learned from the preferred ISP to make all outbound traffic exit that way. Weight (Cisco-proprietary) — local to one router, controls which path that specific router prefers. Route filtering and prefix-lists — accept only specific prefixes from peers; filter out unwanted routes from entering the routing table. BGP communities for traffic shaping — well-known communities (NO_EXPORT, NO_ADVERTISE) control propagation. Advanced techniques: RFC 7999 BLACKHOLE community for DDoS mitigation (signal ISP to black-hole specific prefix). BGP Flowspec (RFC 5575) injects traffic filtering rules via BGP (firewall policies distributed as BGP attributes). RPKI (Resource Public Key Infrastructure) cryptographically validates route origins to prevent BGP hijacking. The underlying philosophy: BGP is a policy language expressed as routing. Every AS makes independent decisions about what to advertise, what to accept, and how to prefer paths — the aggregate of millions of these policies is what creates the internet's routing behavior.

🎯 Key Takeaways

  • Routing is a distributed, hop-by-hop process — each router independently decides the next step toward a destination using only its local routing table.
  • Routes enter the routing table via connected interfaces (AD=0), static configuration (AD=1), or dynamic protocols (various ADs).
  • Administrative Distance (AD) determines which routing source wins when multiple protocols know the same prefix — lower AD = higher trust; 0=Connected, 1=Static, 110=OSPF, 120=RIP.
  • Longest Prefix Match (LPM) selects the most specific matching route — a /24 beats a /16 beats a /8 beats the default /0.
  • OSPF is a link-state protocol using Dijkstra SPF on a complete topology database (LSDB); it divides domains into areas to limit LSA flooding scope.
  • BGP is a path-vector protocol between Autonomous Systems — policy-based (Local Preference, AS Path, MED, Communities) rather than metric-based.
  • ECMP distributes traffic across equal-cost paths using per-flow hashing (5-tuple) — aggregate throughput improves but single flows cannot exceed one link's bandwidth.
  • Floating static routes use a high AD to act as backup — only installed when the primary dynamic route disappears, enabling automatic failover.
  • Route redistribution allows multiple routing protocols to share route information — requires careful filtering with route tags to prevent routing loops.
  • In modern data center leaf-spine fabrics, BGP unnumbered on /31 links provides underlay routing; BGP EVPN provides overlay control plane — no Spanning Tree required.
Share

Discussion

0

Have a better approach? Found something outdated? Share it — your knowledge helps everyone learning here.

Continue with GitHub
Loading...