All lessons
Intermediate·30 minute read

Static routing & default gateways

Short answer

A static route is a line you type to tell a router which next hop reaches a destination network: ip route <network> <mask> <next-hop>. When several routes match, the router uses the most specific one (longest prefix). A default route, 0.0.0.0/0, catches everything no other route matches.

Static routing is the simplest possible way to teach a router which way to send packets for a given destination network. This lesson covers connected, static, and default routes, longest-prefix match, and the gotchas that catch every student the first time.

Open this lab

What a routing table actually contains

A routing table is a list of (destination network, next hop, outgoing interface) tuples. When a packet arrives, the router looks up the destination IP, finds the most specific matching route, and forwards the packet out the listed interface toward the listed next hop.

Routes come from three sources in NetForge-AI: connected (learned automatically when you assign an IP to an interface), static (manually configured with ip route), and default (a 0.0.0.0/0 catch-all set with ip default-gateway or ip route 0.0.0.0 0.0.0.0).

Longest-prefix match

When two routes both match a destination, the router uses the one with the longer prefix. A /24 beats a /16. A /32 host route beats everything except an identical /32. This rule is why you can have a default route to the Internet and more-specific internal routes simultaneously, with internal traffic always preferring the specific match.

Configuring a static route

Static routes are written as: ip route <network> <mask> <next-hop>. For a router that wants to reach 10.0.2.0/24 via 10.0.99.2:

R1> enable
R1# configure terminal
R1(config)# ip route 10.0.2.0 255.255.255.0 10.0.99.2
R1(config)# end
R1# show ip route
S 10.0.2.0/24 [1/0] via 10.0.99.2, Se0/0/0

Default gateway: the most common mistake

Endpoints (PCs, servers) don't run a routing protocol — they just have one default gateway. If a PC's destination IP is in its own subnet, it ARPs the destination directly. Otherwise, it sends the frame to the gateway's MAC and lets the router worry about it.

A misconfigured default gateway is the #1 reason 'my network is down' tickets are created. If the PC's gateway is wrong, even pings to other subnets fail with no useful error.

Note: In NetForge-AI, set a PC's gateway in the right-hand panel. The simulator immediately rebuilds the device's routing table to add a 0.0.0.0/0 entry.

Common questions

What is the command for a static route?
ip route <network> <mask> <next-hop>, in global configuration mode — for example ip route 10.0.2.0 255.255.255.0 10.0.99.2.
What is a default route?
A route to 0.0.0.0/0. It matches every destination, so the router uses it only when nothing more specific matches — typically to send traffic toward the internet.
Why does ping to another subnet fail when the local ping works?
Usually the PC's default gateway is missing or wrong, or a router on the path has no route back to the source network.

Practice this in the lab

Reading helps. Wiring it up yourself and breaking it makes it stick.

Open the lab