Reference notes.

Routing determines how packets travel from source to destination across networks. Routers examine destination IP addresses and forward packets based on routing tables.

Key Concepts

  • Routing table - List of destinations and next hops
  • Longest Prefix Match (LPM) - When multiple routes match a destination IP, the router always selects the most specific prefix (longest subnet mask, e.g., /24 beats /16 beats 0.0.0.0/0)
  • Administrative Distance (AD) - Trustworthiness ranking used to choose between different routing protocols advertising the same prefix (lower = preferred; e.g., connected 0, static 1, eBGP 20, OSPF 110, iBGP 200)
  • Default gateway - Where to send packets when no specific route matches (0.0.0.0/0 or ::/0)
  • Metric/Cost - Route preference within the same routing protocol (lower = preferred)
  • Hop - Each router a packet passes through

Viewing the Routing Table

  • Linux: ip route show (preferred; route -n from net-tools is legacy)
  • macOS: netstat -rn
  • Windows: route print

Static vs Dynamic Routing

TypeDescriptionUse Case
StaticManually configured routesSmall networks, specific paths
DynamicRoutes learned via protocolsLarge networks, redundancy

Dynamic Routing Protocols

Interior Gateway Protocols (IGP)

Used within an autonomous system (AS).

ProtocolTypeUse Case
OSPFLink-stateLarge enterprise networks
IS-ISLink-stateISPs, large networks
RIPDistance-vectorSmall networks (legacy)
EIGRPAdvanced distance-vectorCisco environments, FRRouting (RFC 7868)

Exterior Gateway Protocols (EGP)

ProtocolTypeUse Case
BGPPath-vectorInternet routing, between ISPs and large networks

BGP (Border Gateway Protocol)

The path-vector protocol that makes the internet work. BGP routers exchange reachability information between autonomous systems.

Key Concepts

  • AS (Autonomous System) - Network under single administrative control
  • ASN - Unique AS number (e.g., AS15169 for Google)
  • eBGP vs iBGP - eBGP (External BGP) exchanges routes between different ASes; iBGP (Internal BGP) distributes those routes within the same AS (requiring a full mesh, route reflectors, or confederations to prevent loops)
  • Peering - BGP connections between ASes
  • Prefix announcement - Advertising IP ranges you own
  • BGP Security (RPKI / ROV) - BGP historically lacked origin authentication, enabling route hijacks and leaks. RPKI (Resource Public Key Infrastructure) lets prefix holders publish signed ROAs (Route Origin Authorisations) binding prefixes to authorised ASNs so routers can drop invalid announcements via Route Origin Validation (ROV).

Why BGP Matters

  • Multihoming - Connect to multiple ISPs for redundancy
  • Traffic engineering - Control inbound/outbound traffic paths
  • DDoS mitigation - Null-route or redirect attack traffic

BGP Looking Glass

View BGP routing tables from ISP perspectives:

Policy-Based Routing

Route based on criteria beyond destination (source IP, port, protocol). Useful for sending specific traffic through different paths.

Linux as a Router

Linux can function as a router by enabling IP forwarding and configuring NAT (masquerade) for outbound traffic.

Common Issues

IssueCauseSolution
No route to hostMissing routeAdd route or check gateway
Asymmetric routingDifferent path in/outCheck routing tables both directions
Black holeRoute to nullRemove route or fix next hop
Route flappingUnstable linkCheck physical connection, dampening

See Network Troubleshooting for diagnostic tools.

See Also

  • IP Addressing — Addresses and prefixes that routers forward on
  • Container Networking — Calico and Cilium can use BGP to route pod traffic
  • VPNs — Site-to-site VPNs build encrypted tunnels (IPsec/WireGuard) and exchange routes over them via BGP, OSPF, or static routes

References