Routing¶
Routing is how traffic moves between different networks (Layer 3), as opposed to switching, which moves traffic within a single network/VLAN (Layer 2). See VLANs & Inter-VLAN Routing for the SVI setup this section builds on.
The Routing Table¶
Every router (and Layer 3 switch) keeps a routing table: a list of known destination networks and how to reach them.
show ip route
Sample output:
Codes: C - connected, S - static, O - OSPF, D - EIGRP
C 10.0.10.0/24 is directly connected, Vlan10
C 10.0.20.0/24 is directly connected, Vlan20
S 0.0.0.0/0 [1/0] via 10.0.99.1
C— directly connected network (no config needed beyond anip addresson the interface)S— static route (manually configured)O/D— learned dynamically via OSPF / EIGRP
Longest prefix match: when multiple routes could match a destination, the router always picks the most specific (longest) matching prefix.
Static Routes¶
A static route is a manually configured path to a network. Simple, predictable, and appropriate for small networks or a single upstream path.
ip route <destination-network> <subnet-mask> <next-hop-ip>
Example — route to a remote subnet via a next-hop router:
ip route 10.0.30.0 255.255.255.0 10.0.99.1
Default Route (Gateway of Last Resort)¶
Sends any traffic that doesn't match a more specific route out to the internet/upstream router:
ip route 0.0.0.0 0.0.0.0 10.0.99.1
Verify which default route is active:
show ip route 0.0.0.0
Floating Static Route (Backup Path)¶
Add an administrative distance (AD) higher than the primary route so it's only used if the primary fails:
ip route 0.0.0.0 0.0.0.0 10.0.99.1 ! Primary, AD 1 (default)
ip route 0.0.0.0 0.0.0.0 10.0.98.1 200 ! Backup, AD 200 — only used if primary is down
Lower administrative distance = more trusted / preferred. Static routes default to AD 1; connected routes are AD 0.
Dynamic Routing¶
Dynamic routing protocols let routers automatically discover networks and adapt to topology changes (a link goes down, a new subnet is added) without manual reconfiguration. Worth it once you have more than a couple of routers or need automatic failover.
OSPF (Open Shortest Path First)¶
Industry-standard, link-state protocol. Works across multi-vendor environments (not Cisco-proprietary).
router ospf 1
network 10.0.10.0 0.0.0.255 area 0
network 10.0.20.0 0.0.0.255 area 0
router ospf 1— process ID, locally significant only (doesn't need to match between routers)network <ip> <wildcard-mask> area <area-id>— enables OSPF on any interface whose IP falls in that range, and advertises the network into the specified areaarea 0— the backbone area; simplest designs put everything in area 0
Verify:
show ip ospf neighbor ! Confirm adjacencies have formed (state should be FULL)
show ip route ospf ! Show routes learned via OSPF
EIGRP (Enhanced Interior Gateway Routing Protocol)¶
Cisco-proprietary (though now partially open), advanced distance-vector protocol. Fast convergence, easier to configure than OSPF for simple topologies.
router eigrp 100
network 10.0.10.0 0.0.0.255
network 10.0.20.0 0.0.0.255
no auto-summary
router eigrp 100— autonomous system number; must match on all routers in the same EIGRP domain (unlike OSPF's process ID)
Verify:
show ip eigrp neighbors ! Confirm adjacencies
show ip route eigrp ! Show routes learned via EIGRP
OSPF vs EIGRP — Quick Comparison¶
| OSPF | EIGRP | |
|---|---|---|
| Type | Link-state | Advanced distance-vector |
| Vendor | Open standard | Cisco (partially open since 2013) |
| Convergence | Fast | Very fast |
| Configuration | More complex (areas) | Simpler for flat topologies |
| Use case | Multi-vendor, standards-based | Cisco-only shops wanting simplicity |
Troubleshooting Checklist¶
show ip route— is the expected route present? What's the source (C/S/O/D)?show ip interface brief— is the interface up/up, with the correct IP?show ip protocols— confirm a dynamic routing protocol is actually running and which networks it's advertisingping/traceroute— confirm actual reachability, not just table entries- For OSPF/EIGRP: check neighbor state first (
show ip ospf neighbor/show ip eigrp neighbors) — no neighbor means no routes will be learned, regardless ofnetworkstatements
Related¶
- VLANs & Inter-VLAN Routing
- IP Subnetting
- Cisco IOS CLI Reference
- NAT & Private IP Ranges — how a default route's traffic typically reaches the internet