Static Routing
Static routing is a method of route control in which the administrator manually configures the mapping between destination networks and next hops on a router. Routing falls into two categories: this static routing, and dynamic routing, in which routing protocols exchange route information with neighboring routers to learn routes automatically. This article focuses on static routing, going into more depth on command syntax and the points to keep in mind when configuring it. For the basics of how routing itself works, see Routing.
On Cisco IOS(-XE), static routes are configured using the ip route command (for IOS XR, see IOS XR IPv4 Static Route Configuration).
Router(config)# ip route <destination network> <subnet mask> {<next-hop IP address> | <outgoing interface>} [administrative distance]Specifying the Next Hop
The ip route command lets you specify the packet’s forwarding destination as a “next-hop IP address,” an “outgoing interface,” or a combination of both.
Specifying a Next-Hop IP Address
This method directly specifies the IP address of the adjacent router. On multi-access links such as Ethernet, this is the commonly used approach.
Router(config)# ip route 192.168.2.0 255.255.255.0 10.1.2.2With this configuration, for packets destined to 192.168.2.0/24, the routing table must look up a separate route again (typically a directly connected route) to reach the next hop 10.1.2.2. This is called a recursive lookup. Note that if no route to the next hop 10.1.2.2 itself can be found, this configuration will not take effect.
Specifying an Outgoing Interface
This method directly specifies which of the router’s own interfaces to send the packet out of.
Router(config)# ip route 192.168.2.0 255.255.255.0 GigabitEthernet1On point-to-point links (such as serial links, where only one device is connected on the other end of the link), specifying just the outgoing interface is enough to uniquely determine the forwarding destination, so this method works fine. However, when you use this method on a multi-access link such as Ethernet, the router treats the destination network as if it were directly connected to that interface and sends an ARP request for the final destination IP address itself. It cannot resolve the MAC address unless the neighboring router answers on its behalf via Proxy ARP, and even when it can, the ARP table keeps growing with one entry per destination host — so this method is not recommended.
Specifying Both
You can also specify both the next-hop IP address and the outgoing interface together.
Router(config)# ip route 192.168.2.0 255.255.255.0 GigabitEthernet1 10.1.2.2Because the outgoing interface is explicit, no recursive lookup is needed, and the forwarding destination is uniquely identified even on a multi-access link — making this the recommended syntax in many environments. The static routes used in the test environment in Routing are also configured using this syntax.
1. Floating static routes, which build on this concept, are covered in Floating Static Route, and the default AD values are listed in Administrative Distance (AD).Default Route (Static)
By specifying both the destination network and subnet mask as 0.0.0.0, you can statically configure a default route — the forwarding destination for packets that match no other route.
Router(config)# ip route 0.0.0.0 0.0.0.0 10.1.2.1In the test environment used in Routing, R2 is configured with a default route in this form, which also appears in the show ip route output as S* (candidate default). This is especially common in configurations such as stub networks (networks with only a single exit point to the outside), where there’s no need to configure individual routes in detail.
Verification on Real Devices
To verify static routing in practice, we set up a test environment with three routers (R1-R3) between HOST1 and HOST2.
Each router has the following static route configured.
| Router | Configured Static Route |
|---|---|
| R1 | ip route 0.0.0.0 0.0.0.0 GigabitEthernet1 10.1.2.2 (default route) |
| R2 | ip route 192.168.1.0 255.255.255.0 GigabitEthernet1 10.1.2.1ip route 192.168.2.0 255.255.255.0 GigabitEthernet2 10.2.3.3 |
| R3 | ip route 0.0.0.0 0.0.0.0 GigabitEthernet1 10.2.3.2 (default route) |
R1 and R3, sitting at the edge of the segments where HOST1 and HOST2 connect, have no destination other than the opposite R2, so each is configured with only a default route. R2, acting as the relay, has a separate static route for each of the two segments (192.168.1.0/24 and 192.168.2.0/24) since the exit path differs for each destination.
Each Router’s Routing Table
R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, m - OMP
n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
H - NHRP, G - NHRP registered, g - NHRP registration summary
o - ODR, P - periodic downloaded static route, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
& - replicated local route overrides by connected
Gateway of last resort is 10.1.2.2 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 10.1.2.2, GigabitEthernet1
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.1.2.0/24 is directly connected, GigabitEthernet1
L 10.1.2.1/32 is directly connected, GigabitEthernet1
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet2
L 192.168.1.1/32 is directly connected, GigabitEthernet2
R1#R2#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, m - OMP
n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
H - NHRP, G - NHRP registered, g - NHRP registration summary
o - ODR, P - periodic downloaded static route, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
& - replicated local route overrides by connected
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
C 10.1.2.0/24 is directly connected, GigabitEthernet1
L 10.1.2.2/32 is directly connected, GigabitEthernet1
C 10.2.3.0/24 is directly connected, GigabitEthernet2
L 10.2.3.2/32 is directly connected, GigabitEthernet2
S 192.168.1.0/24 [1/0] via 10.1.2.1, GigabitEthernet1
S 192.168.2.0/24 [1/0] via 10.2.3.3, GigabitEthernet2
R2#R3#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, m - OMP
n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
H - NHRP, G - NHRP registered, g - NHRP registration summary
o - ODR, P - periodic downloaded static route, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
& - replicated local route overrides by connected
Gateway of last resort is 10.2.3.2 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 10.2.3.2, GigabitEthernet1
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.2.3.0/24 is directly connected, GigabitEthernet1
L 10.2.3.3/32 is directly connected, GigabitEthernet1
192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.2.0/24 is directly connected, GigabitEthernet2
L 192.168.2.1/32 is directly connected, GigabitEthernet2
R3#Verifying Reachability from HOST1 to HOST2
Running ping from HOST1 (192.168.1.100) to HOST2 (192.168.2.100) succeeds.
$ ping -c 5 192.168.2.100
PING 192.168.2.100 (192.168.2.100) 56(84) bytes of data.
64 bytes from 192.168.2.100: icmp_seq=1 ttl=61 time=5.61 ms
64 bytes from 192.168.2.100: icmp_seq=2 ttl=61 time=5.25 ms
64 bytes from 192.168.2.100: icmp_seq=3 ttl=61 time=5.07 ms
64 bytes from 192.168.2.100: icmp_seq=4 ttl=61 time=5.09 ms
64 bytes from 192.168.2.100: icmp_seq=5 ttl=61 time=5.79 ms
--- 192.168.2.100 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4007ms
rtt min/avg/max/mdev = 5.068/5.361/5.792/0.288 msA router never rewrites a packet’s source or destination IP address; it only decrements the TTL by 1 at each hop. The Echo Reply that HOST2 sent with an initial value of 64 passes through three routers (R3, R2, and R1), so it is displayed as ttl=61 on the receiving side, HOST1. This confirms the packet traversed three routers on its way to the destination.
How Each Router’s Routing Table Forwards the Traffic
A packet from HOST1 to HOST2 (destination IP: 192.168.2.100) is forwarded by consulting each router’s routing table as follows.
1. HOST1 → R1
Since 192.168.2.100 is not part of its own directly connected network (192.168.1.0/24), the packet is sent to the default gateway, R1 (192.168.1.1).
2. R1 → R2
R1’s routing table has only the directly connected networks (10.1.2.0/24 and 192.168.1.0/24) and a default route, and no route matches 192.168.2.100, so the default route applies.
Gateway of last resort is 10.1.2.2 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 10.1.2.2, GigabitEthernet1
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.1.2.0/24 is directly connected, GigabitEthernet1
L 10.1.2.1/32 is directly connected, GigabitEthernet1
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet2
L 192.168.1.1/32 is directly connected, GigabitEthernet2The packet is forwarded out GigabitEthernet1 to the next hop, 10.1.2.2 (R2).
3. R2 → R3
192.168.2.100 matches the static route for 192.168.2.0/24, so that route applies.
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
C 10.1.2.0/24 is directly connected, GigabitEthernet1
L 10.1.2.2/32 is directly connected, GigabitEthernet1
C 10.2.3.0/24 is directly connected, GigabitEthernet2
L 10.2.3.2/32 is directly connected, GigabitEthernet2
S 192.168.1.0/24 [1/0] via 10.1.2.1, GigabitEthernet1
S 192.168.2.0/24 [1/0] via 10.2.3.3, GigabitEthernet2The packet is forwarded out GigabitEthernet2 to the next hop, 10.2.3.3 (R3). Because R2 has a dedicated route to both the HOST1 side (192.168.1.0/24) and the HOST2 side (192.168.2.0/24), it can decide the outgoing path per destination without relying on a default route.
4. R3 → HOST2
192.168.2.100 falls within R3’s own directly connected network (192.168.2.0/24), so the routing table lookup resolves it as a locally attached network rather than a route toward another router.
Gateway of last resort is 10.2.3.2 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 10.2.3.2, GigabitEthernet1
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.2.3.0/24 is directly connected, GigabitEthernet1
L 10.2.3.3/32 is directly connected, GigabitEthernet1
192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.2.0/24 is directly connected, GigabitEthernet2
L 192.168.2.1/32 is directly connected, GigabitEthernet2The packet is delivered directly out GigabitEthernet2 to HOST2’s MAC address, resolved via ARP.
The reply (Echo Reply) from HOST2 to HOST1 follows the same flow with source and destination swapped: HOST2 sends it to its default gateway, R3 (192.168.2.1); R3 forwards it via its default route to R2 (10.2.3.2); R2 forwards it via its static route to R1 (10.1.2.1); and R1 delivers it directly to the connected HOST1. Because the router in the middle of the path (R2) keeps a dedicated route for each direction, bidirectional reachability between HOST1 and HOST2 is established across the network as a whole.
Download R1 config (r1_static.cfg)
Download R2 config (r2_static.cfg)
Download R3 config (r3_static.cfg)
Advantages and Disadvantages of Static Routing
A comparison between static routing and dynamic routing is summarized in Routing, but a point specific to static routing worth calling out is that route changes or failures require manual intervention by the administrator. In small networks with few routes, or in configurations like stub networks where the routes essentially never change, this is far outweighed by the benefit of avoiding the learning and operational overhead of a dynamic routing protocol.
References
| RFC | Title | Overview |
|---|---|---|
| RFC 1812 | Requirements for IP Version 4 Routers | Defines requirements for IPv4 routers, including concepts related to route selection and administrative-distance-like preference. |