Wiki DE Start in the browser

Wiki › Protocols

Static routing

Entering routes by hand: destination network, mask and next hop, default route, outbound and return path and the most common mistakes.

Layer
3 (Vermittlung)
Standard
RFC 1812
See an example
See demo

A route

A static route tells the router: “You reach network X via neighbour Y.”

Router(config)# ip route 192.168.2.0/24 10.0.0.2
Router(config)# ip route 0.0.0.0/0 203.0.113.1
Router# show ip route

The second line is the default route: everything for which there is no more specific route, usually towards the internet. The next hop must lie in a directly connected network.

The order does not matter. If several routes match a destination, the most specific one wins, i.e. the one with the longest prefix (longest match, RFC 1812). For 192.168.2.7 the /24 route applies even if the /0 default route was entered first. Only with equal prefix length does the administrative distance decide. So the default route does not have to be “at the end”; leyoNET still shows the table sorted by prefix like show ip route, with the default route at the bottom. The same applies to IPv6 (default route ::/0). Static routes can be edited with ✎.

Example with two routers

192.168.1.0/24 — R1 — 10.0.0.0/30 — R2 — 192.168.2.0/24
               .1  .1             .2  .1
RouterRoute
R1192.168.2.0/24 via 10.0.0.2
R2192.168.1.0/24 via 10.0.0.1

Both routes are needed: R1 for the outbound path, R2 for the return path of the reply.

Pros and cons

Static routes are clear, secure and need no computing power. But they hardly react to failures (only a backup route steps in, see below), and in large networks every change must be repeated on many routers. There dynamic protocols such as OSPF take over. Companies often have both: OSPF inside, a static default route to the provider.

Backup route (floating static route)

Every route has an administrative distance, static routes normally 1. If you enter the same destination a second time with a larger distance (e.g. 200, on the command line ip route 0.0.0.0/0 10.0.1.2 200), the second one is only used when the first disappears: if its interface has no link any more, the router removes it from the table (RFC 1812). The routing table shows [distance/metric] for every route.

Distance and metric in the table

show ip route shows [distance/metric] for every route, for static routes usually [1/0]: distance 1, metric 0. The metric hardly matters for static routes, because the path is fixed. The distance, on the other hand, decides whether a static route wins against an OSPF or RIP route to the same network (static 1 beats OSPF 110). Important: both only count when the prefix length is equal. The whole order is explained in Route selection: prefix, distance and metric.

How to do it in leyoNET

The same text as in the app’s help (F1 key).

Routing

The routing table says via which neighbour a network is reachable. Entries come from:

  • connected networks
  • automatic routing for beginners: the router calculates its routes by itself (Automatic routing)
  • static routes, entered by hand
  • dynamic protocols: OSPF, RIP, BGP

The choice follows RFC 1812: the most specific route (longest prefix); on a tie the lower administrative distance (connected 0, static 1, eBGP 20, OSPF 110, RIP 120, iBGP 200), then the lower metric (RIP: hops, OSPF: cost). The table shows both as [distance/metric].

Backup route: A static route with a larger distance (e.g. 200) is only used when the better one disappears, for instance because its interface has no link (floating static route). Distance 255 = never use.

See an example

  • Demo “Static routes” in leyoNETDemo “Static routes” in leyoNET
    Static routes

    Two routers, each knows the remote network through a static route.

    «tracert» shows both routers as hops. Delete a route and try again: destination network unreachable.

    Watch live Project file

“Watch live” opens the network in leyoNET, the simulation runs in a loop. In the app you find it under File → Demo networks, ready to present.

Practise

  • ★★☆☆☆ Two routers, two static routes · 3 goals · Worksheet (German)
  • ★★★☆☆ UE04 Router02 – Task 2: two routers with a transit network · 5 goals · Worksheet (German)
  • ★★★★☆ UE05 Router03: three sites with transit networks · 15 goals · Worksheet (German)
  • ★★★☆☆ Static routing – Task 1: Connect three routers statically · 14 goals · Worksheet (German)
  • ★★★★☆ Sites over a serial line · 2 goals · Worksheet (German)

In leyoNET under Tools → Exercise catalogue. Every exercise checks itself.

Standards

  • RFC 1812 – Requirements for IP Version 4 Routers

Read on

Found a mistake or have an idea? Source of this page on GitHub.