Skip to content

Lab 04-03 · Static routing through a neighbour (optional)

MTCNA

Module 4 · Routing of the MikroTik MTCNA course, official slides p177–178 (optional LAB "Enrutamiento estático": create a route to neighbour A's laptop through neighbour B's router).

In class you want to pass a note to Alex, who sits at the other end of the room. You could walk over. Or you could hand it to Bea, who sits in between, and ask her to pass it on. Bea must agree, and she must know where Alex sits. If she does not, the note ends up on the floor.

In Lab 04-02 your router knocked directly on the door of the neighbour's router. Now you take the long way on purpose: to reach neighbour A's laptop, you send your packets to neighbour B's router, and B passes them on to A. The point is not that it is a good path (it is not), but to see that every router on the way makes its own decision, and needs its own route.

What you will learn

  • Explain hop-by-hop routing: each router only decides the next hop, never the whole path.
  • Build a two-hop path with static routes on two different routers.
  • Diagnose a half-built path with traceroute: the last hop that answers tells you who is missing a route.
  • Explain why the replies can come straight back without crossing B (NAT again).
  • Recognise an ICMP redirect, the router's way of saying "there is a shorter way".

The analogy: passing a note

Classroom Network What it means
You r1 (your router) and pc1 Where the packet starts
Bea, in the middle r3, neighbour B's router The first gateway: 10.0.0.13
Alex, at the far end r2, neighbour A's router Where B must pass it: 10.0.0.12
"Give this to Bea" Your static route 192.168.89.0/24 → 10.0.0.13 You only decide the next hand
"Bea, give it to Alex" B's static route 192.168.89.0/24 → 10.0.0.12 B decides her own next hand

Hop-by-hop routing

In IP routing, every router decides only the next hop for a packet, using its own routing table. Nobody plans the whole path in advance. This is called hop-by-hop routing.

That is why your route alone is not enough: the moment the packet reaches B, it is B's routing table that counts. If B has no route for 192.168.89.0/24, B uses its default route and the packet goes to the classroom gateway, which drops it.

flowchart LR
    PC1["<b>pc1</b>"] -->|"default route"| R1["<b>r1 (you)</b><br>192.168.89.0/24<br>→ 10.0.0.13"]
    R1 -->|"hop 2"| R3["<b>r3 (B)</b><br>192.168.89.0/24<br>→ 10.0.0.12"]
    R3 -->|"hop 3"| R2["<b>r2 (A)</b><br>connected"]
    R2 -->|"delivered"| PC2["<b>pc2</b><br>A's laptop"]

The scenario

flowchart LR
    INET["<b>internet</b><br>198.51.100.10"]
    CAP["<b>class-ap</b><br>10.0.0.1"]
    R1["<b>r1 · you</b><br>10.0.0.11<br>LAN 192.168.88.0/24"]
    R2["<b>r2 · neighbour A</b><br>10.0.0.12<br>LAN 192.168.89.0/24"]
    R3["<b>r3 · neighbour B</b><br>10.0.0.13<br>LAN 192.168.90.0/24"]
    PC1["<b>pc1</b><br>your laptop"]
    PC2["<b>pc2</b><br>A's laptop"]
    PC3["<b>pc3</b><br>B's laptop"]
    INET --- CAP
    CAP ---|"class network 10.0.0.0/24"| R1
    CAP ---|"class network"| R2
    CAP ---|"class network"| R3
    R1 --- PC1
    R2 --- PC2
    R3 --- PC3
Node Role Address
class-ap The trainer's router: class gateway, DNS, NAT 10.0.0.1/24
r1 Your router (group 1) WAN 10.0.0.11/24 · LAN 192.168.88.1/24
r2 Neighbour A's router (group 2) WAN 10.0.0.12/24 · LAN 192.168.89.1/24
r3 Neighbour B's router (group 3) WAN 10.0.0.13/24 · LAN 192.168.90.1/24
pc1, pc2, pc3 The three laptops, by DHCP from their own router 192.168.88.254, 192.168.89.254, 192.168.90.254
internet "The Internet" 198.51.100.10/24

All three routers start like Lab 04-02's starting point: fixed class address, default route to 10.0.0.1, masquerade on ether2, and no routes to the neighbours.

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-03-static-routing-via-neighbour.zip. Open a terminal inside the 04-03-static-routing-via-neighbour folder.

sudo containerlab deploy -t topology.clab.yml

Four RouterOS routers have to boot: give it about three minutes. Then:

ssh admin@clab-mtcna-04-03-r1            # password: admin   (also r2, r3)
docker exec -it clab-mtcna-04-03-pc1 bash   # also pc2, pc3

You configure r1 and you play neighbour B on r3. In class, team up with two neighbours (slide p177). At any moment you can run CLAB_EXEC="docker exec" ./check.sh.

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.

Step 1 · Send A's traffic to B

On r1. WinBox: IP → Routes → +, Dst. Address 192.168.89.0/24 (A's LAN), Gateway 10.0.0.13 (B's router).

/ip route add dst-address=192.168.89.0/24 gateway=10.0.0.13
/ip route print

Expected: a new As line 192.168.89.0/24 → 10.0.0.13.

Done when the route is active.

Step 2 · Watch the packet get lost at B

On pc1:

ping -c 3 192.168.89.254
traceroute -n 192.168.89.254

Expected: the ping fails, and the traceroute reads like a detective story:

 1  192.168.88.1         ← your router: OK
 2  10.0.0.13            ← B received it: your route works
 3  10.0.0.1  !N         ← B sent it to the classroom gateway, which says "network unreachable"

B has no route for 192.168.89.0/24, so B used its default route. The !N is the classroom gateway answering "I have no route to that network".

Check yourself

  1. Which router made the wrong decision, and why was it not "wrong" from its own point of view?
  2. What does !N in a traceroute mean?

Done when you can point at the hop where the packet got lost.

Step 3 · Teach B the way to A

On r3 (neighbour B; in class, B does this on their hAP):

/ip route add dst-address=192.168.89.0/24 gateway=10.0.0.12

On pc1 again:

ping -c 3 192.168.89.254
traceroute -n 192.168.89.254

Expected: the ping works, and the traceroute shows the detour:

 1  192.168.88.1
 2  10.0.0.13        ← B
 3  10.0.0.12        ← A
 4  192.168.89.254   ← A's laptop

Done when pc1 pings pc2 and the traceroute goes through 10.0.0.13. Run CLAB_EXEC="docker exec" ./check.sh: every line must say PASS.

Step 4 · Look at the way back

The replies do not have to follow the same path. Run tcpdump -ni eth1 icmp on pc2 while pc1 pings again. pc2 sees the requests coming from 10.0.0.13: B's router also has a masquerade rule on ether2, and the packet entered and left B through ether2, so B rewrote the sender (your router had already rewritten it to 10.0.0.11 before). A replies to 10.0.0.13, B undoes its translation and sends it to 10.0.0.11, and your router undoes its own.

ICMP redirect: \"there is a shorter way\"

B notices something odd: the packet came in through ether2 and goes out through the same ether2, to a router (10.0.0.12) that you could reach directly. A router in that situation may send an ICMP redirect back: "next time, send this straight to 10.0.0.12". RouterOS sends redirects by default (/ip settings, send-redirects=yes) but does not obey them (accept-redirects=no), so your detour stays. That is good here, because the detour is the whole point of the exercise.

Check yourself

  1. Which sender address does pc2 see? Explain the two translations the packet went through.
  2. Why is sending traffic through B a bad idea in a real network, if A can be reached directly?

Done when you can explain the way back.

If something goes wrong

Symptom Likely cause Fix
Traceroute: hop 2 is 10.0.0.1 Your route points at the wrong gateway, or is missing /ip route print; gateway must be 10.0.0.13
Traceroute: hop 2 10.0.0.13, hop 3 10.0.0.1 !N B has no route to A's LAN Step 3 on r3
Traceroute: 10.0.0.13, 10.0.0.12, then stars pc2 has no address On pc2: dhclient -v eth1
Traceroute goes 10.0.0.12 directly You still have the direct route from Lab 04-02 Remove it: /ip route remove [find gateway=10.0.0.12]
B's route shows I Typo in B's gateway /ip route set [find dst-address=192.168.89.0/24] gateway=10.0.0.12 on r3

Clean up

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

Key takeaways

  • IP routing is hop-by-hop: each router decides only the next hop, using its own routing table.
  • A path through several routers needs a route on every router that is not directly connected to the destination.
  • traceroute shows where a packet gets lost: the last hop that answers is where to look.
  • The way back can be different from the way there; masquerade on each router changed it here.
  • A router may send an ICMP redirect when it sees a shorter path; RouterOS sends them but ignores the ones it receives.

Quick check

1. What does each router decide about a packet in IP routing?
  • The complete path from the source to the destination
  • Only the next hop, using its own routing table
  • Only whether to drop it or not
  • The path chosen by the first router on the way

IP routing is hop-by-hop. Each router looks up the destination in its own routing table and picks the next hop. Nobody plans the whole path.

2. You have the route to A's LAN via B, but B has no route to A's LAN. What happens to your ping?
  • B forwards it to A anyway, because they share a network
  • B follows its default route to the classroom gateway, which drops it
  • Your router notices and sends it to A directly
  • The ping works, but slower

B only uses its own routing table. Without a specific route, the packet matches B's default route and goes to class-ap, which has no route to 192.168.89.0/24 and answers "network unreachable".

3. A traceroute shows 192.168.88.1, then 10.0.0.13, then 10.0.0.1 !N. Who is missing a route?
  • Your router, r1
  • Neighbour B's router, r3
  • Neighbour A's router, r2
  • A's laptop, pc2

The packet reached B (10.0.0.13) correctly, then went to the classroom gateway: B used its default route. So B is missing the route to A's LAN.

4. Which of these routes must neighbour B add for the detour to work?
  • dst-address=192.168.88.0/24 gateway=10.0.0.11
  • dst-address=192.168.89.0/24 gateway=10.0.0.12
  • dst-address=192.168.90.0/24 gateway=10.0.0.13
  • dst-address=0.0.0.0/0 gateway=10.0.0.12

B must hand packets for A's LAN (192.168.89.0/24) to A's router (10.0.0.12). A default route via A would also send all of B's Internet traffic to A.

5. What is an ICMP redirect?
  • A message that moves a web page to another address
  • A firewall rule that changes the destination of a packet
  • A message from a router saying there is a better next hop for that destination
  • The answer of a router that has no route

A router that receives a packet and sends it back out the same interface to another router on that network can send an ICMP redirect: "next time, use that router directly". RouterOS sends them but does not accept them by default.

6. During the detour, which sender address does A's laptop see in tcpdump?
  • 192.168.88.254, your laptop
  • 10.0.0.11, your router
  • 10.0.0.13, B's router
  • 10.0.0.1, the classroom gateway

Your router masqueraded the packet to 10.0.0.11, and then B's masquerade rule (on ether2, where the packet left B) rewrote it again to 10.0.0.13. A's laptop only sees the last translation.

Next: what if you used both paths at the same time, the direct one and the detour? That is ECMP.