Before any dynamic routing protocol runs, there is a simpler, more fundamental concept: static routing — manually telling a router exactly where to send traffic for a given destination network. Static routes are predictable, use no CPU for calculations, and are often the right choice for small networks, stub networks, or specific traffic-engineering needs. This article explains static routing from first principles for both IPv4 and IPv6, covering configuration, verification, and troubleshooting.
What Is a Route, Fundamentally?
A route answers one question for a router: “For this destination network, which direction (next hop or exit interface) should I send the packet?” A router’s routing table is simply a list of these answers. When a packet arrives, the router compares its destination address against the routing table and forwards it according to the most specific matching route — a principle called the longest prefix match.
Why Use Static Routes Instead of Dynamic Routing?
| Scenario | Why Static Routing Fits |
|---|---|
| Small network with only one path in/out | No need for the overhead of a dynamic protocol |
| Stub network (only one way out) | A single default static route is simpler and sufficient |
| Specific security/traffic-engineering requirement | Precise control over exact path, not subject to protocol recalculation |
| Backup route for a dynamic protocol | Floating static routes provide predictable failover |
| Low-resource devices | No CPU overhead for route calculation |
The tradeoff: static routes do not automatically adapt to topology changes. If a link fails, a static route pointing through that link keeps trying to use it until a human intervenes (unless combined with tracking mechanisms, covered later).
Anatomy of a Static Route (IPv4)
ip route <destination network> <subnet mask> <next-hop-ip or exit-interface> [administrative distance]Example:
Router(config)# ip route 192.168.20.0 255.255.255.0 10.0.0.2This says: “To reach 192.168.20.0/24, send traffic to next-hop 10.0.0.2.”
Types of Static Routes
| Type | Example | When to Use |
|---|---|---|
| Standard (next-hop) | ip route 192.168.20.0 255.255.255.0 10.0.0.2 | Most common; specifies the IP of the next router |
| Directly connected (exit-interface) | ip route 192.168.20.0 255.255.255.0 Serial0/0/0 | Point-to-point links (e.g., serial, some WAN links) |
| Fully specified | ip route 192.168.20.0 255.255.255.0 Serial0/0/0 10.0.0.2 | Combines both — most explicit, avoids ambiguity |
| Default route | ip route 0.0.0.0 0.0.0.0 10.0.0.1 | Catch-all for any destination not explicitly matched |
| Floating static route | ip route 192.168.20.0 255.255.255.0 10.0.0.3 200 | Backup route with a higher administrative distance, used only if the primary route fails |
Why Exit-Interface vs Next-Hop Matters (A Common Gotcha)
On multi-access networks (like Ethernet), using only an exit-interface (without specifying a next-hop) can cause the router to perform an ARP request for every destination address, treating the entire subnet as if it were directly connected — this is inefficient and, in more complex topologies, can cause serious routing problems. On point-to-point links (like a serial or point-to-point GRE tunnel), this issue doesn’t arise, since there’s inherently only one possible destination for anything sent out that interface.
Best practice: Use next-hop IP for Ethernet-type interfaces, and exit-interface (or fully specified) for genuinely point-to-point links.
Administrative Distance — Why It Matters
Administrative Distance (AD) is a trustworthiness rating routers use to choose between routes to the same destination learned from different sources. Lower AD wins.
| Route Source | Default Administrative Distance |
|---|---|
| Directly connected | 0 |
| Static route | 1 |
| OSPF | 110 |
| RIP | 120 |
| Unknown / unreachable | 255 (never used) |
Static routes have a very low default AD of 1, meaning they will be preferred over almost any dynamically learned route to the same destination — a fact commonly exploited deliberately with floating static routes, which manually increase the AD (e.g., to 200) so the static route is only used as a backup, activated only if the primary (usually dynamic) route disappears from the routing table.
Configuring IPv4 Static Routes on Cisco IOS
Basic Topology Example
Router A (192.168.1.0/24) --- 10.0.0.0/30 --- Router B (192.168.2.0/24)! Router A
Router A(config)# ip route 192.168.2.0 255.255.255.0 10.0.0.2! Router B
Router B(config)# ip route 192.168.1.0 255.255.255.0 10.0.0.1Default Route Example (Stub Network to ISP)
Router(config)# ip route 0.0.0.0 0.0.0.0 203.0.113.1Floating Static Route Example (Backup Path)
Router(config)# ip route 192.168.2.0 255.255.255.0 10.0.0.2 (primary, AD 1 by default)
Router(config)# ip route 192.168.2.0 255.255.255.0 10.0.1.2 200 (backup, AD 200)The backup route only appears in the routing table (and gets used) if the primary route becomes unavailable.
Verifying IPv4 Static Routes
Router# show ip route staticS 192.168.2.0/24 [1/0] via 10.0.0.2
S* 0.0.0.0/0 [1/0] via 203.0.113.1Sindicates a static route.S*indicates the static default route (also called the “gateway of last resort”).[1/0]shows[Administrative Distance/Metric].
Router# show ip route
Router# ping 192.168.2.1
Router# traceroute 192.168.2.1IPv6 Static Routing — What’s Different
IPv6 static routing follows the same core logic as IPv4 but uses IPv6 addressing and slightly different syntax. Two conceptual points matter:
- IPv6 does not use “subnet mask” notation like
255.255.255.0— it uses prefix length notation (e.g.,/64) directly attached to the address. - IPv6 requires
ipv6 unicast-routingto be globally enabled before any IPv6 routing (static or dynamic) will function on a Cisco router — this is off by default.
Anatomy of a Static Route (IPv6)
ipv6 route <destination-prefix>/<prefix-length> <next-hop-ipv6 or exit-interface>Configuring IPv6 Static Routes on Cisco IOS
Step 1: Enable IPv6 Routing Globally
Router(config)# ipv6 unicast-routingStep 2: Configure Interface IPv6 Addresses
Router(config)# interface GigabitEthernet0/0
Router(config-if)# ipv6 address 2001:DB8:1::1/64
Router(config-if)# no shutdownStep 3: Configure the Static Route
Router(config)# ipv6 route 2001:DB8:2::/64 2001:DB8:12::2IPv6 Default Route Example
Router(config)# ipv6 route ::/0 2001:DB8:12::1::/0 is IPv6’s equivalent of IPv4’s 0.0.0.0/0 — matching any destination.
IPv6 Static Route Using Link-Local Next-Hop (Common in Real Deployments)
IPv6 often uses link-local addresses (starting with FE80::) as the next-hop, since every interface automatically has one. When doing this, you must also specify the exit interface, since a link-local address alone is not globally unique and needs interface context to be meaningful:
Router(config)# ipv6 route 2001:DB8:2::/64 GigabitEthernet0/1 FE80::2Verifying IPv6 Static Routes
Router# show ipv6 route staticS 2001:DB8:2::/64 [1/0]
via 2001:DB8:12::2Router# show ipv6 route
Router# show ipv6 interface brief
Router# ping ipv6 2001:DB8:2::1
Router# traceroute ipv6 2001:DB8:2::1Comparison Table: IPv4 vs IPv6 Static Routing
| Aspect | IPv4 | IPv6 |
|---|---|---|
| Address notation | Dotted decimal + subnet mask | Hexadecimal + prefix length (/64) |
| Global enable command needed | No (IPv4 routing is on by default) | Yes — ipv6 unicast-routing required |
| Default route syntax | ip route 0.0.0.0 0.0.0.0 | ipv6 route ::/0 |
| Common next-hop type | Global unicast address | Often link-local (FE80::), requiring exit-interface |
| Verification command | show ip route static | show ipv6 route static |
| Administrative Distance default | 1 | 1 (same default) |
Configuring and Verifying Static Routes on Linux
Linux systems can also act as routers between subnets, using the ip route command.
IPv4 Static Route on Linux
sudo ip route add 192.168.2.0/24 via 10.0.0.2 dev eth1Verify:
ip route show
ip route get 192.168.2.5IPv6 Static Route on Linux
sudo ip -6 route add 2001:db8:2::/64 via 2001:db8:12::2 dev eth1Verify:
ip -6 route showEnabling IP Forwarding on Linux (Required for the Host to Act as a Router)
sudo sysctl -w net.ipv4.ip_forward=1
sudo sysctl -w net.ipv6.conf.all.forwarding=1To make this persistent across reboots, add these lines to /etc/sysctl.conf:
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1Automating Static Route Validation with Python
import ipaddress
routing_table = [
{"destination": "192.168.2.0/24", "next_hop": "10.0.0.2"},
{"destination": "0.0.0.0/0", "next_hop": "203.0.113.1"},
]
def find_route(dest_ip, table):
dest_ip = ipaddress.ip_address(dest_ip)
best_match = None
best_prefix_len = -1
for entry in table:
network = ipaddress.ip_network(entry["destination"])
if dest_ip in network and network.prefixlen > best_prefix_len:
best_match = entry
best_prefix_len = network.prefixlen
return best_match
test_ip = "192.168.2.55"
route = find_route(test_ip, routing_table)
print(f"Traffic to {test_ip} goes via {route['next_hop']} (matched {route['destination']})")
Output:
Traffic to 192.168.2.55 goes via 10.0.0.2 (matched 192.168.2.0/24)This script demonstrates the longest prefix match principle — even though the default route 0.0.0.0/0 technically matches everything, the more specific /24 route wins because it has a longer (more specific) prefix.
Best Practices
- Use fully specified static routes (next-hop + exit-interface) on ambiguous multi-access networks to avoid proxy-ARP related issues.
- Always configure a default route on stub networks/edge routers rather than individually routing every possible external destination.
- Use floating static routes as automatic backups for dynamic routing protocols, ensuring predictable failover behavior.
- Document static routes clearly — unlike dynamic routing, there’s no automatic topology awareness, so tribal knowledge about “why this route exists” matters.
- For IPv6, always remember to enable
ipv6 unicast-routingglobally — a very common early configuration mistake. - Periodically audit static routes for relevance; stale static routes pointing to decommissioned next-hops are a common source of network confusion.
Troubleshooting
| Symptom | Likely Cause | Fix |
|---|---|---|
Static route not appearing in show ip route | Next-hop unreachable (not directly connected or via a known route) | Verify next-hop is reachable via ping, check underlying connectivity |
| Route appears but traffic still fails | Return path missing on the other router (asymmetric routing) | Add reciprocal static route on the far-end router |
| IPv6 static routes have no effect at all | ipv6 unicast-routing not enabled globally | Enable with ipv6 route unicast-routing |
| Static route using exit-interface causes strange ARP behavior | Exit-interface-only route on a broadcast (multi-access) network | Convert to next-hop or fully specified route |
| Floating static route never activates during failure | Administrative distance not set higher than the primary route source | Verify the floating route’s AD value is genuinely higher |
| Default route not used as expected | A more specific static or dynamic route exists and wins via longest prefix match | This is expected behavior — verify with show ip route which route is actually selected |
Real-World Example: Small Branch with Backup Static Route
A branch office has a primary route via OSPF and wants a floating static backup route in case OSPF fails, plus IPv4 and IPv6 default routes to the Internet.
! IPv4 default and floating backup
ip route 0.0.0.0 0.0.0.0 203.0.113.1
ip route 192.168.100.0 255.255.255.0 10.0.0.2 200
! IPv6 enable and default route
ipv6 unicast-routing
ipv6 route ::/0 2001:DB8:FFFF::1This gives the branch a working default path for both IPv4 and IPv6, plus a safety-net static route that only activates if the normally-preferred OSPF-learned path disappears.
Conclusion
Static routing is the foundation upon which all routing understanding is built — before diving into dynamic protocols, mastering exactly how a router decides “where does this packet go” using manually configured routes, administrative distance, and longest prefix match is essential. IPv4 and IPv6 static routing share the same underlying logic, differing mainly in addressing notation and the requirement to explicitly enable IPv6 routing. Combined with tools like floating static routes for backup paths, static routing remains a practical, precise, and widely used technique even in networks that also run dynamic routing protocols.
References
- Cisco IPv4 Static Routing Configuration Guide — https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/iproute_static/configuration/xe-16/irs-xe-16-book.html
- Cisco IPv6 Static Routing Configuration — https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/ipv6_basic/configuration/xe-16/ip6b-xe-16-book/ip6-route-static-xe.html
- RFC 4861 – Neighbor Discovery for IPv6 — https://datatracker.ietf.org/doc/html/rfc4861
- RFC 8200 – Internet Protocol, Version 6 (IPv6) Specification — https://datatracker.ietf.org/doc/html/rfc8200
- Linux ip route Command Documentation — https://man7.org/linux/man-pages/man8/ip-route.8.html
- Cisco Administrative Distance Reference — https://www.cisco.com/c/en/us/support/docs/ip/enhanced-interior-gateway-routing-protocol-eigrp/15986-admin-distance.html