Skip to content

Lab 04-01 · The default route: "all other directions"

MTCNA

Module 4 · Routing of the MikroTik MTCNA course, official slides p160–173 (what routing is, the routing table, most specific route, check-gateway, administrative distance, the default gateway, the LAB "Puerta de enlace predeterminada" on p169–170, dynamic routes and route flags).

Drive out of any town and look at the first roundabout. There are signs for a few places: Hospital, Airport, Port. And there is always one more sign, the most useful one: "All other directions". You do not need a sign for every town in Europe. If your town is not listed, you follow that one.

Your router works exactly like that roundabout. It knows a few networks by name (its own LAN, the classroom network), and for everything else, the whole Internet, it follows one sign: the default route. Until today the router got that sign automatically from DHCP, so you never saw it. In this lab you take it away, watch the Internet disappear, and put the sign back up by hand.

What you will learn

  • Explain what a routing table is and read one: destination, gateway, distance, flags.
  • Explain the default route 0.0.0.0/0 and why the router needs it to reach the Internet.
  • Use the most specific route rule (longest prefix) and administrative distance to predict which route wins.
  • Stop the DHCP client from installing the default route and see the Internet break.
  • Add a static default route by hand and check it with ping and a web page.
  • Read the RouterOS v7 route flags (D, A, c, s, d) and spot the trap: they changed from v6.

The analogy: the roundabout

Roundabout Router What it means
A road sign A route "To reach this place, go that way"
The town written on the sign The destination (dst-address) A network, like 192.168.89.0/24
The road the sign points to The gateway The next router to hand the packet to
"Hospital (1 km)" beats "City centre" The most specific route A smaller, more precise network wins
"All other directions" The default route 0.0.0.0/0 Used when no other sign matches
All the signs together The routing table IP → Routes

What is routing?

Routing is choosing, for every packet, where to send it next. It works at Layer 3 (the network layer), using IP addresses.

A bridge (Module 3) joins networks into one. A router does the opposite: it keeps networks separate and passes packets between them. For each packet it looks at the destination IP address, searches its routing table, and sends the packet to the gateway of the best matching route. The gateway is the next router on the way, which repeats the same process, hop by hop, until the packet arrives.

A route is one line of the routing table: a destination network and the gateway (the next hop) that leads there.

In RouterOS: WinBox IP → Routes, terminal /ip route print.

Which route wins? Most specific first

A packet can match several routes. Slide p164's example:

Route Gateway
192.168.90.0/24 1.2.3.4
192.168.90.128/25 5.6.7.8

A packet for 192.168.90.135 matches both (.135 is inside .0–.255 and inside .128–.255). The router picks the most specific one, the /25, because it describes a smaller, more precise network. So the packet goes to 5.6.7.8. This is the longest prefix match rule: the longer the prefix (the number after the slash), the more specific the route.

The default route 0.0.0.0/0 has a prefix of zero: it matches every address, and it is the least specific route possible. That is why it only wins when nothing else matches.

Equally specific? The distance breaks the tie

If two routes are equally specific, the router compares their administrative distance (RouterOS: distance). It is a number that says how much the router trusts the source of the route. Lower wins.

Route source Distance (default)
Connected (an address on the router's own interface) 0
Static (typed by hand) 1
eBGP 20
OSPF 110
RIP 120
iBGP 200

Slide p167 adds: if two routes are equally specific and have the same distance, it depends on the vendor. The slide says MikroTik uses the one it learned first; the current RouterOS manual simply says the active one is chosen arbitrarily, so never rely on the order. You will meet the exception, ECMP, in Lab 04-04.

Routes that check their gateway

A route can test whether its gateway is alive with check-gateway (slide p165): every 10 seconds it sends a ping (or an ARP request); after two timeouts in a row, the route is marked inactive and the next best route takes over. You will use it in Labs 04-04 and 04-05.

The default route

The default route (or default gateway) is the route to 0.0.0.0/0: "every destination". The router sends there all traffic for which it has no more specific route.

At home, your router's default route points at your Internet provider. Here it points at the trainer's router, class-ap (10.0.0.1). Without it, your router only knows the networks it is directly connected to, and the Internet does not exist for it.

Where routes come from, and the v7 flags

Routes appear in three ways:

  • Connected: when you add an IP address to an interface, RouterOS creates the route to that network by itself (slide p171). 192.168.88.1/24 on bridge1 creates 192.168.88.0/24 → bridge1.
  • Dynamic from a protocol: the DHCP client can install a default route; OSPF or BGP install many.
  • Static: you type them. They stay until you remove them.

Each line of /ip route print starts with flags. The slides (p171–172) show RouterOS v6 flags in capitals, like ADC. RouterOS v7 prints them differently:

Flag Meaning v6 equivalent on the slides
D Dynamic: created by RouterOS, not typed by you D
A Active: the route is in use A
c connect: comes from an address on an interface C
s static: typed by hand S
d dhcp: installed by the DHCP client (shown as ADS in v6)
I Inactive: exists but is not in use (gateway unreachable...) —
+ ECMP: one of several equal routes (Lab 04-04) —

So DAc in v7 is the v6 ADC (same letters, different order and case), and a DHCP default route looks like DAd.

The scenario

flowchart LR
    INET["<b>internet</b><br>198.51.100.10<br>web server"]
    CAP["<b>class-ap</b><br>trainer's router<br>10.0.0.1"]
    subgraph R1["r1 · your router"]
        WAN["ether2 (WAN)<br>DHCP client 10.0.0.x"]
        BR["<b>bridge1</b> (LAN)<br>192.168.88.1/24"]
    end
    PC1["<b>pc1</b><br>your laptop<br>192.168.88.x"]
    INET ---|"198.51.100.0/24"| CAP
    CAP ---|"10.0.0.0/24"| WAN
    BR ---|"ether3"| PC1
    WAN -.->|"default route 0.0.0.0/0<br>gateway 10.0.0.1"| CAP
Node Role Address
internet "The Internet": answers ping, serves a web page 198.51.100.10/24
class-ap The trainer's router: class gateway, DHCP, DNS, NAT 10.0.0.1/24, 198.51.100.1/24
r1 Your router, factory setup: ether2 = Internet port, ether3 = LAN port in bridge1 WAN by DHCP · LAN 192.168.88.1/24
pc1 Your laptop (Linux) By DHCP from r1

Why ether2 and not ether1?

On a real hAP the Internet port is ether1. In the virtual lab ether1 is reserved for the lab itself (containerlab uses it to manage the router), so the Internet port is ether2 and the LAN ports start at ether3. Never touch ether1 in these labs. In the classroom your hAP's ether1 is plugged by cable into the trainer's router, exactly like ether2 here.

Start the lab

Download the lab files and unzip them: 04-01-default-route.zip. Open a terminal inside the 04-01-default-route folder.

sudo containerlab deploy -t topology.clab.yml

Give RouterOS about two minutes to boot. Then:

ssh admin@clab-mtcna-04-01-r1            # password: admin
docker exec -it clab-mtcna-04-01-pc1 bash

The laptops ask for their address by themselves when the lab starts; if ip -br address show eth1 shows no IPv4 address yet (the router was still booting), run dhclient -v eth1.

At any moment you can run CLAB_EXEC="docker exec" ./check.sh to see which parts are already solved.

Step 1 · Read the routing table

Before changing anything, read the signs your router already has.

WinBox: IP → Routes.

/ip route print
/ip route print detail

Expected (the addresses 10.0.0.x may differ):

Flags: D - DYNAMIC; A - ACTIVE; c - CONNECT, d - DHCP
    DST-ADDRESS       GATEWAY   ROUTING-TABLE  DISTANCE
DAd 0.0.0.0/0         10.0.0.1  main                  1
DAc 10.0.0.0/24       ether2    main                  0
DAc 172.31.255.28/30  ether1    main                  0
DAc 192.168.88.0/24   bridge1   main                  0

Four routes. Two are your networks (c, connected, distance 0). One is the lab's management network on ether1: ignore it. And one is the default route, installed by the DHCP client (d), pointing at 10.0.0.1.

Test it from the router and from the laptop:

/ping 198.51.100.10 count=3
curl http://www.mikrotik.com/

Both work; curl prints Welcome to the Internet.

Check yourself

  1. For each of the four routes, say where it came from: an address you configured, DHCP, or the lab.
  2. Why does 192.168.88.0/24 point at an interface (bridge1) and the default route at an IP address (10.0.0.1)?

Done when you can explain every line of the table.

Step 2 · Stop DHCP from installing the default route

The slides (p169) say: disable "Add Default Route" in the DHCP client settings and check the Internet connection (it does not work). The DHCP client keeps getting the address; it just stops putting up the sign.

WinBox: IP → DHCP Client, double-click the client on ether2, Add Default Route: no.

/ip dhcp-client set [find interface=ether2] add-default-route=no
/ip route print

Expected: the DAd 0.0.0.0/0 line is gone. The two connected routes are still there.

Now test again:

/ping 198.51.100.10 count=3
curl -m 5 http://www.mikrotik.com/

The router answers no route to host, and curl fails. The router still knows 10.0.0.0/24 (try /ping 10.0.0.1 count=3: it works), but for 198.51.100.10 there is no sign at all.

Check yourself

  1. ping 10.0.0.1 works but ping 198.51.100.10 does not. Explain why with the routing table.
  2. Did the router lose its WAN address 10.0.0.x? Why not?

Done when /ip route print has no 0.0.0.0/0 line and the Internet is unreachable.

Step 3 · Add the default route by hand

The slides (p170): add the default gateway manually (the trainer's router) and check that the Internet is available. The trainer's router is 10.0.0.1.

WinBox: IP → Routes → +, Dst. Address 0.0.0.0/0, Gateway 10.0.0.1.

/ip route add dst-address=0.0.0.0/0 gateway=10.0.0.1
/ip route print

Expected:

#     DST-ADDRESS       GATEWAY   ROUTING-TABLE  DISTANCE
0  As 0.0.0.0/0         10.0.0.1  main                  1
  DAc 10.0.0.0/24       ether2    main                  0

The new line has A (active) and s (static), and no D: it is yours, not RouterOS's. Its distance is 1, the default for static routes.

The gateway must be reachable

A gateway must be in a network the router is directly connected to. 10.0.0.1 is fine because 10.0.0.0/24 is a connected route. If you typed a gateway the router cannot reach (for example 10.9.9.9), the route would appear with the flag I (inactive) and nothing would work.

Done when the static default route shows the flags As.

Step 4 · Test the Internet again

From the router and from the laptop:

/ping 198.51.100.10 count=3
curl http://www.mikrotik.com/
traceroute -n 198.51.100.10

curl prints Welcome to the Internet again. traceroute shows the path: 192.168.88.1 (your router), 10.0.0.1 (class-ap), 198.51.100.10 (the web server).

Check yourself

  1. Copy the three hops of your traceroute. Which hop used the default route you just typed?
  2. Why is a static default route a problem if the classroom gateway ever changes its address? Why is the DHCP one not?

Done when curl works from pc1. Run CLAB_EXEC="docker exec" ./check.sh: every line must say PASS.

Backup: no cable available?

In our classroom the hAP's ether1 reaches the trainer's router by cable. If you had to use WiFi instead (wlan1 as a station, as in the WiFi module), nothing in this lab changes except the interface name: the DHCP client lives on wlan1 and the default route still points at 10.0.0.1.

If something goes wrong

Symptom Likely cause Fix
The default route did not disappear in Step 2 You changed the wrong DHCP client (the one on ether1) /ip dhcp-client print; change the one on ether2
The new route shows I (inactive) Typo in the gateway, or a gateway outside 10.0.0.0/24 /ip route set [find dst-address=0.0.0.0/0] gateway=10.0.0.1
Router pings the Internet but pc1 cannot pc1 has no address or no default route dhclient -r eth1; dhclient -v eth1, then ip route
curl by name fails but curl http://198.51.100.10 works DNS: the router has no DNS server /ip dns print; the DHCP client must still provide 10.0.0.1 (use-peer-dns=yes)
Two default routes in the table You turned add-default-route back on Keep only one: set it to no again

Clean up

sudo containerlab destroy -t topology.clab.yml --cleanup

Key takeaways

  • Routing works at Layer 3: for each packet the router looks up the destination in its routing table and sends it to the route's gateway.
  • The most specific route (longest prefix) wins; between equally specific routes, the lowest distance wins.
  • The default route 0.0.0.0/0 matches everything and is used when nothing more specific matches.
  • Routes are connected (from interface addresses), dynamic (DHCP, OSPF...) or static (typed by hand).
  • RouterOS v7 shows flags like DAc, DAd, As: lowercase letters for the route's source, unlike the v6 capitals on the slides.
  • A gateway must be reachable through a connected network, otherwise the route is inactive.

Quick check

1. A router has routes to 10.0.0.0/8 via A and to 10.1.0.0/16 via B. Where does it send a packet for 10.1.2.3?
  • To A, because its route was added first
  • To B, because 10.1.0.0/16 is the more specific route
  • To A, because /8 covers more addresses
  • To both, splitting the traffic

Both routes contain 10.1.2.3, but /16 is a longer prefix than /8, so it describes a smaller, more precise network. The most specific route wins: the packet goes to B.

2. What does the destination 0.0.0.0/0 mean in a routing table?
  • No destination: the route is disabled
  • Only the address 0.0.0.0
  • Every possible IPv4 address: it is the default route
  • The router's own address

A prefix of /0 fixes zero bits, so it matches every address. That is the default route, the "all other directions" sign, used only when no more specific route matches.

3. Two routes to the same network are equally specific: one static, one learned by OSPF. Which one is used?
  • The static one, because distance 1 beats distance 110
  • The OSPF one, because protocols are more modern
  • The one with the higher distance
  • Neither: RouterOS refuses duplicate routes

With equal specificity, the lowest administrative distance wins. Static routes have 1 and OSPF 110 by default, so the static route is used.

4. In RouterOS v7, a route line starts with DAc. What kind of route is it?
  • A disabled static route typed by hand
  • A dynamic, active route created from an address on an interface
  • A route learned from the DHCP client
  • An inactive route waiting for its gateway

D = dynamic (RouterOS made it), A = active, c = connect: it comes from an IP address on one of the router's interfaces. The v6 slides write the same thing as ADC.

5. After disabling Add Default Route, the router can ping 10.0.0.1 but not 198.51.100.10. Why?
  • The DHCP client lost its address
  • The trainer's router blocks pings from students
  • 10.0.0.0/24 is a connected route, but no route matches 198.51.100.10 any more
  • NAT stops working without a DHCP client

10.0.0.1 is inside a connected network, so the router still knows how to reach it. For 198.51.100.10 only the default route matched, and it is gone: the router answers no route to host.

6. You add a static default route with a gateway outside every network the router is connected to. What happens?
  • The router finds the gateway through the DHCP client
  • The route is added but stays inactive
  • The route is used anyway, through ether1
  • RouterOS replaces the gateway with 10.0.0.1

A gateway must be reachable through a connected route. If it is not, RouterOS keeps the route with the flag I (inactive) and does not use it.

7. Your phone's hotspot gives your laptop an address. Which value plays the role of the default route on the laptop?
  • The DNS server address
  • The laptop's own IP address
  • The default gateway, the phone's address
  • The subnet mask

On any device, the default gateway is its default route: "send everything that is not on my own network to this address". Here, the phone. Your laptop's routing table (ip route) shows it as default via ....

Next: your neighbour's laptop lives in another network, 192.168.89.0/24. The default route sends it to the classroom gateway, which has never heard of it. Time for your first static route.