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
  • Default gateway - Where to send packets when no specific route matches
  • Metric/Cost - Route preference (lower = preferred)
  • Hop - Each router a packet passes through

Viewing the Routing Table

  • Linux: ip route show or route -n
  • 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)
EIGRPHybridCisco environments

Exterior Gateway Protocols (EGP)

ProtocolUse Case
BGPInternet routing, between ISPs and large networks

BGP (Border Gateway Protocol)

The 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)
  • Peering - BGP connections between ASes
  • Prefix announcement - Advertising IP ranges you own

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.

References