Static vs Dynamic Routing: Failover, Scale and When to Use Each

A router looks up its routing table to decide where to send each packet next. Routes can enter the table in two ways: static routing, where an administrator configures them by hand, and dynamic routing, where routers exchange information with a routing protocol and build the table automatically. Static routing is simple, puts no extra load on the router and behaves predictably, but it does not switch over automatically after a failure, and configuration and management grow as the network grows. Dynamic routing finds routes automatically with protocols such as OSPF and BGP and switches to another path after a failure. Real networks usually combine the two, for example a static default route at a site with a single exit and dynamic routing where there are redundant paths.

AspectStatic routingDynamic routing
How routes are setThe administrator configures the destination network and the next hop on each routerRouters exchange information with a routing protocol (OSPF, BGP, RIP, etc.) and find routes automatically
Behavior on failureDoes not switch over automatically; it does not notice failures beyond the neighboring router and can keep using a route that no longer worksWhen a failure is detected, it recomputes and switches to another route
Router load and bandwidthExchanges no route information, so it uses no CPU, memory or link bandwidth for thatUses CPU, memory and bandwidth to exchange route information and compute routes
Configuration effort and scaleThe amount of configuration and the risk of mistakes grow with the number of networks and routes; every change means editing all the routers involvedAdditions and changes spread automatically, so even large networks are easy to manage; but designing and configuring the protocol takes knowledge
PredictabilityBehaves exactly as configured, so it is easy to predictThe route used can change depending on the protocol's calculations
SecurityReceives no route information, so there is no risk of being fed false routesNeeds neighbor authentication and limits (filters) on accepted routes to avoid accepting false routes
Administrative distanceGenerally a low value, preferred over dynamic routes (the value varies by device, for example 1)Set per protocol (some devices use, for example, 110 for OSPF and 120 for RIP)
Where it fitsSmall networks, the default route at a site with one exit, the exit to a service providerNetworks with redundant paths, enterprise networks with many sites, and between ASes on the internet (BGP)

Figures are typical orders of magnitude and vary by process generation and product.

When to use which

Static routing
Networks with few routers and an almost fixed layout, or sites such as branch offices with only one exit, where configuring a single 0.0.0.0/0 default route is enough.
Dynamic routing
Networks with many routers, or with redundant paths that should switch over automatically after a failure. It also suits networks where routes are often added or changed.

FAQ

Can static routing switch to a backup route after a failure?

To some extent. If you configure a backup static route with a higher administrative distance than the normal route (a floating static route), it is used only when the normal route disappears from the routing table. However, the normal route disappears only in cases such as the router noticing that its own link went down, so failures further away go unnoticed. For that reason it is sometimes combined with a feature that periodically checks reachability and removes the route.

What is a default route?

A route such as 0.0.0.0/0 (::/0 in IPv6) that matches every destination. A router picks the matching route with the longest prefix (longest prefix match), so the default route is used only when no other route matches. At a site with only one exit, it is common to configure a single static default route instead of a route for each destination.

If a static route and a dynamic route exist for the same destination, which is used?

Routes with different prefix lengths are treated as different routes, and forwarding picks the longest one by longest prefix match. When both have a route to the same destination with the same prefix length, the one with the lower administrative distance goes into the routing table. Static routes generally have a lower value than dynamic ones, so the static route wins. The actual values differ between equipment vendors.

Can static and dynamic routing be used together?

Yes, and many networks combine them. For example, the head office and branches exchange routes with OSPF, while a static default route is configured at the internet exit and that default route is advertised to the other routers through OSPF.

Check your understanding

Which correctly describes dynamic routing?

  1. AAn administrator configures routes on each router by hand, and the same routes stay in use after a failure until the configuration is changed
  2. BRouters exchange route information using routing protocols and automatically switch to another path when a failure makes a route unusable
  3. CA route is chosen at random for each packet to spread the load evenly over several paths
Show answer and explanation

Answer: B. Routers exchange route information using routing protocols and automatically switch to another path when a failure makes a route unusable

Static routing means an administrator configures routes by hand. It is simple and predictable, and suits small networks or the default route of a site with only one exit, but it does not switch over automatically after a failure. In dynamic routing, routers exchange information with routing protocols such as OSPF or BGP to build their routing tables automatically, and recalculate another path when a link fails. On the internet, routes between organizations' networks (autonomous systems) are exchanged with BGP. Real networks commonly combine both.

Branch router R2 is connected to head-office router R1 over a 10.255.0.0/30 link, with R1's end at 10.255.0.1 and R2's at 10.255.0.2. When a static route to the head-office network 192.168.1.0/24 is configured on R2, which address is appropriate as the next hop?

  1. A10.255.0.1
  2. B10.255.0.2
  3. C192.168.1.1 (R1's address on the head-office LAN)
Show answer and explanation

Answer: A. 10.255.0.1

A static route specifies the destination network and the address of the next router to hand packets to (the next hop). As a rule, the next hop is the address of a neighboring router on a network to which the router is directly connected. Here it is R1's address on the other end of the link, 10.255.0.1, and R2 uses ARP to find the MAC address for it before sending frames. When a branch has only one way out, a common alternative to writing a route for each destination is to configure just one default route, 0.0.0.0/0.

A router has learned routes to the same destination, 192.168.50.0/24, from both OSPF and RIP. On this router, the administrative distance, which expresses the preference for each route source (lower is preferred), is 110 for OSPF and 120 for RIP. Which route goes into the routing table?

  1. ABoth routes are installed and used alternately for each packet
  2. BOnly the RIP route is installed
  3. COnly the OSPF route is installed
Show answer and explanation

Answer: C. Only the OSPF route is installed

Routing protocols express route quality (the metric) in different ways, such as OSPF cost and RIP hop count, so their metrics cannot be compared directly. When routes to the same destination with the same prefix length are learned from several sources, the router therefore installs the one with the lower administrative distance, a measure of how much each source is trusted. Here OSPF's 110 is lower than RIP's 120, so the OSPF route goes into the routing table. Directly connected networks commonly get 0 and static routes 1, giving lower values to what people configure, but the name and default values differ between equipment vendors.

  1. A router's routing table holds three routes: a static route 10.0.0.0/8 (next hop router A, administrative distance 1), 10.1.0.0/16 learned by OSPF (router B, 110) and 10.1.1.0/24 learned by RIP (router C, 120). To which router is a packet for 10.1.1.5 sent?
  2. A router's routing table has four routes: 0.0.0.0/0 (next hop router A), 10.0.0.0/8 (router B), 10.1.0.0/16 (router C) and 10.1.2.0/24 (router D). To which router is a packet for 10.1.5.9 sent?

Practice Network Design and Operations questions

Key terms explained

IP routing
Deciding which path packets take to reach their destination on an IP network. Each router holds a routing table, picks the route that matches the destination IP address with the longest prefix (longest-prefix match) and passes the packet to the next router. The table is built by static routing, configured by hand, or by dynamic routing, built automatically with routing protocols such as OSPF, RIP and BGP.
Router
A network-layer (layer 3) device that forwards packets between different networks. It compares the destination IP address of each packet with its routing table, picks the next router (next hop) and the outgoing interface, and sends the packet on. Home routers also bundle NAPT, a DHCP server and a firewall.
Administrative distance
A preference value for each route source, used to decide which route to install in the routing table when routes to the same destination with the same prefix length are learned from several sources, such as static routes, OSPF and RIP. Lower values are preferred. It is not used to choose between routes with different prefix lengths; that is decided by longest prefix match. The name and default values differ between equipment vendors.
Longest prefix match
The rule by which a router, when several routes in its routing table match a destination IP address, chooses the route with the longest (most specific) prefix. For example, a destination that matches both 10.0.0.0/8 and 10.1.0.0/16 uses the /16 route. The default route (0.0.0.0/0), used when nothing else matches, is the shortest possible route, with a length of 0.
OSPF (Open Shortest Path First)
A link-state routing protocol used inside an organization. Each router floods the state of its own links so that all routers share the network topology, and computes the path with the lowest total cost using Dijkstra's algorithm. Costs are generally derived from link bandwidth, and splitting the network into several areas lets it scale to large networks.
BGP (Border Gateway Protocol)
The routing protocol that exchanges routing information between ASes (autonomous systems, the units of network run by organizations such as ISPs) on the internet. It chooses routes based on attributes attached to them, such as the sequence of ASes they have passed through (AS_PATH), and on each organization's policy. Routers connect to each other over TCP port 179 to exchange information.

Related comparisons