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":
| Type | Example | Good for |
|---|---|---|
| Next hop | ip route 192.168.3.0 255.255.255.0 10.0.12.2 | Ethernet links. The usual choice. |
| Exit interface | ip route 192.168.3.0 255.255.255.0 Serial0/1/0 | Point-to-point links, where there is only one device on the other end. |
| Fully specified | ip route 192.168.3.0 255.255.255.0 GigabitEthernet0/1 10.0.12.2 | Ethernet, when you want the route tied to one interface and one neighbour. |
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
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".
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. R1 needs: 192.168.3.0/24 via 10.0.12.2.
- 2. R2 needs: 192.168.3.0/24 via 10.0.23.2. The request arrives.
- 3. R3 needs: 192.168.1.0/24 via 10.0.23.1, or the reply is dropped right here.
- 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.2On 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.1On R2: forward toward R3, and back toward R1.
ip route 192.168.1.0 255.255.255.0 10.0.23.1On 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.
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
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
Test yourself on static routes
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?
Which form is recommended for a static route out of an Ethernet interface?
Cisco reference: Static routes and next-hop resolution.