Course contents

Chapter 8: RoutingLesson 4 of 16

Configuring static routes

Next-hop and exit-interface routes, how to add them, and how to check they work.

Beginner · 8 min read

Technical definition

A static route is a route an administrator configures by hand, telling the router to reach a destination network through a given next-hop address or exit interface. It stays in the routing table while its next hop or interface is usable and does not adapt to changes elsewhere in the network.

Every interface up, still no path to the server

The three routers are cabled and every interface is up. Yet PC1 still can't reach the server. R1 only knows its own connected networks. Nobody has told it that 192.168.3.0/24 exists behind R2 and R3. The quickest fix in a small network is a static route.

The ip route command and its three forms

A static route is a route you type in by hand. It tells the router: "to reach this network, send packets this way". It doesn't change by itself, although the router removes it from the routing table if its exit interface goes down. The command is:

ip route <network> <mask> {<next-hop-ip> | <exit-interface>} [<AD>]

Entered in global configuration mode. The mask is written in dotted decimal, not as /24.

There are three ways to say "which way":

Diagram
The ip route command and its three forms
The ip route command and its three forms
TypeExampleGood for
Next hopip route 192.168.3.0 255.255.255.0 10.0.12.2Ethernet links. The usual choice.
Exit interfaceip route 192.168.3.0 255.255.255.0 Serial0/1/0Point-to-point links, where there is only one device on the other end.
Fully specifiedip route 192.168.3.0 255.255.255.0 GigabitEthernet0/1 10.0.12.2Ethernet, when you want the route tied to one interface and one neighbour.
Read each row across: the left box names the item, the others describe it.

A host route is a static route to a single address, with a /32 mask (255.255.255.255), for example ip route 192.168.3.10 255.255.255.255 10.0.12.2 to send traffic for one server a particular way. Because it is the most specific match possible, it wins over any shorter route to the same subnet. The IPv6 version uses a /128 prefix.

Recursive lookups and the return path

Diagram
The route names R2; the interface decides how to reach R2
The route names R2; the interface decides how to reach R2
The route names R2; the interface decides how to reach R2On R1, route 192.168.3.0/24 points to R2 at 10.0.12.2. The connected 10.0.12.0/30 route resolves that next hop through R1 Gi0/1, whose address is 10.0.12.1/30. R2 Gi0/0 is 10.0.12.2/30. R1 resolves R2's MAC on Ethernet, not the remote server's MAC.R1R2Gi0/110.0.12.1/30Gi0/010.0.12.2/30Destination 192.168.3.10 → route 192.168.3.0/24Next hop 10.0.12.2 → connected 10.0.12.0/30 → Gi0/1Ethernet frame destination: R2’s MAC, not the server’s MAC
The rest of the R2–R3–server path is omitted here to focus on R1's first hop. A usable next hop is required for normal static-route installation; ARP resolution is separately required to forward on Ethernet.

With only an exit interface on Ethernet, the router has no neighbour address. It treats every destination as if it were directly on that link and sends an ARP request for each one. That only works if the neighbour answers on their behalf (a feature called proxy ARP), and it fills the ARP table. On Ethernet, specify the next-hop address; a fully specified route also names the exit interface.

Routing also has to work in both directions. A route on R1 gets the request to the server. The reply needs routes on R3 and R2 that lead back to 192.168.1.0/24. Missing return routes are the most common reason a static setup "half works".

Diagram
Routes needed for PC1 and the server to talk
Routes needed for PC1 and the server to talk
192.168.1.0/24203.0.113.0/3010.0.12.0/3010.0.23.0/30192.168.2.0/24192.168.3.0/24PC1IP 192.168.1.10ISPIP 203.0.113.1R1R2R3PC2IP 192.168.2.10ServerIP 192.168.3.10

Device key: PC1, PC2 (computer) · ISP (network / service) · R1, R2, R3 (router)

Lines show the example’s network connections. Thick links: uplinks/WAN, as labelled. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type.

Reading the addresses

IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.

An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.

  • PC1: IP 192.168.1.10
  • ISP: IP 203.0.113.1
  • PC2: IP 192.168.2.10
  • Server: IP 192.168.3.10
  1. 1. R1 needs: 192.168.3.0/24 via 10.0.12.2.
  2. 2. R2 needs: 192.168.3.0/24 via 10.0.23.2. The request arrives.
  3. 3. R3 needs: 192.168.1.0/24 via 10.0.23.1, or the reply is dropped right here.
  4. 4. R2 needs: 192.168.1.0/24 via 10.0.12.1. Now the round trip works.

Four routes for one round trip

Based on Cisco IOS / IOS XE documentation, not run on a lab device. These four routes give PC1 and the server a working round trip. The lab in the “Lab: static routing across three routers” lesson completes the rest.

ip route 192.168.3.0 255.255.255.0 10.0.12.2

On R1: the server LAN is through R2.

ip route 192.168.3.0 255.255.255.0 10.0.23.2 ip route 192.168.1.0 255.255.255.0 10.0.12.1

On R2: forward toward R3, and back toward R1.

ip route 192.168.1.0 255.255.255.0 10.0.23.1

On R3: the return route to PC1's LAN.

Checking the route and a sourced ping

This output is based on Cisco documentation, not run on a lab device.

Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show ip route static
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       ...

Gateway of last resort is not set

S     192.168.3.0/24 [1/0] via 10.0.12.2
The route is there with AD 1. A static route is only installed while its next hop is reachable. If Gi0/1 goes down, it disappears from the table (it stays in the running configuration).
Example output · based on Cisco documentation; exact format varies by platform and software version
R1#ping 192.168.3.10 source GigabitEthernet0/0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.3.10, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms
Sourcing the ping from the LAN interface tests the same return path PC1 would use. A plain ping would come from 10.0.12.1, which the other routers may have no route back to.

Test yourself on static routes

Predict · scenario 1

R1 has a route to 192.168.3.0/24, but R3 has no route to 192.168.1.0/24. PC1 pings the server. What happens?

Predict · scenario 2

Which form is recommended for a static route out of an Ethernet interface?

Cisco reference: Static routes and next-hop resolution.