Skip to main content

Routing

What is Routing?

  1. Identify the destination IP address (in the packet)
  2. If the destination IP address is on a locally connected subnet
    • Forward the packet to the local device.
  3. If the destination IP address is not on a locally connected subnet
    • Forward to the next-hop router/gateway
    • This "map" of forwarding location is called the routing table.

1. Static vs Dynamic Routing

Static Routing

  • Manually configured routes by administrator.
    • Pros: Simple, secure (no protocol overhead), predictable
    • Cons: No automatic failover, hard to scale, manual updates required
    • Default administrative distance (AD): 1 (very trusted)
    • Common use: Small networks, default route to internet (gateway of last resort)

Dynamic Routing

  • Routers automatically learn and share routes using routing protocols.
    • Pros: Adapts to changes (link failure, new networks), scales well
    • Cons: More complex, protocol overhead, potential security risks
    • Types: Interior Gateway Protocols (IGP) for inside one organization, Exterior Gateway Protocol (EGP) for between organizations

2. Key Routing Protocols (Basics for Network+)

OSPF (Open Shortest Path First)

  • Link-state protocol
  • Open standard (multi-vendor)
  • Uses areas (single-area common for smaller networks; Area 0 is backbone)
  • Metric: Cost (based on bandwidth; lower cost = better path)
  • Fast convergence
  • Administrative distance: 110
  • Best for medium/large enterprise networks

EIGRP (Enhanced Interior Gateway Routing Protocol)

  • Advanced distance-vector (hybrid) protocol
  • Cisco proprietary (but now partially open)
  • Fast convergence, supports unequal-cost load balancing
  • Metric: Composite (bandwidth + delay + load + reliability; defaults to bandwidth + delay)
  • Administrative distance: 90 (internal)
  • Common in Cisco-only environments

BGP (Border Gateway Protocol)

  • Path-vector protocol
  • Exterior Gateway Protocol (EGP)
  • Used on internet edge routers (between autonomous systems/AS)
  • Makes policy-based decisions (attributes like AS path, local preference)
  • Very scalable for global internet routing
  • Administrative distance: 20 (eBGP), 200 (iBGP)
  • Slow convergence compared to IGPs

Quick Comparison Table

ProtocolTypeVendorMetric BasisADBest For
OSPFLink-stateOpenCost (bandwidth)110Enterprise, multi-vendor
EIGRPAdvanced DVCiscoBandwidth + delay90Cisco networks, fast
BGPPath-vectorOpenPolicy/attributes20/200Internet, between AS

3. Route Selection Process

Routers choose best route using 3-step logic (longest prefix first):

  1. Longest Prefix Match (most specific route)

    • /30 beats /24 beats /16 (prefix length highest wins)
  2. Lowest Administrative Distance (if prefix same)

    • AD measures trustworthiness of source (lower = better)
    • Directly connected: 0
    • Static: 1
    • EIGRP: 90
    • OSPF: 110
    • BGP eBGP: 20, iBGP: 200
  3. Lowest Metric (if AD same)

    • Protocol-specific cost to destination
    • Lower metric wins

4. NAT and PAT

NAT (Network Address Translation)

  • Translates private IP to public IP (hides internal network)
  • Types: Static NAT (1-to-1), Dynamic NAT (pool), PAT (overloading)
  • Solves IPv4 address exhaustion

PAT (Port Address Translation) / NAT Overload

  • Most common form
  • Many private IPs share one public IP using different ports
  • Router tracks sessions with port numbers
  • Command example (Cisco): ip nat inside source list 1 interface Gi0/0 overload

5. First Hop Redundancy Protocol (FHRP)

Provides gateway redundancy (default gateway failover).
Hosts use virtual IP/MAC as gateway.

HSRP (Hot Standby Router Protocol)

  • Cisco proprietary
  • Active router forwards traffic, standby takes over if active fails
  • Virtual IP shared, priority determines active (default 100)

VRRP (Virtual Router Redundancy Protocol)

  • Open standard (RFC)
  • Similar to HSRP
  • Master router forwards, backup takes over
  • Priority default 100, higher wins

Key: Both create virtual router with VIP; clients point to VIP as gateway.

6. Subinterfaces

Used on router for inter-VLAN routing (router-on-a-stick).

  • Single physical interface divided into logical subinterfaces
  • Each subinterface tagged with VLAN ID (802.1Q)
  • Example config (Cisco):
    interface Gi0/0.10
    encapsulation dot1Q 10
    ip address 192.168.10.1 255.255.255.0

Common on trunk link from switch to router.

Common Exam Scenarios

  • Why static route preferred over OSPF? (Lower AD: 1 vs 110)
  • Route with /26 vs /24 to same network? (/26 wins – longest prefix)
  • NAT/PAT needed? (Private to public translation, conserve IPs)
  • HSRP/VRRP down? (Active/master failed, no preemption or priority mismatch)
  • Subinterface missing encapsulation? (No VLAN tagging, traffic dropped)