Static vs. dynamic routing and OSPF fundamentals
The downsides of static routes
In the previous chapter, you learned that routers can reach remote networks (networks they aren’t directly connected to) by manually configuring routes and pointing them toward the next router along the path to the destination network. For packets to reach the destination host, every router along the path must also have a route to that destination network.
The type of route you enter manually on a router is called a Static Route. As you saw earlier, this can be a tedious process. Also, if hosts need bi-directional communication, then every router along the path must have a route back toward the source network as well.
You can see how this becomes difficult if you had to configure static routes to 100 networks. It’s not practical, and it’s hard to maintain as networks change:
- If a static route is no longer needed, you must remember to delete it.
- If a static route needs to be changed, you must update it manually, every time.
There’s another important limitation of static routes. Because they’re configured manually, the local router doesn’t automatically know if the destination network becomes unavailable. As long as the link to the next-hop router stays up, the static route stays in the routing table. That’s because there is no inherent* mechanism in static routes that tracks whether the destination network is reachable.
(Image 156)
Image Title - Static Route to network 192.168.4.0/24 remains in R1’s routing table even though it is no longer available
R1 will remove the static route from its routing table only if the link to R2 (the next hop toward 192.168.4.0/24) goes down. Otherwise, R1 will still believe it can send traffic to 192.168.4.0/24. That wastes bandwidth across the routers, only for the packets to be dropped at R4.
Dynamic routing protocols
Static routes are still necessary in certain situations, and they have an important place in networking. However, in medium to large networks, it’s usually better to use dynamic routes by configuring a routing protocol.
Routing protocols let routers learn remote networks automatically:
- Routers advertise their directly connected networks to each other.
- Routers also advertise routes they learned from neighbors to other neighbors.
(Image 157)
Image Title - 3 Routers advertising their directly connected networks to each other
Unlike static routes, routing protocols do track route availability. If a route becomes unavailable (for example, a cable is unplugged or an interface is shut down), the routing protocol on the router where the failure occurred will alert its neighbor to remove the route from its routing table. That update then propagates to other routers that also learned the route.
(Image 158)
Image Title - R3 alerting R2 that the 192.168.4.0/24 network is down. In turn R2 alerts R1 to remove the route from its Routing Table
Once the network becomes available again, the route is automatically advertised to neighbors again.
To advertise your directly connected routes using a routing protocol, you typically enable the routing protocol on the router interface. This approach keeps configuration simpler and removes the need to manually maintain routes in the routing table.
The Open Shortest Path First (OSPF) routing protocol
One of the most widely deployed routing protocols is Open Shortest Path First (OSPF), specifically version 2, which is the version covered on the CCNA 200-301 v1.1 exam.
OSPF is a Link State routing protocol. That means routers exchange topology information until they all share the same view of the network (like a map). With an identical, up-to-date topology view, each router can calculate the shortest path to every destination.
OSPF uses the Dijkstra algorithm (also known as the “Shortest Path” algorithm). It’s the same general idea used by GPS systems: given a map and link “weights,” compute the best path.
(Image 159)
Image Title - OSPF Routers exchanging Link State Advertisements (LSAs)
In terms of Administrative Distance, OSPF has a default Administrative Distance of 110 on Cisco Routers.
Routing protocol metric (OSPF cost)
OSPF chooses the “best” path as the one with the lowest metric. In OSPF, the metric is called cost.
By default, cost is derived from the Reference Bandwidth (default 100Mbps) divided by the bandwidth of the outgoing router interface.
You can also manually set the cost on an interface to get the behavior the network administrator wants.
Routers calculate the total cost to a destination by adding the costs of all outgoing links along the path. Because each OSPF router has a full topology view, it knows the cost of each link leading to the destination.
(Image 160)
Image Title - Cost between R1 and R3 to get to the 192.168.4.0/24 network
R1 has two possible routes to reach 192.168.4.0/24:
- One path through R2
- Another path through R3
By default, modern router interfaces often have a default cost of 1, but in this example the link between R1 and R3 has been configured with a cost of 10. As a result, R1 selects the route through R2 because it has a lower total cost (cost of 3 vs. 12).
That doesn’t mean R1 discards the higher-cost route through R3. That route remains in the OSPF database as a backup. If the route through R2 fails, R1 can install the backup route into its routing table, similar to how a Floating Static Route works.
Equal cost multipath (ECMP)
Sometimes a router learns two or more routes to the same network with the same subnet mask. Consider the example below:
(Image 161)
Image Title - R1 receiving an equal cost route to 192.168.4.0/24 from both R2 and R3
Both R2 and R3 advertise 192.168.4.0/24 to R1, and both routes are calculated with a cost of 3.
When the prefix length ties, the administrative distance ties, and the routing protocol metric also ties, the router will load balance across the equal routes. It installs multiple next hops in the routing table and uses them instead of choosing only one. This behavior is called Equal Cost Multipath (ECMP).
In this case, R1 installs both routes in its routing table and alternates sending packets to R2 and R3.
To recall the order of operations when selecting the best route and installing it into the Routing table, here is the criteria in order of precedence once again:
OSPF areas
OSPF areas provide structure by dividing routers into logical groups, which is especially useful in larger OSPF deployments. An area is simply a logical grouping of OSPF Routers that have similar configurations and the same view of the entire topology.
For the CCNA 200-301 v1.1 exam, the focus is Single Area OSPF, which uses only Area 0. Area 0 is the “Backbone” area, and it’s where the core of the OSPF topology stems from.