Learn / Stage 3: Networking and CCNA / Lesson 3.7

$ lesson 3.7 --track ccna --domain routing

The Routing Table and Static Routing (IPv4 and IPv6)

Every packet a router forwards is a lookup in one table. Learn to read that table line by line, predict which route wins, and build static routes, including the backup kind that waits quietly until the primary path fails.

  • Stage 3 Networking and CCNA
  • Level Intermediate
  • 60 min
  • 5 sections, quiz, lab

Start the lesson Jump to the lab

By the end of this lesson you can

  • Read every field of a routing table entry
  • Pick the winning route using longest prefix match, then AD, then metric
  • Configure IPv4 and IPv6 network, default, host and floating static routes
  • Troubleshoot missing return routes with show ip route and traceroute
3.7.01

Reading a routing table

R1#show ip route
Codes: L - local, C - connected, S - static, O - OSPF
       * - candidate default

Gateway of last resort is not set

C        10.0.12.0/30 is directly connected, GigabitEthernet0/0/1
L        10.0.12.1/32 is directly connected, GigabitEthernet0/0/1
S        192.168.3.0/24 [1/0] via 10.0.12.2
O        10.20.0.0/16 [110/20] via 10.0.12.2, 00:01:12, GigabitEthernet0/0/1
  • Code: C connected, L local (the router's own address as a /32), S static, O OSPF, and an asterisk marks a candidate default route.
  • Prefix and length: the destination network.
  • [AD/metric]: administrative distance (how much the router trusts the source) and the protocol's metric (how far).
  • via: the next hop, then for dynamic routes the age and the exit interface.
  • Gateway of last resort: the default route, used when nothing more specific matches.
3.7.02

How a router picks a route

  1. Longest prefix match first. Of all routes that contain the destination, the most specific wins. A /32 beats a /24, which beats a /16, which beats the /0 default. This happens no matter what the AD is.
  2. AD only for identical prefixes. When two sources offer the same prefix and length, only the lowest AD enters the table.
  3. Metric breaks ties within one routing protocol.
Administrative distance
SourceDefault AD
Connected0
Static1
eBGP20
EIGRP (internal)90
OSPF110
RIP120
EIGRP (external)170
iBGP200
Unusable255

Practise with the game. This router has no default route, so a packet that matches nothing is dropped.

Which route wins?

These are all the routes this router learned, from every source. Only the best source for each prefix goes into the routing table, then the longest matching prefix forwards the packet. Pick the route that forwards each packet, or drop it.

Candidate routes
SourcePrefixADMetricNext hopChoose

3.7.03

Static routes: network, default, host and floating

! network route via a next hop (recursive: the router then looks up how to reach 10.0.12.2)
R1(config)#ip route 192.168.3.0 255.255.255.0 10.0.12.2
! exit interface only: fine on point to point links, avoid on Ethernet
R1(config)#ip route 192.168.3.0 255.255.255.0 GigabitEthernet0/0/1
! fully specified: both
R1(config)#ip route 192.168.3.0 255.255.255.0 GigabitEthernet0/0/1 10.0.12.2
! default route
R2(config)#ip route 0.0.0.0 0.0.0.0 10.0.12.1
! host route
R1(config)#ip route 192.168.3.100 255.255.255.255 10.0.13.2
! floating static: AD 5, only used if the AD 1 route disappears
R1(config)#ip route 192.168.3.0 255.255.255.0 10.0.13.2 5
! IPv6 equivalents
R1(config)#ipv6 route 2001:db8:1:3::/64 2001:db8:12::2
R1(config)#ipv6 route ::/0 2001:db8:12::2
  • A floating static sits in the running config but stays out of the routing table while the primary route is installed.
  • A static route via a next hop stays installed as long as the router can still reach that next hop through an up interface. If the far router dies but your local interface stays up, the route usually stays too, and traffic is black holed. That is why real networks pair statics with tracking or use a routing protocol.
  • For IPv6, if the next hop is a link-local address (fe80::), you must also name the exit interface.
3.7.04

Troubleshooting: it is always the way back

A ping needs a route there and a route back. Most static routing tickets are a forgotten return route on the far router. Work hop by hop: show ip route on each router for the destination and for the source, then traceroute (on a PC: tracert) to see where packets stop.

R1#show ip route 192.168.3.100
Routing entry for 192.168.3.100/32
  Known via "static", distance 1, metric 0
  Routing Descriptor Blocks:
  * 10.0.13.2
      Route metric is 0, traffic share count is 1
3.7.05

Practise on R1

console: R1 (R1 static routes)

Missions 0/9

    Simplified IOS simulator in your browser. It teaches the commands; Packet Tracer and real gear have many more.

    Flashcards: do you remember?

    Tap a card to flip it. Try to answer in your head first; recalling is what makes it stick.

    Quick quiz

    Instant feedback on every answer. Score 70% or more to pass this lesson's quiz.

    Q1Routes: OSPF 10.1.0.0/16 and RIP 10.1.1.0/24. Destination 10.1.1.9 uses?

    Q2Which line adds a floating backup default route?

    Q3Ping from LAN1 to LAN3 fails. R1 has a route to LAN3. What is the next thing to check?

    Q4Two static routes for 192.168.3.0/24 with AD 1 and AD 5. What is in the routing table?

    Q5Why avoid an exit interface only static on Ethernet?

    Q6What does ip route 198.51.100.0 255.255.255.0 Null0 do?

    0 / 6

    Hands-on lab

    Cisco Packet Tracer lab50 minutessimulated network

    Packet Tracer lab 3.7: static, host and floating routes

    You need: Cisco Packet Tracer (free with a Cisco Networking Academy account; version 9.0.1 was the current download on the NetAcad Resource Hub when this lesson was written). Devices: 3 x ISR4331, 2 x 2960, PC1, PC3, Server3. Enable ipv6 unicast-routing on every router.

    Topology and addressing

    Lab 3.7 topology: R1 reaches LAN3 behind R2 directly or through R3Gi0/0/0Gi0/0/1 .1.2 Gi0/0/1Gi0/0/2 .1.2 Gi0/0/1Gi0/0/2 .1.2 Gi0/0/0Gi0/0/0PC1192.168.1.10R1R2R3PC3192.168.3.10Server3192.168.3.100
    R1 to R2 on 10.0.12.0/30, R1 to R3 on 10.0.13.0/30, R2 to R3 on 10.0.23.0/30. LAN1 behind R1, LAN3 (PC3 and Server3) behind R2.
    Addressing table
    DeviceInterfaceIPv4 address / prefixDefault gateway or note
    R1Gi0/0/0192.168.1.1/24, 2001:db8:1:1::1/64LAN1
    R1Gi0/0/110.0.12.1/30, 2001:db8:12::1/64to R2
    R1Gi0/0/210.0.13.1/30, 2001:db8:13::1/64to R3
    R2Gi0/0/110.0.12.2/30, 2001:db8:12::2/64to R1
    R2Gi0/0/210.0.23.1/30, 2001:db8:23::2/64to R3
    R2Gi0/0/0192.168.3.1/24, 2001:db8:1:3::1/64LAN3
    R3Gi0/0/110.0.13.2/30, 2001:db8:13::3/64to R1
    R3Gi0/0/010.0.23.2/30, 2001:db8:23::3/64to R2
    PC1Fa0192.168.1.10/24gw 192.168.1.1
    PC3Fa0192.168.3.10/24gw 192.168.3.1
    Server3Fa0192.168.3.100/24gw 192.168.3.1
    1. Address everything

      Use the table. Check every router with show ip interface brief before adding a single route: half of all routing problems are an interface that is still shut.

    2. R1: primary, floating and host routes

      R1(config)#ip route 192.168.3.0 255.255.255.0 10.0.12.2
      R1(config)#ipv6 route 2001:db8:1:3::/64 2001:db8:12::2
      R1(config)#ip route 192.168.3.0 255.255.255.0 10.0.13.2 5
      R1(config)#ipv6 route 2001:db8:1:3::/64 2001:db8:13::3 5
      R1(config)#ip route 192.168.3.100 255.255.255.255 10.0.13.2
    3. R2: default route back, plus a floating default

      R2(config)#ip route 0.0.0.0 0.0.0.0 10.0.12.1
      R2(config)#ipv6 route ::/0 2001:db8:12::1
      R2(config)#ip route 0.0.0.0 0.0.0.0 10.0.23.2 5
    4. R3: routes to both LANs

      R3(config)#ip route 192.168.1.0 255.255.255.0 10.0.13.1
      R3(config)#ip route 192.168.3.0 255.255.255.0 10.0.23.1
      R3(config)#ipv6 route 2001:db8:1:1::/64 2001:db8:13::1
      R3(config)#ipv6 route 2001:db8:1:3::/64 2001:db8:23::2
    5. Compare paths

      From PC1: tracert 192.168.3.10 should go R1, R2. tracert 192.168.3.100 should go R1, R3, R2, because the /32 host route wins over the /24.

    6. Fail the primary

      Shut R1 Gi0/0/1 and run show ip route on R1: the floating route appears as [5/0] via 10.0.13.2. Ping PC3 again. Then bring Gi0/0/1 back.

    7. Verify

      R1#show ip route
      R1#show ip route static
      R1#show ip route 192.168.3.100
      R1#show ipv6 route static
      R1#show running-config | include ip route

    You are done when: R1 shows S 192.168.3.0/24 [1/0] via 10.0.12.2 and S 192.168.3.100/32 [1/0] via 10.0.13.2; the AD 5 route appears only while Gi0/0/1 is shut; tracert to the server goes through R3.

    Packet Tracer limits and notes

    • This lab corrects one detail you may see in other guides: on a /30 only .1 and .2 are usable, so R3 uses 10.0.13.2 and R2 uses 10.0.23.1.
    • As on real IOS, a static route via a next hop usually stays installed when the far router fails but your local interface stays up. That is why this lab shuts the local interface to test failover.
    • Packet Tracer simulates a subset of IOS. If a command here is rejected in your version, note it, skip that step and carry on; the concept still applies to real Cisco gear.

    Download the lab checklist (.txt) Print it or keep it open beside Packet Tracer.

    Key takeaways

    • Longest prefix first, then AD, then metric.
    • Static routes: network, default, host, floating.
    • Floating statics wait in the config until the primary disappears.
    • Every path needs a return path.
    • Log and review route changes like any security relevant change.

    Finished the sections, quiz and lab? Mark the lesson complete. Progress is saved only in this browser.