Sub topic 13
Choosing static, dynamic or a combination
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 on a router or Linux host. It also assumes you have seen longest-prefix match, administrative distance and floating static routes in earlier chapters. Here you use them to make a design decision.
The decision in one sentence
Use static routes where the topology is small, stable and has one way out. Use a dynamic routing protocol where the network is large, changes often or has several paths that must fail over without a person. Use both where parts of the network differ, which is the usual case.
Neither approach is better in general. Each trades effort, resilience and overhead differently.
What each approach costs
| Factor | Static routing | Dynamic routing |
|---|---|---|
| Configuration effort | Grows with every route on every router | A few commands per router, then routes are learned |
| Reaction to failure | None by itself. A dead next hop stays in the table until someone removes it or tracking is configured | Detects loss of neighbors and recomputes paths |
| CPU, memory, bandwidth | Almost none | Neighbor traffic, a topology database or route table, and path calculations |
| Predictability | Exactly the path you wrote | Path depends on metrics and current topology |
| Security surface | No routing messages to spoof | Needs neighbor authentication and route filtering |
| Skill needed | Low | Higher, including protocol troubleshooting |
Two points in this table decide most real cases.
The first is failure handling. A static route to a next hop on a directly connected Ethernet link is not removed when the next hop dies, because the local interface is still up. The router keeps sending packets to a device that is not there. A dynamic protocol notices the missing hellos or updates and withdraws the path.
The second is scaling. With N routers and many subnets, hand-edited routes multiply, and one typo or missed update can create a black hole (traffic that is silently dropped) or a loop.
Factors to weigh
Check these in order for each part of your network.
- Size. A handful of routers and subnets is manageable by hand. Dozens of routers or hundreds of prefixes are not.
- Rate of change. If subnets are added, moved or renumbered often, dynamic routing saves repeated edits.
- Redundancy. If there is more than one path and traffic must switch automatically, you need a protocol, or a floating static route with tracking for simple cases.
- Number of exits. One exit means a default route is enough. Several exits to choose between needs metrics or policy.
- Trust and control. Where you do not control the other side, such as a customer link, a static route avoids accepting whatever the neighbor announces.
- Device capability. A small branch router or an embedded Linux host may lack the memory or the protocol support for a full routing process.
- Operations. Consider who maintains it and how they will troubleshoot at 3 a.m.
Typical fits
Stub networks
A stub network has exactly one connection to the rest of the network. A branch office with one uplink is the classic case. The router needs only a default route toward the upstream router. A routing protocol here adds traffic and risk and gains nothing, because there is no alternative path to choose.
! Cisco IOS: branch router with one uplink
ip route 0.0.0.0 0.0.0.0 192.168.1.1The upstream router still needs to reach the branch prefix. It can have a static route for it, or learn it from a protocol.
Core and campus networks
A campus or data-center network with many routers and redundant links benefits from a link-state protocol such as OSPF. It converges after a failure without anyone logging in, and a new subnet is advertised by one network statement at the edge.
Links to other organizations
Between your network and an ISP or partner, use whichever fits the relationship. A single-homed customer often uses a static route toward the ISP, and the ISP uses a static route back. A customer with two ISPs or its own address space usually runs BGP, which gives policy control that static routes cannot.
Small home or lab setups
A Linux host or home router with one gateway needs one default route. Adding a protocol daemon is rarely justified.
Combining both
Real networks mix the two. Common patterns:
- Default route plus dynamic interior. The interior runs OSPF. One edge router holds a static default route to the internet and advertises it into OSPF. Other routers learn the default dynamically.
- Static for stubs, dynamic for the core. Branches use a default route. The core has static routes pointing at each branch, and those are redistributed into the protocol so the rest of the core can reach them.
- Floating static as backup. The primary path is learned by OSPF. A static route to the same prefix with a higher administrative distance sits idle until the OSPF route disappears.
- Static where policy must be exact. You may pin traffic to one specific path even though a protocol would pick another.
The floating static pattern relies on administrative distance. This is the example from the earlier chapter.
! Cisco IOS: primary path learned by OSPF (default administrative distance 110)
router ospf 1
router-id 1.1.1.1
network 10.1.0.0 0.0.255.255 area 0
! Backup static route with administrative distance 200, used only if the OSPF route disappears
ip route 10.2.0.0 255.255.0.0 192.168.2.2 200Because 200 is higher than OSPF's 110, the router prefers the OSPF route for 10.2.0.0/16. When the OSPF route is lost, the static route enters the table.
! Cisco IOS: inspect the routing table
show ip route
show ip route static
show ip route ospf
show ip route 10.2.5.7A caution about mixing
Redistributing static routes into a protocol, or one protocol into another, is covered in a later chapter. For now, remember that it can produce loops and suboptimal paths if metrics and distances are not planned. Keep each mix simple and documented.
A worked example
A company has a head office, a data center and 12 branches.
- Branches: each has one WAN link. Use a static default route toward the head office. No protocol runs there.
- Head office and data center: four routers with redundant links. Run OSPF between them so a link failure reroutes traffic automatically.
- Branch prefixes: the head-office router has a static route for each branch and redistributes them into OSPF, so the data center can reach every branch.
- Internet exit: one static default route on the edge router, advertised into OSPF.
- Backup WAN to the data center: a floating static route with administrative distance 200 for the data-center prefix, in case OSPF loses the primary.
This design uses a protocol only where there are several paths. The 12 branches add no routing traffic and no protocol state.
Common mistakes
- Static route to a next hop that can fail silently. On an Ethernet segment, the interface stays up when the neighbor dies. Use a routing protocol, or tie the route to a tracked reachability check, so it is withdrawn.
- Missing return route. A packet may reach the destination, but replies have no route back. Check both directions.
- Floating route with a distance that is too low. If its distance is below the protocol's, the static route always wins and the protocol path is never used. If it equals the protocol's, the behavior can be unclear. Use a clearly higher value.
- Running a protocol on a stub link. It adds neighbors, messages and an attack surface for no benefit.
- Overlapping static prefixes. Longest-prefix match picks the more specific route, which can send traffic somewhere you did not intend when you add a /24 inside an existing /16.
- No documentation. Static routes are easy to forget. List them with their purpose.
Verifying your choice
After configuring, check that the route you intended is the one in use. On Linux, ask the kernel directly.
# Show the routing table
ip route show
# Ask the kernel which route it would use for one destination
ip route get 10.2.5.7On a Cisco router, show ip route 10.2.5.7 shows which source supplied the winning route. To test failover, shut the primary link in a lab and confirm that the floating static route appears, then restore the link and confirm the dynamic route returns.
Summary of the decision
| Situation | Suggested approach |
|---|---|
| One uplink, small site | Static default route |
| Many routers, redundant links, frequent change | Dynamic protocol such as OSPF |
| Two organizations, single link | Static routes on both sides |
| Multiple ISPs or own address space | BGP |
| Dynamic primary with a simple backup | Dynamic route plus floating static route |
| Mixed network | Static at the edges, dynamic in the core |
Exercise
A branch office has one router with a single uplink to head office. The head office has four routers with redundant links between them. Which routing approach would you use in each place, and why?
Show answer
Use a static default route on the branch router, because it has only one exit and a protocol would add traffic and risk without giving it a choice of paths. Use a dynamic protocol such as OSPF among the four head-office routers, because redundant links need automatic rerouting when one fails. Give the head office a way to reach the branch prefix, either a static route redistributed into OSPF or a protocol adjacency.
Exercise
You configure a backup static route for 10.2.0.0/16 with administrative distance 90 while OSPF (distance 110) also learns that prefix. What happens, and what should you change?
Show answer
The static route has the lower distance, so it is preferred over OSPF at all times, and the OSPF path is never used while the static route is valid. Change the static route's administrative distance to a value above 110, such as 200, so it works as a floating backup.
Exercise
Why can a plain static route to a next hop on an Ethernet link keep sending traffic to a dead neighbor, and name two ways to avoid it.
Show answer
The local Ethernet interface stays up when the neighbor fails, so the router still considers the next hop reachable and keeps the route in the table. Avoid it by running a dynamic routing protocol, which detects missing neighbor messages, or by tying the static route to a tracked reachability check so it is removed when the next hop stops responding.