Static routes and default routes

ip route

A static route says: to reach this network, send packets to that next hop.

ip route network mask next-hop

StyleExampleNote
Next hopip route 192.168.3.0 255.255.255.0 10.0.12.2The usual choice. The router looks up the next hop to find the exit interface (recursive lookup).
Exit interfaceip route 192.168.3.0 255.255.255.0 g0/1Only for point-to-point links. On Ethernet the router must ARP for every destination.
Fully specifiedip route 192.168.3.0 255.255.255.0 g0/1 10.0.12.2Both: no recursive lookup, and safe on Ethernet.

A default route

A default route (0.0.0.0/0) matches every destination, so it's used when nothing longer matches. Branch routers often need nothing else: everything goes towards the core or the internet.

Below, R1 and R3 get a default route towards R2, and R2 gets one route to each LAN. Then PC1 can reach PC3:

In NetLab

▶ R1
R1>enable
R1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#ip route 0.0.0.0 0.0.0.0 10.0.12.2
R1(config)#end
*Mar  1 00:00:04.000: %SYS-5-CONFIG_I: Configured from console by console
▶ R3
R3>enable
R3#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#ip route 0.0.0.0 0.0.0.0 10.0.23.1
R3(config)#end
*Mar  1 00:00:08.000: %SYS-5-CONFIG_I: Configured from console by console
▶ R2
R2>enable
R2#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#ip route 192.168.1.0 255.255.255.0 10.0.12.1
R2(config)#ip route 192.168.3.0 255.255.255.0 10.0.23.2
R2(config)#end
*Mar  1 00:00:13.000: %SYS-5-CONFIG_I: Configured from console by console
R2#show ip route static
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
       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
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       + - replicated route, % - next hop override

Gateway of last resort is not set

S     192.168.1.0/24 [1/0] via 10.0.12.1
S     192.168.3.0/24 [1/0] via 10.0.23.2
▶ PC1
NetLab Windows-style command prompt. Type help to see the commands.
C:\Users\student>ping 192.168.3.10

Pinging 192.168.3.10 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Reply from 192.168.3.10: bytes=32 time<1ms TTL=61

Ping statistics for 192.168.3.10:
    Packets: Sent = 4, Received = 1, Lost = 3 (75% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms
C:\Users\student>tracert 192.168.3.10

Tracing route to 192.168.3.10 over a maximum of 30 hops

  1   <1 ms    <1 ms    <1 ms  192.168.1.1
  2    2 ms     2 ms     2 ms  10.0.12.2
  3    3 ms     3 ms     3 ms  10.0.23.2
  4    4 ms     4 ms     4 ms  192.168.3.10

Trace complete.

The first replies time out: each router on the way drops the first packet while it asks (with ARP) for the next hop's MAC address. Once the ARP tables are filled, every ping gets through.

The route back

A ping needs two paths: there and back. If R2 had a route to 192.168.3.0/24 but not to 192.168.1.0/24, the echo request would reach PC3 but the reply would be dropped at R2. Always check both directions.

Common mistake: A static route whose next hop isn't reachable is not installed. If show ip route doesn't show your route, check that the next hop is in a connected network and that interface is up.

HOME LABS COMMUNITY DASHBOARD