Network Bytes · Episode 45 · CCNA 3.3
Static and default routes
A static route is a route an engineer types into a router by hand. The default route, 0.0.0.0/0, matches every address and is used only when no more specific route matches.
Signs at a junction
Picture a junction with signs. One says: library, turn left. One says: airport, turn right. And at the bottom: everywhere else, straight ahead. A router's routing table works the same way. Each entry says "for this group of addresses, go this way," and the router follows the sign that fits the packet's destination best.
Static routes: signs put up by hand
A router learns some routes on its own (networks plugged into its interfaces, or routes shared by a routing protocol). A static route is one an engineer configures by hand. On a Cisco router the command is:
ip route <network> <mask> <next hop or exit interface>
For example, ip route 10.1.1.0 255.255.255.0 10.0.0.2 tells the router: to reach 10.1.1.0/24, send packets to the next router at 10.0.0.2. Static routes have an administrative distance of 1 by default, so the router trusts them more than routes from any routing protocol (EP44). They never change on their own: if the network changes, someone has to update them.
The default route: 0.0.0.0/0
The bottom sign is the default route. It's written 0.0.0.0/0. The /0 means zero network bits have to match, so it matches every IPv4 address there is. On a Cisco router you set one with ip route 0.0.0.0 0.0.0.0 <next hop>. In show ip route it shows up as S* (static, candidate default) and the router prints a Gateway of last resort line naming the next hop.
Least specific, used last
Because a /0 is the least specific route possible, it always loses to any longer route that also matches (longest prefix match, EP43). So the router only uses it when nothing better matches. Your home router is the classic example: it knows your home network and has one default route that sends everything else to your internet provider. IPv6 has the same idea, written ::/0.
Try it yourself
In Cisco Packet Tracer (free with a Cisco Networking Academy account), connect two routers and give each a LAN. On the first router, add a static route to the second router's LAN with ip route <network> <mask> <next hop>, then run show ip route and find the line that starts with S. Ping a PC on the far LAN to check it works. Then remove the route with no ip route ... and ping again to see it fail.
Good to know
- Cisco IOS static route:
ip route <network> <mask> <next-hop or exit interface>, administrative distance 1 by default. - A static default route is
ip route 0.0.0.0 0.0.0.0 <next hop>, shown asS*with a "Gateway of last resort" line inshow ip route. - The default route has prefix length 0, so it matches every IPv4 address but always loses to any longer matching route (longest prefix match, EP43).
- IPv6 uses
::/0for the default route. - Default routes can also be learned from a routing protocol or from DHCP, not only typed in by hand.
203.0.113.5comes from a block reserved for documentation (RFC 5737), so it's safe to use in examples.
For CCNA learners
This lines up with CCNA 200-301 exam topic 3.3, configure and verify IPv4 and IPv6 static routing: know the ip route syntax, how a default route (0.0.0.0/0, ::/0) differs from a network route, and how they appear in show ip route.
Answer to the comment question
The default route, 0.0.0.0/0. 10.1.1.0/24 covers only 10.1.1.0 to 10.1.1.255, so it doesn't contain 203.0.113.5. Nothing more specific matches, so the router falls back to the default route and sends the packet to its gateway of last resort.
Test your knowledge
Quick quiz: Static and default routes
4 multiple-choice questions. Pick one answer for each, then check how you did.
Sources
- Cisco, "Configure a Gateway of Last Resort that Uses IP Commands":
ip route 0.0.0.0 0.0.0.0 <next hop>sets the gateway of last resort, shown inshow ip route - Cisco, IP Routing Configuration Guide (IOS XE), "Basic IP Routing": static routes and default routes configured by hand
- IETF, RFC 4632, Classless Inter-domain Routing (CIDR): prefix-length notation and longest match, so 0.0.0.0/0 loses to any longer match
- IETF, RFC 5737, IPv4 Address Blocks Reserved for Documentation: 203.0.113.0/24 used in the comment question
- Cisco, CCNA 200-301 v1.1 exam topics: 3.3 configure and verify IPv4 and IPv6 static routing
Video transcript
What does a route to 0.0.0.0/0 mean?
Picture signs at a junction. One says: library, turn left. One says: airport, turn right. And at the bottom: everywhere else, straight ahead.
A static route is a sign an engineer puts up by hand. You tell the router: to reach this network, send packets to that next router.
The bottom sign is the default route. It's written 0.0.0.0/0. Zero network bits means it matches every address there is.
Because it's the least specific route, it's only used when nothing better matches. Your home router uses one to send everything to your internet provider.
A router knows 10.1.1.0/24, plus a default route. A packet heads to 203.0.113.5. Which route does it take? Comment your answer below!
That's your byte.
More from Network Bytes
- EP43Longest prefix match
- EP44Administrative distance
- EP46OSPF in 60 seconds
- EP47OSPF neighbors and DR/BDR