🛣️ Static Routes

Routing 1: three routers, two computers, and the one rule every network beginner learns the hard way: a ping needs a road there AND a road back.

Video: Static Routes (Networking video)
Prefer to watch? This short video runs this page's main commands on three real FRR routers in Docker, with on-screen captions and a synthetic voiceover (an AI voice trained on the author's own recording). Click to play, or watch it on YouTube.
Routing 1: static routes on three routers

What you will learn:
   how a router decides where a packet goes (its routing table)
   how to add a static route, and why the first one you add does not fix anything yet
   the return path, default routes, and what happens when a link goes down
   the Cisco IOS command for each step, side by side

A router only knows two kinds of networks on its own: the ones plugged straight into it. Everything else, you have to tell it about. A static route is you telling it, by hand: "to reach that network, hand the packet to this neighbour."
Every command and every line of output on this page was run for real on 2026-11-21, in a small lab of three routers and two computers on one Linux PC. The routers run FRRouting (FRR) 10.7.1, the open-source router software used in many real networks, whose command line was modelled on Cisco's. The computers are tiny Alpine Linux containers. Where Cisco IOS types a command differently, the Cisco version is shown next to it; those Cisco lines are for reference and were not run here, because the lab has no Cisco gear.

The lab

Five boxes in a line. h1 wants to talk to h3, three routers away:

   h1 ---- r1 ---- r2 ---- r3 ---- h3
 10.1.0.10     |       |       |     10.3.0.10
        LAN 1  |link 12|link 23| LAN 3
   10.1.0.0/24  10.0.12.0/24  10.0.23.0/24  10.3.0.0/24

   r1: 10.1.0.1 (LAN 1)    10.0.12.1 (link 12)
   r2: 10.0.12.2 (link 12) 10.0.23.2 (link 23)
   r3: 10.0.23.3 (link 23) 10.3.0.1  (LAN 3)

h1's default gateway is r1 (10.1.0.1) and h3's is r3 (10.3.0.1), exactly like a PC on an office LAN.
New to the /24 part? It means "the first three numbers are the network". Try 10.1.0.0/24 in the subnet calculator on the Tools page.

Check what the router is running (on the routers, vtysh is the Cisco-style command line):
$ vtysh -c "show version"
FRRouting 10.7.1_git (r1) on Linux(7.0.0-42-generic).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

Step 1: the ping that fails

From h1, ping h3:
h1$ ping -c2 -W1 10.3.0.10
PING 10.3.0.10 (10.3.0.10): 56 data bytes

--- 10.3.0.10 ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss

Why? Ask r1 what it knows:
r1# show ip route
Codes: K - kernel route, C - connected, L - local, S - static,
       ...
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup

IPv4 unicast VRF default:
C>* 10.0.12.0/24 is directly connected, eth1, weight 1, 00:00:06
L>* 10.0.12.1/32 is directly connected, eth1, weight 1, 00:00:06
C>* 10.1.0.0/24 is directly connected, eth0, weight 1, 00:00:06
L>* 10.1.0.1/32 is directly connected, eth0, weight 1, 00:00:06

How to read it:
   C   connected: a network plugged straight into this router
   L   local: the router's own address on that network
   >*  "this is the best route, and it is installed": the one actually used
r1 knows LAN 1 and link 12. It has never heard of 10.3.0.0/24, so it throws h1's packet away.
Cisco IOS: same command, show ip route. The codes look almost identical.

Step 2: one static route (and why it is not enough)

Tell r1 how to reach LAN 3: "send it to r2".
r1# configure terminal
r1(config)# ip route 10.3.0.0/24 10.0.12.2
r1(config)# end

Cisco IOS writes the mask out in full instead of /24:
   ip route 10.3.0.0 255.255.255.0 10.0.12.2

Ping again:
h1$ ping -c2 -W1 10.3.0.10
2 packets transmitted, 0 packets received, 100% packet loss

Still nothing. traceroute shows where it dies:
h1$ traceroute -n -w1 -m4 10.3.0.10
traceroute to 10.3.0.10 (10.3.0.10), 4 hops max, 46 byte packets
 1  10.1.0.1  0.008 ms  0.006 ms  0.005 ms
 2  *  *  *
 3  *  *  *
 4  *  *  *

r1 now forwards the packet to r2. But r2 has never heard of LAN 3 either, so it drops it. Every router on the path needs to know the way: a route on r1 alone only gets the packet one hop.

Step 3: the middle router

r2 needs two routes: LAN 3 is behind r3, and (for the replies) LAN 1 is behind r1.
r2# configure terminal
r2(config)# ip route 10.3.0.0/24 10.0.23.3
r2(config)# ip route 10.1.0.0/24 10.0.12.1
r2(config)# end

h1$ ping -c2 -W1 10.3.0.10
2 packets transmitted, 0 packets received, 100% packet loss

Still failing, and this is the lesson that trips up everyone: the ping now REACHES h3. h3 answers, hands the reply to its gateway r3, and r3 has no idea where 10.1.0.10 is. The reply is the part that dies.
A ping is two journeys. The road there is not the road back.

Step 4: the return path

Give r3 the way back to LAN 1:
r3# configure terminal
r3(config)# ip route 10.1.0.0/24 10.0.23.2
r3(config)# end

h1$ ping -c2 -W1 10.3.0.10
PING 10.3.0.10 (10.3.0.10): 56 data bytes
64 bytes from 10.3.0.10: seq=0 ttl=61 time=0.272 ms
64 bytes from 10.3.0.10: seq=1 ttl=61 time=0.258 ms

--- 10.3.0.10 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss

It works. ttl=61: h3's reply started at 64 and passed through three routers, each taking one off.
r2's table now has both static routes, marked S:
r2# show ip route
C>* 10.0.12.0/24 is directly connected, eth0, weight 1, 00:00:24
L>* 10.0.12.2/32 is directly connected, eth0, weight 1, 00:00:24
C>* 10.0.23.0/24 is directly connected, eth1, weight 1, 00:00:24
L>* 10.0.23.2/32 is directly connected, eth1, weight 1, 00:00:24
S>* 10.1.0.0/24 [1/0] via 10.0.12.1, eth0, weight 1, 00:00:07
S>* 10.3.0.0/24 [1/0] via 10.0.23.3, eth1, weight 1, 00:00:07

[1/0] is [administrative distance / metric]. Distance 1 means "static: trust this more than anything learned from a routing protocol" (OSPF is 110). It matters in Routing 2.

A surprise: ping works, traceroute shows a gap

h1$ traceroute -n -w1 10.3.0.10
traceroute to 10.3.0.10 (10.3.0.10), 30 hops max, 46 byte packets
 1  10.1.0.1  0.011 ms  0.008 ms  0.009 ms
 2  10.0.12.2  0.010 ms  0.010 ms  0.012 ms
 3  *  *  *
 4  10.3.0.10  0.014 ms  0.012 ms  0.014 ms

Hop 3 (r3) stays silent, every time. We dug into it in the lab:
   r3 DID send its "time exceeded" reply (its ICMP counter went up by one per probe)
   it sends it FROM its link 23 address, 10.0.23.3
   r1 has no route to 10.0.23.0/24, and Linux routers drop packets from a source they have no route back to (reverse path filtering, rp_filter)
r1's counter proved it:
r1$ awk ... /proc/net/netstat           (the IPReversePathFilter counter)
IPReversePathFilter=11

Fix: let r1 know the link network too.
r1(config)# ip route 10.0.23.0/24 10.0.12.2

h1$ traceroute -n -w1 -q1 10.3.0.10
 1  10.1.0.1  0.009 ms
 2  10.0.12.2  0.006 ms
 3  10.0.23.3  0.006 ms
 4  10.3.0.10  0.006 ms

Lesson: a "* * *" in traceroute does not always mean a broken path. Here the traffic worked fine and only the router's own replies were filtered. A Cisco router does not filter like this unless you turn on uRPF (ip verify unicast source), so on Cisco gear you would probably have seen hop 3 straight away.

Default routes: the lazy (and normal) way

r3 sits at the end of the line: everything that is not LAN 3 is "back that way". Instead of one route per network, give it a default route, 0.0.0.0/0, which matches everything:
r3(config)# no ip route 10.1.0.0/24 10.0.23.2
r3(config)# ip route 0.0.0.0/0 10.0.23.2

Cisco IOS:  ip route 0.0.0.0 0.0.0.0 10.0.23.2

r3# show ip route
S>* 0.0.0.0/0 [1/0] via 10.0.23.2, eth0, weight 1, 00:00:00
C>* 10.0.23.0/24 is directly connected, eth0, weight 1, 00:00:24
L>* 10.0.23.3/32 is directly connected, eth0, weight 1, 00:00:24
C>* 10.3.0.0/24 is directly connected, eth1, weight 1, 00:00:24
L>* 10.3.0.1/32 is directly connected, eth1, weight 1, 00:00:24

h3$ ping -c2 -W1 10.1.0.10
64 bytes from 10.1.0.10: seq=0 ttl=61 time=0.192 ms
64 bytes from 10.1.0.10: seq=1 ttl=61 time=0.282 ms

This is exactly how your home router works: one default route towards your internet provider. The most specific route always wins, so r3 still uses its connected routes for LAN 3 and link 23, and the default for everything else.

Mistake 1: a next hop that does not exist

Typo the next hop (10.0.99.1 is on no network r1 is connected to):
r1(config)# ip route 10.9.9.0/24 10.0.99.1

No error. The command is accepted and it is in the configuration:
r1# show running-config
...
ip route 10.3.0.0/24 10.0.12.2
ip route 10.9.9.0/24 10.0.99.1

But it is not in the routing table:
r1# show ip route 10.9.9.0/24
% Network not in table

FRR tells you why:
r1# show ip nht
10.0.12.2
 resolved via connected, prefix 10.0.12.0/24
 is directly connected, eth0 (vrf default), weight 1
10.0.99.1
 unresolved

"unresolved": the router cannot reach the next hop, so it will not use the route. If a static route "does nothing", check its next hop first. On Cisco, the route simply does not appear in show ip route either.
Static routes do not think. Pull the cable between r2 and r3 (here: take r2's link 23 interface down):
r2$ ip link set eth1 down
r2# show ip route 10.3.0.0/24
% Network not in table
h1$ ping -c2 -W1 10.3.0.10
2 packets transmitted, 0 packets received, 100% packet loss

The route disappears because its next hop is no longer reachable, and comes back by itself when the link does:
r2$ ip link set eth1 up
r2# show ip route 10.3.0.0/24
Routing entry for 10.3.0.0/24
  Known via "static", distance 1, metric 0, best
  Last update 00:00:02 ago
  Flags: Recursion Selected RR Distance
  Status: Installed
  * 10.0.23.3, via eth1, weight 1

What static routes cannot do: find ANOTHER way round. If there were a second path, you would have to add it by hand. That is the job of a routing protocol, which is Routing 2 (OSPF).

Save it, or lose it

Everything typed so far lives only in memory. Save it:
r1# write memory
Building Configuration...
Configuration saved to /etc/frr//mgmtd.conf
Configuration saved to /etc/frr/zebra.conf
Configuration saved to /etc/frr/staticd.conf

Cisco IOS:  copy running-config startup-config   (or the old favourite: write memory)

We restarted r1 to prove it:
r1# show ip route static
S>* 10.3.0.0/24 [1/0] via 10.0.12.2, eth0, weight 1, 00:00:04

The route survived. Notice it now says eth0, not eth1: in this Docker lab, restarting a router container can shuffle its interface names. The route still worked because it points at a next hop address, not an interface. Real routers keep their port names.

Build the same lab yourself

You need a Linux PC with Docker. Five containers, four networks, about 30 seconds:

   docker pull quay.io/frrouting/frr:10.7.1
   docker network create --internal --subnet 10.1.0.0/24  --gateway 10.1.0.254  rt-lan1
   docker network create --internal --subnet 10.0.12.0/24 --gateway 10.0.12.254 rt-link12
   docker network create --internal --subnet 10.0.23.0/24 --gateway 10.0.23.254 rt-link23
   docker network create --internal --subnet 10.3.0.0/24  --gateway 10.3.0.254  rt-lan3
   # a router: forwarding on, attached to its first network
   docker run -d --name rt-r1 --hostname r1 --cap-add NET_ADMIN --cap-add SYS_ADMIN \
       --sysctl net.ipv4.ip_forward=1 --network rt-lan1 --ip 10.1.0.1 quay.io/frrouting/frr:10.7.1
   docker network connect --ip 10.0.12.1 rt-link12 rt-r1
   # ...the same for r2 (10.0.12.2, 10.0.23.2) and r3 (10.0.23.3, 10.3.0.1)
   # a computer: tiny Alpine box with its router as the default gateway
   docker run -d --name rt-h1 --cap-add NET_ADMIN --network rt-lan1 --ip 10.1.0.10 alpine:3.21 sleep infinity
   docker exec rt-h1 ip route replace default via 10.1.0.1
   # (h3: 10.3.0.10 on rt-lan3, default via 10.3.0.1)
   docker exec -it rt-r1 vtysh          # the router's command line

Why the .254 gateways? Docker gives each network a gateway address on the host; moving it to .254 leaves .1, .2 and .3 free for the routers. --internal keeps the lab off your real network.
If vtysh complains that vtysh.conf is missing, it is harmless; "touch /etc/frr/vtysh.conf" inside the router silences it.
Clean up afterwards: docker rm -f rt-r1 rt-r2 rt-r3 rt-h1 rt-h3, then docker network rm the four rt- networks.

Cheat sheet: FRR and Cisco IOS

Task                       FRR (vtysh)                         Cisco IOS
show the routing table     show ip route                       show ip route
only static routes         show ip route static                show ip route static
one network                show ip route 10.3.0.0/24           show ip route 10.3.0.0
add a static route         ip route 10.3.0.0/24 10.0.12.2      ip route 10.3.0.0 255.255.255.0 10.0.12.2
default route              ip route 0.0.0.0/0 10.0.23.2        ip route 0.0.0.0 0.0.0.0 10.0.23.2
remove a route             no ip route ...                     no ip route ...
is the next hop reachable  show ip nht                         show ip route 10.0.12.2
save                       write memory                        copy running-config startup-config
(Cisco column: standard IOS syntax, for reference; not run in this lab.)

Common problems

Ping fails after adding a route: check every router on the path, in BOTH directions. The reply needs its own road back.
Route is in the config but not in show ip route: the next hop is unreachable (show ip nht says "unresolved"), or it is a typo.
Traceroute shows * * * for one hop but the ping works: that router's replies are being dropped, often because another router has no route to the link it answers from. Add the link network, or ignore it if the traffic works.
Everything vanished after a reboot: you did not write memory.
Packets go the wrong way: the most specific route wins. A /24 beats a default route every time.

What's next

Routing 2: OSPF. We add a fourth link so there are two ways from r1 to r3, let the routers find routes by themselves, and pull a cable to watch them reroute in seconds, which static routes cannot do.
Then Routing 3: BGP, how networks owned by different people (and the internet) share routes.
More from the network side of the site: the Cisco switch CVE notes on the Security page, and the subnet calculator on the Tools page.