Introduction to Static Routing
Consider two office buildings, each with its own computer network. A computer in Building A sends a file to a computer in Building B. The devices belong to different networks, so the packet needs a route between them. A router operates at the network layer and makes the forwarding decision from the destination address. A .
The router examines the destination address in the packet header and selects an outgoing interface or next hop. It first searches for the longest matching prefix, which describes the most specific destination network. When it receives a of data, it searches its routing table for a matching entry and forwards the packet according to that entry.
This list of rules is called a routing table. An entry states which interface or next hop should receive packets for a destination prefix. Before using an entry, the router can verify next-hop or interface availability when the configuration includes a tracking mechanism. A routing table can be built in two ways:
- Dynamic Routing: Routers exchange reachability information and use protocol algorithms to calculate paths. After a topology change, a protocol can distribute new information and recalculate entries.
- Static Routing: An administrator enters a route directly into the router configuration. The entry remains until it is changed or removed, so it does not require periodic route messages to neighbors.
Parameters of a Static Route
A static route is an explicit, manually configured entry in a router's routing table. The router uses it after an administrator adds it to the configuration. Each entry defines one forwarding rule. Depending on the platform, the administrator can also set an administrative distance, a tracking reference, or a recursive next hop. Three pieces of information are required:
- Destination Network Address: The IP address of the destination network you want to reach. Together with the mask, it forms a prefix such as 10.0.0.0/24.
- Subnet Mask: A mask that tells the router which part of the destination address is the network portion and which is the host portion. It defines the size of the destination network, so an incorrect mask can match too many or too few addresses.
- Forwarding direction: This specifies how the packet is sent. It can identify the next router or an interface, and the platform may require the next hop to be reachable through a local interface:
- Next-Hop IP Address: The IP address of the next router that should receive the packet. The router must determine the interface through which that address is reachable.
- Exit Interface: The physical or logical interface through which the router sends the packet. On a point-to-point link, an interface can be sufficient for forwarding.
Example: A Simple Office Network
In this example, RouterA is connected to the network, and RouterBis connected to the network. The two routers are linked, with RouterA's interface at and RouterB's at . The destination prefix is 24 bits long, and the next-hop address belongs to the transit network between the routers.
For a PC in the network to reach a server in the network, the administrator must configure a static route onRouterA:
This command tells RouterA: If you receive a packet destined for any address in the network, forward it toRouterB at . In a real configuration, the administrator supplies the prefix, mask, and next hop in the command syntax supported by the router.
The Default Route
A router does not need a separate entry for every Internet prefix. A home router, for example, uses a special static route called the default route. The IPv6 equivalent is the ::/0 prefix.
The default route matches a destination when the table has no more-specific entry. If a route for a specific subnet exists, it takes precedence over 0.0.0.0/0. The default route connects a smaller network to a larger one, such as a home network and its Internet Service Provider (ISP). The router still applies longest-prefix matching, so a default entry does not replace a more-specific prefix. A network with one exit point is called a .
Syntax and Example
An IPv4 default route is written as 0.0.0.0/0, with destination and mask . A zero-length prefix has no fixed network bits. It matches every IPv4 address when no more-specific route exists.
A home router often has a default route pointing to the ISP router. The next hop is usually learned from the local access configuration, while the default entry covers destinations outside the home network. Local connected routes and more-specific entries remain available for internal destinations.
Destination: , Mask: , Next-Hop:
After resolves to an IP address, the computer sends the packet to its router. If no more-specific match exists, the router uses the default route toward the ISP.
Administrative Distance
A router can learn the same destination prefix from a static configuration and a dynamic protocol such as OSPF. It must select one route to install in the routing table.
In Cisco IOS, Administrative Distance (AD) is a value from 0 to 255 assigned to a routing source. For routes describing the same prefix, a lower AD gives that source preference. A protocol metric selects a path within one source, while AD compares different sources.
Default Administrative Distances
In Cisco IOS, routing protocols and other route sources have default AD values, which an administrator can usually modify. An AD of 255 marks a route as unusable for installation. Common defaults include:
| Route Source | Default AD Value |
|---|---|
| Connected Interface | |
| Static Route | |
| EIGRP | |
| OSPF | |
| RIP | |
| Unknown / Unusable |
The router first applies longest-prefix matching and only then compares sources for that prefix. A static route with the default AD of is therefore preferred over a dynamic route with a higher AD for the same prefix, but a directly connected network with AD has preference, and a static default route 0.0.0.0/0 does not replace a more-specific dynamic route.
Advantages of Static Routing
Dynamic routing is useful for large, changing networks. Static routing has practical advantages in small, stable, or deliberately limited topologies where the administrator knows the number of networks, interfaces, and alternate paths. The entries can then be compared directly with the documented links.
- Limited route exchange: Static routing does not send protocol updates, so it reduces traffic used to exchange routes. The administrator controls the configured paths, while security still requires access control and device protection. Fewer routing messages reduce information exchanged with neighbors, but they do not protect the router itself from compromise.
- Predictability and Simplicity: For an active static entry, the forwarding path is defined in the configuration. This helps analyze traffic in a small, stable network because the decision does not depend on ongoing route exchanges. Changing the path requires an explicit configuration change, so the reason for the forwarding decision is easy to identify.
- Resource Efficiency: Static routing does not run protocol calculations or maintain a neighbor and topology database. The router still uses resources for route entries and packet forwarding, but it sends no routing updates. This can suit devices and links where limiting additional traffic matters, such as simple branch links.
Disadvantages and Limitations of Static Routing
As a network grows, maintaining static routes requires more administrative work. The administrator must check prefixes, masks, next hops, and backup entries across the affected devices.
- Limited Scalability: Configuring 5 or 10 routes usually requires little work, but a network with 50 routers and hundreds of subnets means manual changes on many devices. Adding a subnet or changing the topology requires updates to the affected entries, documentation, and change records, so dynamic protocols suit larger networks better.
- Limited Fault Detection: Without a mechanism that tracks the next hop or interface, a router may continue to forward packets toward an unreachable destination. Traffic is then lost in a black hole. The administrator must detect the problem and configure an alternative route or tracking mechanism. The presence of a configuration entry does not by itself prove that the link works.
- Administrative Work: Adding an office, upgrading a link, or changing IP addressing requires manual updates on affected routers. An incorrect IP address or subnet mask can interrupt connectivity and complicate diagnosis.
Practical Use Cases for Static Routes
Static routes are useful when the set of connections and paths is known. They also define controlled exits, connect stub networks, and prepare a backup path.
- Connecting Stub Networks: A branch office connected to headquarters by one link can use a static default route pointing to the headquarters router. The entry handles traffic to networks outside the branch, while headquarters can use a route for the branch prefix.
- Creating a Backup Route (Floating Static Route): An administrator gives the static route a higher Administrative Distance than the dynamic route, for example AD for a backup to OSPF with AD . The floating route remains out of the routing table while the primary route is active. If the dynamic route is removed, for example after a link failure, the router can install the static route when its next hop remains reachable.
- Specific Route Control: An administrator can configure a route to a specific network to control the path for security monitoring or cost reasons. For the same prefix, a static route with the default AD of is preferred to a dynamic route with a higher AD. A more-specific prefix still wins over a less-specific static entry, regardless of the source's AD.