Sub topic 5
Dynamic routing: routers sharing what they know
This chapter assumes you know IPv4 addressing and CIDR prefixes, the difference between a router, a switch and a host, and basic command-line use. You should also know that a router forwards packets by looking up the destination in its routing table and choosing the longest matching prefix.
What dynamic routing does
With static routing, an administrator types every route by hand. With dynamic routing, routers run a routing protocol. A routing protocol is a set of rules that lets routers exchange information about networks and fill their routing tables automatically.
Each router follows the same cycle:
- It learns about its directly connected networks.
- It sends that information to neighbouring routers.
- It receives the neighbours' information and works out the best path to each destination.
- It installs the best paths in its routing table.
When a link fails, the routers repeat the cycle and update their tables without anyone logging in.
Worked example: enabling OSPF
OSPF (Open Shortest Path First) is a common dynamic protocol. The configuration below turns it on for one router. Any interface whose address falls inside the network statement joins OSPF and starts looking for neighbours.
! Cisco IOS: enable OSPF on interfaces in 10.1.0.0/16
router ospf 1
router-id 1.1.1.1
network 10.1.0.0 0.0.255.255 area 0The 0.0.255.255 value is a wildcard mask, which is the inverse of a subnet mask. A 0 bit must match and a 1 bit is ignored. So this statement covers every address from 10.1.0.0 to 10.1.255.255. The router ID identifies this router in the protocol. The area number groups routers, and area 0 is the backbone.
After a neighbour router is configured the same way, you can check the result:
show ip ospf neighbor
show ip route ospfRoutes marked O in the output were learned through OSPF. You never typed them.
What gets exchanged
Protocols share different information, and that difference is what separates the protocol families covered later in this tutorial.
| Approach | What routers share | Example |
|---|---|---|
| Distance-vector | Each router's list of destinations and their distances | RIP |
| Link-state | The state of each router's links, so every router builds a full map | OSPF |
| Path-vector | The list of networks a route passes through | BGP |
Benefits and costs
Dynamic routing scales better than static routing and reacts to failures by itself. It also has costs:
- Routers use CPU, memory and bandwidth to run the protocol.
- Misconfiguration spreads. A wrong advertisement can affect many routers.
- Protocols need authentication. Without it, a rogue device could inject false routes.
- Behaviour is harder to predict, so you need to know how to read the protocol's state.
Common errors
- No neighbour forms. Mismatched area IDs, timers, or authentication settings, or a
networkstatement that does not cover the interface, stop two routers from becoming neighbours. - Route missing from the table. A neighbour may be up, but the route is not advertised or is rejected. Check
show ip routeand the protocol's own database. - Wrong route wins. A static route or another protocol may have a lower administrative distance. The next chapters cover this.
Exercise
A router has the statement network 10.1.0.0 0.0.255.255 area 0 under OSPF. An interface has the address 10.2.0.1. Will it join OSPF, and why?
Show answer
No. The wildcard mask 0.0.255.255 requires the first two octets to match 10.1, and 10.2.0.1 does not match. The interface needs its own network statement that covers it.
Exercise
Name two ways dynamic routing helps when a link fails, compared with static routing.
Show answer
Routers detect the failure and recalculate paths automatically, and they install an alternate route in the routing table without an administrator editing configuration.