NE-05

Routing Fundamentals

Network+ / NE-05
< Network+ Hub

Learning Objectives

What Routers Do

A router connects different networks and forwards packets between them based on their destination IP address. When a packet arrives, the router examines the destination IP, consults its routing table, and forwards the packet to the next hop or directly to the destination network.

Routers operate at OSI Layer 3. Each router interface belongs to a different network (different subnet). Unlike switches, routers do not forward broadcasts -- each interface is a separate broadcast domain.

The Routing Table

Every router maintains a routing table that lists known destination networks and how to reach them. Entries are populated by directly connected networks, static routes, and dynamic routing protocols.

/* Example routing table (Cisco IOS) */ Router# show ip route Codes: C - connected, S - static, O - OSPF, R - RIP Gateway of last resort is 10.0.0.1 to network 0.0.0.0 C 192.168.1.0/24 is directly connected, GigabitEthernet0/0 C 10.0.0.0/30 is directly connected, Serial0/0/0 S 172.16.0.0/16 [1/0] via 10.0.0.1 O 192.168.2.0/24 [110/20] via 10.0.0.1, 00:05:12, Serial0/0/0 S* 0.0.0.0/0 [1/0] via 10.0.0.1 /* [admin distance/metric] -- lower is preferred */

Static Routes

Static routes are manually configured by an administrator. They never change unless modified. Ideal for small networks, stub networks, or as a backup to dynamic routing.

/* Static route syntax */ Router(config)# ip route [destination network] [mask] [next-hop IP or exit interface] /* Example: Route to 172.16.0.0/16 via next-hop 10.0.0.1 */ Router(config)# ip route 172.16.0.0 255.255.0.0 10.0.0.1 /* Default route (gateway of last resort) */ Router(config)# ip route 0.0.0.0 0.0.0.0 10.0.0.1 /* Floating static route (backup with higher AD) */ Router(config)# ip route 172.16.0.0 255.255.0.0 10.0.1.1 5 // AD of 5 means this route is only used if the primary (AD 1) fails

Administrative Distance

When multiple routing sources provide routes to the same destination, the router uses Administrative Distance (AD) to determine which source to trust. Lower AD = more trustworthy.

Route SourceDefault AD
Directly Connected0
Static Route1
EIGRP Summary5
eBGP20
EIGRP (internal)90
OSPF110
IS-IS115
RIP120
EIGRP (external)170
iBGP200
Unknown / Unreachable255
AD vs Metric:

AD selects between different routing protocols (OSPF vs RIP). Metric selects between different paths within the SAME protocol (two OSPF routes to the same destination). They solve different problems.

Dynamic Routing Protocols

Dynamic routing protocols automatically discover networks, calculate best paths, and adapt to topology changes. They fall into two categories:

Distance-Vector Routers share their entire routing table with directly connected neighbors. Path selection based on hop count or composite metric. Examples: RIP, EIGRP. Think "routing by rumor."
Link-State Routers build a complete map of the network topology, then independently calculate shortest paths. More CPU/memory, but faster convergence. Examples: OSPF, IS-IS.

RIP -- Routing Information Protocol

RIP is the simplest distance-vector protocol. It uses hop count as its metric (maximum 15 hops -- 16 is unreachable). RIPv2 supports CIDR and VLSM. It sends full routing table updates every 30 seconds via multicast (224.0.0.9).

/* RIP Configuration */ Router(config)# router rip Router(config-router)# version 2 Router(config-router)# network 192.168.1.0 Router(config-router)# network 10.0.0.0 Router(config-router)# no auto-summary /* RIP Limitations: - Max 15 hops (not suitable for large networks) - Slow convergence (hold-down timers, 180s) - Periodic full-table broadcasts consume bandwidth - No concept of link speed in metric (hop count only) */

OSPF -- Open Shortest Path First

OSPF is a link-state protocol that builds a complete topology map using Link-State Advertisements (LSAs). It uses Dijkstra's Shortest Path First (SPF) algorithm to calculate the best route. Metric is based on interface cost (derived from bandwidth).

/* OSPF Configuration (single area) */ Router(config)# router ospf 1 Router(config-router)# router-id 1.1.1.1 Router(config-router)# network 192.168.1.0 0.0.0.255 area 0 Router(config-router)# network 10.0.0.0 0.0.0.3 area 0 /* OSPF uses wildcard masks (inverse of subnet mask) 255.255.255.0 subnet mask --> 0.0.0.255 wildcard 255.255.255.252 subnet --> 0.0.0.3 wildcard */ /* OSPF Cost = Reference Bandwidth / Interface Bandwidth Default reference: 100 Mbps FastEthernet (100M): cost = 1 GigabitEthernet (1G): cost = 1 (same -- increase reference!) Fix: Router(config-router)# auto-cost reference-bandwidth 10000 */
OSPF Areas Large OSPF networks are divided into areas to reduce LSA flooding. Area 0 (backbone) is mandatory. All other areas must connect to it.
DR/BDR Election On multi-access segments, OSPF elects a Designated Router (DR) and Backup DR to reduce adjacency count. Highest priority or Router ID wins.

Routing Decision Process

When a packet arrives, the router follows this decision process:

1. Extract destination IP from the packet header 2. Perform longest prefix match against the routing table // /28 is preferred over /24 for the same destination 3. If multiple sources match, choose lowest Administrative Distance 4. If same AD, choose lowest metric 5. If equal cost paths exist, load-balance (ECMP) 6. If no match found, use default route (0.0.0.0/0) 7. If no default route, drop the packet and send ICMP Destination Unreachable

Key Takeaways