Questions? Call 1.800.716.8955

Chapter 20

IPv4 and IPv6 Static Routing

Exam topics covered

3.3 Configure and verify IPv4 and IPv6 static routing (3.3.a Default route, 3.3.b Network

route, 3.3.c Host route, 3.3.d Floating static)

Foundation. A static route is a route you type in yourself. Static routes cost nothing in CPU or bandwidth, never change unless you change them, and are perfect for small sites, stub networks, Internet default routes and backup paths. They are also a favourite of the CCNA exam, which expects you to configure all four kinds named in the blueprint (default, network, host and floating static) for both IPv4 and IPv6, and to spot a broken one in a routing table. This chapter builds on the routing-table skills from Chapter 19.

20.1 The ip route Command

Every IPv4 static route is configured in global configuration mode with one command. It names a destination (prefix and mask) and tells the router how to get there: by a next-hop IP address, by an exit interface, or by both.

Figure 20-1 The parts of an IPv4 static route command.

Two details catch people out. First, the mask is entered in dotted-decimal form, never as /24 . Second, the prefix must be a network ID: if you type host bits (for example ip route 192.168.2.1 255.255.255.0 ... ), IOS silently converts it to 192.168.2.0, which may hide a typo. Other optional keywords include name (a description) and permanent (keep the route even if its interface goes down, rarely a good idea).

20.1.1 The sample network

Figure 20-2 shows the network used throughout this chapter. R1 is a branch router with one

LAN. It connects to the headquarters router R2 over a primary Gigabit link and a slower backup link. R2 connects to the Internet. The network is dual-stack; the IPv6 prefixes are used in Section 20.6.

R1

R2

Isp

Hq lan 192.168.2.0/24

Figure 20-2 Branch (R1) and headquarters (R2) with a primary link, a backup link and an Internet connection.

With only connected routes, R1 cannot reach 192.168.2.0/24 and R2 cannot reach 192.168.1.0/24. Our goals: give R1 a default route towards R2 (R1 is a stub site with only one way out), give R2 a network route back to the branch LAN, and add backups.

20.2 Network Routes: Three Ways to Point the Way

A network route is a static route to a subnet (any prefix length from /1 to /31). You can tell the router where to send the packet in three ways.

20.2.1 Next-hop route

R2(config)# ip route 192.168.1.0 255.255.255.0 10.0.12.1

This is the most common form. The router knows the next hop's IP address but not which interface to use, so for each packet (or, with CEF, once when the FIB is built) it performs a recursive lookup: it looks up 10.0.12.1 in its own routing table, finds the connected route 10.0.12.0/30 on G0/1, and uses G0/1 as the exit. A next-hop static route is installed only if the next hop is reachable through some other route; if 10.0.12.0/30 disappears, so does the static route.

Figure 20-3 Recursive lookup: the next-hop address is itself looked up to find the exit interface.

20.2.2 Exit-interface (directly connected) route

R2(config)# ip route 192.168.1.0 255.255.255.0 GigabitEthernet0/1

Here no next hop is given. IOS treats the destination as if it were directly connected to G0/1. On a point-to-point serial link that works perfectly, because there is only one device at the other end. On Ethernet it is a poor choice: R2 must ARP for every individual destination (192.168.1.20, 192.168.1.21 and so on) and relies on R1 answering with proxy ARP. If proxy ARP is disabled, the route fails, and even when it works the ARP cache fills with entries. The route is shown as "directly connected" but still carries AD 1.

20.2.3 Fully specified route

R2(config)# ip route 192.168.1.0 255.255.255.0 GigabitEthernet0/1 10.0.12.1

Giving both the interface and the next hop avoids the recursive lookup and the proxy-ARP problem: R2 knows to leave by G0/1 and to ARP only for 10.0.12.1. Fully specified routes are mandatory for IPv6 routes that use a link-local next hop (Section 20.6) and are good practice on multi-access Ethernet.

R2 — console

R2# show ip route static (three alternatives shown together for comparison)

S 192.168.1.0/24 [1/0] via 10.0.12.1 ! next hop

S 192.168.1.0/24 is directly connected, GigabitEthernet0/1 ! exit interface S 192.168.1.0/24 [1/0] via 10.0.12.1, GigabitEthernet0/1 ! fully specified

Figure 20-4 How each form of static route appears in the routing table. All output in this chapter is illustrative of Cisco IOS 15 /

Ios xe.

Table 20-1 Comparing the three ways to specify a static route

  • Form
  • Example
  • target
  • Pros Cons

Next hop 10.0.12.1 Simple; works on any link type Recursive lookup; removed if next hop unreachable

Exit

interface

G0/1 No recursion; ideal on point-to-point serialOn Ethernet depends on proxy ARP; ARP per destination

Exam alert

The exam often shows a static route command and asks whether it is valid or which next hop it uses. Check three things: the mask is dotted decimal, the next-hop address is the neighbour's IP on a shared subnet (not the local router's own interface address, and not a remote router several hops away), and the destination is the remote network, not a connected one.

20.3 Default Routes

R1 is a stub router: every destination that is not on its own LAN lies beyond R2. Instead of one static route per remote network, R1 needs a single default route, a static route to 0.0.0.0/0, which matches every destination and is used only when no longer prefix matches (Chapter 19).

R1(config)# ip route 0.0.0.0 0.0.0.0 10.0.12.2 ! quad-zero route to R2
R2(config)# ip route 0.0.0.0 0.0.0.0 203.0.113.1 ! R2's default route to the ISP

R1 — console

R1# show ip route

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP ...

  • Gateway of last resort is 10.0.12.2 to network 0.0.0.0
  • S* 0.0.0.0/0 [1/0] via 10.0.12.2
  • 10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
  • C 10.0.12.0/30 is directly connected, GigabitEthernet0/1
  • L 10.0.12.1/32 is directly connected, GigabitEthernet0/1
  • C 10.0.99.0/30 is directly connected, GigabitEthernet0/2
  • L 10.0.99.1/32 is directly connected, GigabitEthernet0/2
  • 192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
  • C 192.168.1.0/24 is directly connected, GigabitEthernet0/0
  • L 192.168.1.1/32 is directly connected, GigabitEthernet0/0

Figure 20-5 The default route appears as S* and sets the gateway of last resort.

Notice that R2 also needs a route back to the branch LAN (the network route from Section 20.2), and the ISP would need a route to the company's addresses (in practice provided by NAT, Chapter 24). Routing is always two-way.

20.4 Host Routes

A host route is a route to a single address, with a /32 mask (255.255.255.255) in IPv4 or /128 in IPv6. Because /32 is the longest possible prefix, a host route overrides every other route for that one address. Suppose the branch's nightly backups to the server 192.168.2.100 should use the backup link so they do not congest the primary link:

R1(config)# ip route 192.168.2.100 255.255.255.255 10.0.99.2

Traffic to 192.168.2.100 now matches the /32 and leaves through G0/2, while everything else still follows the default route over G0/1. In show ip route it appears as S 192.168.2.100 [1/0] via 10.0.99.2 under the heading 192.168.2.0/32 is subnetted, 1 subnets . Host routes are also used to reach a neighbour's loopback address, and the local (L) routes you saw in Chapter 19 are host routes created automatically.

20.5 Floating Static Routes

A static route is installed with AD 1, which beats every dynamic protocol. If you raise its AD above that of the preferred route, the static route "floats" out of the routing table: IOS keeps it in the configuration but does not install it while the preferred route exists. If the preferred route disappears, the floating route drops into the table automatically. This is how you configure a backup path without a routing protocol.

R1(config)# ip route 0.0.0.0 0.0.0.0 10.0.12.2 ! primary, AD 1
R1(config)# ip route 0.0.0.0 0.0.0.0 10.0.99.2 5 ! floating backup, AD 5
R2(config)# ip route 192.168.1.0 255.255.255.0 10.0.12.1
R2(config)# ip route 192.168.1.0 255.255.255.0 10.0.99.1 5

Both R1 and R2 need the backup, otherwise traffic would fail over in one direction only. The AD just has to be higher than the primary's. If the primary path were learned by OSPF (AD 110), the floating static would need an AD greater than 110, such as 130; with EIGRP (AD 90), greater than 90.

Figure 20-6 A floating static route takes over when the primary route is withdrawn.

R1 — console

R1# show ip route static
  • S* 0.0.0.0/0 [1/0] via 10.0.12.2
  • 192.168.2.0/32 is subnetted, 1 subnets
  • S 192.168.2.100 [1/0] via 10.0.99.2
  • (the primary cable is unplugged)

%LINK-3-UPDOWN: Interface GigabitEthernet0/1, changed state to down %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to down

R1# show ip route static
  • S* 0.0.0.0/0 [5/0] via 10.0.99.2
  • 192.168.2.0/32 is subnetted, 1 subnets
  • S 192.168.2.100 [1/0] via 10.0.99.2
R1# show running-config | include ip route
ip route 0.0.0.0 0.0.0.0 10.0.12.2
ip route 0.0.0.0 0.0.0.0 10.0.99.2 5
ip route 192.168.2.100 255.255.255.255 10.0.99.2

Figure 20-7 Before and after failover. Only the routing table changes; both routes stay in the configuration.

Watch out

A static route is withdrawn only when the router can no longer resolve its next hop or its exit interface goes down. If R1 and R2 were connected through a switch, and the failure happened on R2's side of that switch, R1's G0/1 would stay up/up and the primary static route would stay in the table, black-holing traffic. Production networks solve this with IP SLA object tracking or a dynamic routing protocol; both are beyond the CCNA.

20.6 IPv6 Static Routes

IPv6 static routing works exactly like IPv4, with three differences. First, the router must be enabled to forward IPv6 with ipv6 unicast-routing (without it, the router acts as an IPv6 host and will not route). Second, prefixes are written with a prefix length ( /64 ) instead of a mask. Third, if the next hop is a link-local address, you must also give the exit interface, because the same fe80:: address can exist on every link and the router cannot tell which one you mean.

Table 20-2 IPv6 static route types on R1 and R2

Type Command

Enable routing ipv6 unicast-routing

Network route, global next hop R2: ipv6 route 2001:db8:1::/64 2001:db8:12::1 Network route, exit interface R2: ipv6 route 2001:db8:1::/64 g0/1 Network route, link-local (fully specified) R2: ipv6 route 2001:db8:1::/64 g0/1 fe80::1 Default route R1: ipv6 route ::/0 2001:db8:12::2

Host route R1: ipv6 route 2001:db8:2::100/128 2001:db8:99::2

Floating default R1: ipv6 route ::/0 2001:db8:99::2 5

As with IPv4, avoid naming only an Ethernet exit interface: the router would treat every destination as on-link and send Neighbor Solicitations for remote addresses that nobody answers. Use a global next hop or the fully specified form. If you forget the interface with a link-local next hop, IOS rejects the command:

R1 — console

R1(config)# ipv6 route ::/0 fe80::2

% Interface has to be specified for a link-local nexthop

R1(config)# ipv6 route ::/0 g0/1 fe80::2
R1(config)# ipv6 route ::/0 2001:db8:99::2 5
R1(config)# ipv6 route 2001:db8:2::100/128 2001:db8:99::2
R1(config)# end
R1# show ipv6 route static

IPv6 Routing Table - default - 8 entries

Codes: C - Connected, L - Local, S - Static, U - Per-user Static route ...

Figure 20-8 Configuring IPv6 static routes and viewing them. IOS displays IPv6 addresses in upper case.

Notice the floating default (AD 5) does not appear: it is waiting in the configuration exactly like its IPv4 equivalent. Verify IPv6 reachability with ping 2001:db8:2::100 and traceroute 2001:db8:2::100 , and check a specific destination with show ipv6 route 2001:db8:2::100 .

Exam alert

Remember the two IPv6-only gotchas: ipv6 unicast-routing must be configured, and a link-local next hop requires the outgoing interface. The IPv6 default route is ::/0 .

20.7 Troubleshooting Static Routes

Most static routing problems fall into a handful of categories. Work through them in order with show ip route , ping and traceroute .

Table 20-3 Common static route faults

Wrong destination Prefix typed incorrectly (e.g.

The most common fault in labs and on the exam is forgetting that packets must travel both ways. Suppose R1 has its default route but R2 has no route to 192.168.1.0/24. A ping from PC1 (192.168.1.10) to the server reaches the server, but the server's reply goes to R2, which has no route for 192.168.1.10 except its default route towards the ISP, so the reply is lost.

PC1 .10 R1 R2 Server .100

Echo request: R1 default route works, R2 delivers to connected LAN ✕ R2: no route to 192.168.1.0/24, sent to ISP and lost

Figure 20-9 A one-way route: the request arrives, the reply cannot find its way back.

R1# ping 192.168.2.100 source 192.168.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.100, timeout is 2 seconds:

Packet sent with a source address of 192.168.1.1

.....

Success rate is 0 percent (0/5)

R1# ping 192.168.2.100

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.100, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms

R1# traceroute 192.168.2.100 source 192.168.1.1

Type escape sequence to abort.

Figure 20-10 The default ping (sourced from 10.0.12.1, which R2 knows as a connected subnet) succeeds, but the ping and

traceroute sourced from the LAN fail: the classic missing-return-route signature.

Figure 20-10 shows a powerful technique: a plain ping from a router uses the outgoing

interface's address as its source, which the far end usually knows because it is a shared connected subnet. Adding source (an extended ping) tests the path the users actually need. When the plain ping works but the sourced ping fails, look for a missing return route on the far router. The fix is the network route on R2 from Section 20.2.

20.7.2 Wrong next hop and routing loops

If R2's route to 192.168.1.0/24 points at the ISP (203.0.113.1) by mistake, and the ISP routes the packet back to R2, the packet bounces between them until its TTL reaches zero. A traceroute shows the same two addresses alternating, a sure sign of a routing loop:

R2 — console

R2# traceroute 192.168.1.10
  • Tracing the route to 192.168.1.10
  • 1 203.0.113.1 2 msec 1 msec 1 msec
  • 2 203.0.113.2 2 msec 2 msec 2 msec
  • 3 203.0.113.1 3 msec 2 msec 2 msec
  • 4 203.0.113.2 3 msec 3 msec 3 msec

...

R2# show ip route 192.168.1.10
  • Routing entry for 192.168.1.0/24
  • Known via "static", distance 1, metric 0
  • Routing Descriptor Blocks:
  • * 203.0.113.1
  • Route metric is 0, traffic share count is 1

Figure 20-11 Alternating hops in a traceroute reveal a loop; show ip route exposes the wrong next hop.

LAB Static routing across three routers

Goal: Provide full IPv4 and IPv6 reachability between three LANs using network, default, host and floating static routes, then test failover.

  • RA RB RC
  • 10.1.12.0/30 (.1 / .2) 10.1.23.0/30 (.2 / .3)
  • Backup 10.1.13.0/30 (RA .1 / RC .3)
  • LAN A 172.16.1.0/24 LAN B 172.16.2.0/24 LAN C 172.16.3.0/24
  • Each router's LAN interface is .1 on its own /24

Figure 20-12 Lab topology: RA and RC are connected through RB, with a direct backup link between them. Steps:

  • 1. Address all interfaces as shown and confirm with show ip interface brief that each is up/up.
  • 2. On RB, add network routes to both outer LANs:
RB(config)# ip route 172.16.1.0 255.255.255.0 10.1.12.1
RB(config)# ip route 172.16.3.0 255.255.255.0 10.1.23.3
  • 3. On RA and RC, add network routes to each other's LAN via RB, a route to LAN B, and floating backups across the direct link:
RA(config)# ip route 172.16.2.0 255.255.255.0 10.1.12.2
RA(config)# ip route 172.16.3.0 255.255.255.0 10.1.12.2
RA(config)# ip route 172.16.3.0 255.255.255.0 10.1.13.3 10 ! floating
RC(config)# ip route 172.16.2.0 255.255.255.0 10.1.23.2
RC(config)# ip route 172.16.1.0 255.255.255.0 10.1.23.2
RC(config)# ip route 172.16.1.0 255.255.255.0 10.1.13.1 10 ! floating
  • 4. Add a host route on RA so that traffic to RC's LAN interface 172.16.3.1 always uses the direct link: ip route 172.16.3.1 255.255.255.255 10.1.13.3 .
  • 5. Optional IPv6: enable ipv6 unicast-routing , address the links with 2001:db8:12::/64, 2001:db8:23::/64 and 2001:db8:13::/64, and repeat steps 2–3 with ipv6 route , using one fully specified link-local next hop.

Verify: From RA, ping 172.16.3.1 source 172.16.1.1 and traceroute 172.16.3.10 source 172.16.1.1 should show hop 1 as 10.1.12.2 (RB). Shut RA's G0/1 towards RB and repeat: show ip route static now shows [10/0] via 10.1.13.3 and the traceroute reaches RC in one hop.

Expected results: All three LANs reach each other; the host route is always via 10.1.13.3; the floating routes appear only while the RA–RB link is down and disappear again when it is restored. Note that with RA–RB down, RB can no longer reach LAN A, because RB has no backup route: a good illustration of why every router on the path needs a backup.

  • 1. Which command configures an IPv4 default route through 10.0.0.1?
  • A. ip route 0.0.0.0 255.255.255.255 10.0.0.1
  • B. ip route 0.0.0.0 0.0.0.0 10.0.0.1
  • C. ip default-route 10.0.0.1
  • D. ip route 0.0.0.0/0 10.0.0.1
  • 2. A router has ip route 10.5.0.0 255.255.0.0 172.16.1.2 130 and learns 10.5.0.0/16 from OSPF. What appears in the routing table?
  • A. The static route, because static routes always win
  • B. The OSPF route, because 110 is lower than 130
  • C. Both routes, load-balanced
  • D. Neither route
  • 3. Which mask creates an IPv4 host route?
  • A. 0.0.0.0
  • B. 255.255.255.0
  • C. 255.255.255.254
  • D. 255.255.255.255
  • 4. An engineer enters ipv6 route 2001:db8:5::/64 fe80::5 and receives an error. Why?
  • A. IPv6 static routes cannot use a next hop
  • B. A link-local next hop requires the outgoing interface
  • C. The prefix length must be /128
  • D. ipv6 unicast-routing is not supported with static routes
  • 5. What is the main drawback of a static route that specifies only an Ethernet exit interface?
  • A. It has an AD of 0
  • B. It requires a recursive lookup
  • C. The router ARPs for each destination and relies on proxy ARP
  • D. It cannot be used for a default route
  • 6. Which two statements about floating static routes are true? (Choose two.)
  • A. They are configured with an AD higher than the primary route
  • B. They are installed only when the primary route is removed
  • C. They require a routing protocol to be running
  • D. They always use AD 255
  • E. They load-balance with the primary route
  • 7. R1's static route to 192.168.9.0/24 is in the running configuration but not in the routing table. What is the most likely cause?
  • A. The route has AD 1
  • B. The next-hop address is not reachable
  • C. The destination network is not up
  • D. CEF is disabled
  • 8. A plain ping from R1 to a remote server succeeds, but a ping sourced from R1's LAN interface fails. What is the most likely problem?
  • A. The server's default gateway is wrong
  • B. A missing return route to R1's LAN on a router along the path
  • C. R1 has no default route
  • D. The LAN interface is shut down
  • 9. Which command is required before a Cisco router forwards IPv6 packets?
  • A. ipv6 enable
  • B. ipv6 routing
  • C. ipv6 unicast-routing
  • D. ipv6 forward
  • 10. Which routing table entry represents a fully specified static route?
  • A. S 10.1.0.0/16 [1/0] via 10.0.0.2
  • B. S 10.1.0.0/16 is directly connected, GigabitEthernet0/0
  • C. S 10.1.0.0/16 [1/0] via 10.0.0.2, GigabitEthernet0/0
  • D. S* 0.0.0.0/0 [1/0] via 10.0.0.2
  • 11. Which two commands create valid IPv6 default routes? (Choose two.)
  • A. ipv6 route ::/0 2001:db8:1::1
  • B. ipv6 route ::/128 2001:db8:1::1
  • C. ipv6 route ::/0 g0/0 fe80::1
  • D. ipv6 route 0::0/64 fe80::1
  • E. ipv6 route default 2001:db8:1::1
  • 12. Traceroute output alternates between 10.0.0.1 and 10.0.0.2 until it times out. What does this indicate?
  • A. An ACL is blocking ICMP
  • B. A routing loop between two routers
  • C. ECMP load balancing
  • D. A missing default route
  • 13. Primary traffic to 10.9.0.0/16 must use EIGRP-learned routes, with a static backup. Which AD should the static route have?
  • A. 1
  • B. 50
  • C. 95
  • D. 255

Answers

  • 1. B. The default route is 0.0.0.0 with mask 0.0.0.0. IOS does not accept CIDR notation in ip route .
  • 2. B. The static route has AD 130, higher than OSPF's 110, so it floats and OSPF is installed.
  • 3. D. A /32 (255.255.255.255) identifies one host.
  • 4. B. Link-local addresses are only unique per link, so the interface must be specified.
  • 5. C. With no next hop on Ethernet, the router treats every destination as on-link and depends on proxy ARP.
  • 6. A and B. A floating route has a higher AD and is installed only when the better route is gone. No routing protocol is required; AD 255 would never be installed.
  • 7. B. A next-hop static route is installed only when the next hop resolves through another route.
  • 8. B. The plain ping is sourced from the link subnet, which the far end knows; the LAN-sourced ping needs a return route that is missing.
  • 9. C. ipv6 unicast-routing enables IPv6 forwarding.
  • 10. C. Both the next hop and the exit interface are listed.
  • 11. A and C. ::/0 with a global next hop, or with an interface and link-local next hop. ::/128 is a host route to the unspecified address, and IOS has no default keyword here.
  • 12. B. Repeating hops are the signature of a routing loop; packets bounce until TTL expires.
  • 13. C. Internal EIGRP has AD 90, so the backup must be higher than 90. AD 255 would never be used.
Use ← → to move between sections