---
title: "Static Routes and Routing Table for CCNA | CyberWithMadhav"
description: "Free CCNA lesson: read a routing table, see why longest prefix match beats administrative distance, and set up default, host and floating static routes."
url: https://www.cyberwithmadhav.com/learn-ccna-static-routing.html
source_format: markdown rendering of the HTML page
---

[Learn](https://www.cyberwithmadhav.com/learn.html) / [Stage 3: Networking and CCNA](https://www.cyberwithmadhav.com/learn.html#stage-3) / 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

## In this lesson

1. Reading a routing table
2. How a router picks a route
3. Static routes: network, default, host and floating
4. Troubleshooting: it is always the way back
5. Practise on R1
6. Flashcards
7. Quick quiz
8. Hands-on lab
9. Key takeaways

## 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.

| Source | Default AD |
| --- | --- |
| Connected | 0 |
| Static | 1 |
| eBGP | 20 |
| EIGRP (internal) | 90 |
| OSPF | 110 |
| RIP | 120 |
| EIGRP (external) | 170 |
| iBGP | 200 |
| Unusable | 255 |

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.

| Source | Prefix | AD | Metric | Next hop | Choose |
| --- | --- | --- | --- | --- | --- |

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
```
How attackers abuse this

Routers are not usually attacked through static routes over the wire, but a compromised admin account can add one quietly: send a subnet's traffic through a capture box, or black hole a monitoring server so alerts never arrive. Asymmetric paths also break stateful firewalls, which see only half of each session and drop it.
Defender move

Strong AAA and MFA for device logins (lesson 3.12), configuration change logging to syslog (lesson 3.11), regular config backups you can diff, and a review of `show ip route` after every change. Null routes are a defensive tool too: `ip route 198.51.100.0 255.255.255.0 Null0` silently drops traffic to a known bad prefix.

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.

### Q1 Routes: OSPF 10.1.0.0/16 and RIP 10.1.1.0/24. Destination 10.1.1.9 uses?

### Q2 Which line adds a floating backup default route?

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

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

### Q5 Why avoid an exit interface only static on Ethernet?

### Q6 What does `ip route 198.51.100.0 255.255.255.0 Null0` do?

**0 / 6**

## Hands-on lab

Cisco Packet Tracer lab  50 minutes  simulated 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.

**Simulator lab, zero risk.** This lab runs inside Cisco Packet Tracer, so it touches no real network. Packet Tracer is free with a Cisco Networking Academy account (netacad.com). It simulates a subset of Cisco IOS, so where support for a feature is uncertain we say so instead of promising it works.

#### Topology and addressing

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.

| Device | Interface | IPv4 address / prefix | Default gateway or note |
| --- | --- | --- | --- |
| R1 | Gi0/0/0 | 192.168.1.1/24, 2001:db8:1:1::1/64 | LAN1 |
| R1 | Gi0/0/1 | 10.0.12.1/30, 2001:db8:12::1/64 | to R2 |
| R1 | Gi0/0/2 | 10.0.13.1/30, 2001:db8:13::1/64 | to R3 |
| R2 | Gi0/0/1 | 10.0.12.2/30, 2001:db8:12::2/64 | to R1 |
| R2 | Gi0/0/2 | 10.0.23.1/30, 2001:db8:23::2/64 | to R3 |
| R2 | Gi0/0/0 | 192.168.3.1/24, 2001:db8:1:3::1/64 | LAN3 |
| R3 | Gi0/0/1 | 10.0.13.2/30, 2001:db8:13::3/64 | to R1 |
| R3 | Gi0/0/0 | 10.0.23.2/30, 2001:db8:23::3/64 | to R2 |
| PC1 | Fa0 | 192.168.1.10/24 | gw 192.168.1.1 |
| PC3 | Fa0 | 192.168.3.10/24 | gw 192.168.3.1 |
| Server3 | Fa0 | 192.168.3.100/24 | gw 192.168.3.1 |

1. Address everythingUse 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.  Done
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`  Done
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`  Done
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`  Done
5. Compare pathsFrom 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.  Done
6. Fail the primaryShut 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.  Done
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`  Done

**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)](https://www.cyberwithmadhav.com/assets/learn/learn-ccna-static-routing-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.

[Previous 3.6 Inter-VLAN Routing and First Hop Redundancy: Router on a Stick, SVIs, HSRP](https://www.cyberwithmadhav.com/learn-ccna-inter-vlan-routing-hsrp.html)[Next 3.8 Single Area OSPFv2: Neighbours, DR/BDR, Cost and Troubleshooting](https://www.cyberwithmadhav.com/learn-ccna-ospf.html)
