Wired LAN with RouterOS¶
Practical 3.4 wired-lan-with-routeros-annex.pdf · PDF
At home you plug a cable into the router and, a second later, you are online. You never typed an address. You never chose a DNS server. Somebody did all of that for you, years ago, in a factory. Today that somebody is you.
Last session your group cabled its LAN. The link lights came on... and nothing worked. A blank MikroTik does not hand out addresses, does not answer names, and does not even pass traffic from one port to the next. By the end of this page you will know the four pieces that turn a box of ports into a working LAN, and how to build them on RouterOS, MikroTik's operating system.
What you will learn
- Explain what a bridge is and why a blank router needs one to behave like a switch
- Give the router an address in your group's LAN (
10.G.0.1/24) on the right interface - Set up a DHCP server with a pool, a gateway and a DNS server, and read its lease table
- Turn the router into the LAN's DNS server and add a static name
- Check the LAN from a PC (
ip,ping,dig) and save the router's configuration with/export - Why "DHCP gives you internet" is a trap
What a LAN needs: four pieces¶
Think about what the router at home does without you noticing. It has done four jobs since the day it was switched on:
| Piece | What it does | Where in RouterOS (WinBox) |
|---|---|---|
| 1 · Bridge | Joins several ports into one LAN, like a switch | Bridge → Bridge, Ports |
| 2 · Address | Gives the router a place in the LAN, so it can be the gateway | IP → Addresses |
| 3 · DHCP server | Hands out an address, gateway and DNS server to every PC | IP → DHCP Server |
| 4 · DNS | Answers name questions for the LAN | IP → DNS |
A MikroTik with no configuration has none of them. You will add them in this order, because each one needs the one before.
flowchart LR
B["<b>1 · Bridge</b><br>the corridor that<br>joins the rooms"] --> A["<b>2 · Address</b><br>10.G.0.1/24<br>on the bridge"]
A --> D["<b>3 · DHCP server</b><br>hands out addresses<br>from the pool"]
D --> N["<b>4 · DNS</b><br>answers names<br>for the LAN"]
The bridge: a switch inside the router¶
A bridge is a software switch inside the router: it joins several ports into one LAN.
Picture a blank MikroTik as a house with five separate rooms and no doors between them. Each port (ether1 to ether5) is a room. A PC in room ether2 cannot reach a PC in room ether3: nothing passes.
The bridge is the corridor that joins the rooms. Once ether2 to ether5 open onto the corridor, anything said in one room can reach the others. The bridge learns which MAC address lives behind which port, exactly like the switch you met in Ethernet, MAC and switching.
flowchart TB
subgraph BEFORE ["Blank router: five separate rooms"]
direction LR
E2a["ether2"]
E3a["ether3"]
E4a["ether4"]
E5a["ether5"]
end
subgraph AFTER ["With a bridge: one corridor"]
direction LR
BR["<b>bridge-lan</b><br>the corridor<br>10.G.0.1/24"]
E2b["ether2"] --- BR
E3b["ether3"] --- BR
E4b["ether4"] --- BR
E5b["ether5"] --- BR
end
BEFORE -->|"add the ports<br>to the bridge"| AFTER
Careful: a router's ports are not automatically a switch
On your home router the yellow ports look like a switch because the factory already made a bridge for you. On a blank MikroTik every port is a separate network until you bridge them.
Where the router's address goes¶
The router needs an address inside the LAN so the PCs can talk to it. Where do you put it? On the bridge, not on one port.
If you put 10.G.0.1/24 on ether2, only the room ether2 can reach the router. Put it on the corridor, and every room can. In the house picture, the reception desk belongs in the corridor, not inside one bedroom.
The address plan¶
Your group's LAN is 10.G.0.0/24, where G is your group number (1 to 8). A /24 has 254 usable addresses. You do not hand them all out automatically: you split them by job.
| Addresses | Use |
|---|---|
10.G.0.1 |
The router: gateway and DNS server of the LAN |
10.G.0.2 – 10.G.0.99 |
Reserved for fixed addresses (servers, printers) |
10.G.0.100 – 10.G.0.199 |
The DHCP pool: 100 addresses for the PCs |
10.G.0.200 – 10.G.0.254 |
Free |
A DHCP pool is the range of addresses the DHCP server is allowed to hand out automatically.
Why not give the whole /24 to the pool? Because the router's own address and the fixed ones would collide with a lease: two devices with the same address, and neither works well.
Careful: the pool is not the network
The network is 10.G.0.0/24, with 254 usable addresses. The pool is only the part handed out automatically. From .100 to .199 there are 100 addresses, because both ends count.
Building it in WinBox¶
Your group does this on the real router, taking turns. These are the steps of Part A of the Exercise sheet (Practical 3.4), with G = 3 as the example.
- Reset. System → Reset Configuration, tick No Default Configuration. WinBox loses the router (it has no address any more). Reconnect from Neighbors by clicking the MAC address, user
admin. - Name and password. System → Identity:
G3-router. System → Password. - Bridge. Bridge → Bridge tab → +, name
bridge-lan. Then the Ports tab → + once per port,ether2toether5. - Address. IP → Addresses → +:
10.3.0.1/24, interfacebridge-lan. - DHCP server. IP → DHCP Server → DHCP Setup: interface
bridge-lan· network10.3.0.0/24· gateway10.3.0.1· addresses10.3.0.100-10.3.0.199· DNS10.3.0.1· lease time30m. - DNS. IP → DNS, tick Allow Remote Requests. Static → +: name
gw.tramuntana.internal, address10.3.0.1. - A fixed address for one PC. IP → DHCP Server → Leases → right-click a lease → Make Static.
Step 6 makes the router answer DNS questions from the LAN. Without Allow Remote Requests, it only resolves names for itself. The static entry is a name you invent for your own network: gw.tramuntana.internal now means "the router".
A static lease ties one MAC address to one address in the DHCP server.
Careful: a static lease is not a static IP
With a static lease the PC still asks by DHCP. The difference is on the server side: it always answers that MAC with the same address. A static IP, instead, is typed by hand on the PC and DHCP is not involved at all.
Checking from a PC¶
A configuration that nobody verified is not a configuration. Unplug your cable, plug it back in (so the PC asks for a new lease), and run:
ip -br address # enp3s0 UP 10.3.0.199/24 ...
ip route # default via 10.3.0.1 dev enp3s0 proto dhcp ...
ping -c 3 10.3.0.1
ping -c 3 10.3.0.198 # the PC of a classmate
dig +short gw.tramuntana.internal
What each line proves:
| Command | What you should see | What it proves |
|---|---|---|
ip -br address |
An address between .100 and .199 |
DHCP works. RouterOS hands the pool out from the top, so .199 first is normal |
ip route |
default via 10.3.0.1 |
The PC learned its default gateway from DHCP |
ping 10.3.0.1 |
Replies | PC ↔ router works |
ping 10.3.0.198 |
Replies | PC ↔ PC works, through the bridge |
dig +short ... |
10.3.0.1 |
The PC learned its DNS server from DHCP, and the router answers |
On the router you can look from the other side:
The first shows one lease per PC, status bound. The second is the bridge's MAC table: which MAC lives behind which port. It is the switch's table, inside the router.
Careful: DHCP does not give you internet
DHCP gives an address, mask, gateway and DNS server. That is all. Our gateway leads nowhere yet, so ping 1.1.1.1 fails, and it should. The way out to the Internet comes later in the unit, with NAT.
When it does not work¶
| Symptom | Most likely cause |
|---|---|
| One PC gets an address, the others do not | Their ports are not in the bridge: Bridge → Ports |
| No PC gets an address, the DHCP server shows in red | The server sits on ether2 instead of bridge-lan. A port inside a bridge cannot run a server |
dig times out |
Allow Remote Requests is not ticked |
| The PC keeps an old address | Unplug the cable for five seconds, or nmcli device reapply enp3s0 |
The same thing as text: the CLI¶
Everything you clicked in WinBox has a path in the CLI (command-line interface). IP → Addresses becomes /ip address. In any menu, four verbs do almost everything:
| Verb | Does |
|---|---|
print |
Shows what is there |
add |
Creates a new entry |
set |
Changes an entry |
remove |
Deletes an entry |
Press Tab to complete a word and ? to list what can come next.
The DHCP Setup wizard hid three separate things. Typed by hand they are:
/ip pool add name=pool-lan ranges=10.3.0.100-10.3.0.199
/ip dhcp-server add name=dhcp-lan interface=bridge-lan address-pool=pool-lan disabled=no
/ip dhcp-server network add address=10.3.0.0/24 gateway=10.3.0.1 dns-server=10.3.0.1
Pool = which addresses. Server = on which interface. Network = what else to tell the client.
The whole LAN, in nine lines (this is Part B of the Exercise sheet, in the virtual lab, where the router has only ether2 and ether3 for PCs):
/interface bridge add name=bridge-lan
/interface bridge port add bridge=bridge-lan interface=ether2
/interface bridge port add bridge=bridge-lan interface=ether3
/ip address add address=10.3.0.1/24 interface=bridge-lan
/ip pool add name=pool-lan ranges=10.3.0.100-10.3.0.199
/ip dhcp-server add name=dhcp-lan interface=bridge-lan address-pool=pool-lan disabled=no
/ip dhcp-server network add address=10.3.0.0/24 gateway=10.3.0.1 dns-server=10.3.0.1
/ip dns set allow-remote-requests=yes
/ip dns static add name=gw.tramuntana.internal address=10.3.0.1
In the lab, never touch ether1
In the virtual lab, ether1 is the management port: it is the cable your ssh session travels through. Bridge it and you cut yourself off. Likewise, on the lab PCs eth0 is the management cable: work on eth1 only.
Watching DORA happen¶
On a lab PC, ask for a lease with dhclient -v:
It prints the four DHCP messages live: DHCPDISCOVER, DHCPOFFER of 10.3.0.199 from 10.3.0.1, DHCPREQUEST, DHCPACK, and then bound to 10.3.0.199. That is the DORA exchange from DHCP and DNS, happening in front of you. The Offer and the Ack come from the router.
Saving your work: /export¶
/exportprints the router's whole configuration as the list of commands that would rebuild it.
The first form prints it on screen. The second saves it on the router as g3-0903.rsc (find it in Files in WinBox and drag it to your PC). Read it: every line is one of the steps you did.
A text file can be read, compared and pasted into a report. That is why professionals prefer it to screenshots.
Careful: /export is not a backup
/export is a readable text. /system backup save name=g3-0903 makes a binary backup that only a router can read. Keep both: the next sessions start from this configuration.
Key takeaways¶
- A LAN needs four pieces: a bridge, an address, a DHCP server and DNS, in that order.
- On a blank MikroTik every port is a separate network; a bridge is the software switch that joins them.
- The router's LAN address (
10.G.0.1/24) goes on the bridge, so every port can reach it. - A DHCP server has a pool (which addresses), an interface (where) and a network (gateway and DNS to tell the client). A static lease always gives one MAC the same address.
- DHCP gives address, mask, gateway and DNS, not internet.
/exportturns the configuration into readable commands;/system backup savemakes the binary backup.
Quick check¶
1. In RouterOS, what is a bridge?
- A software switch that joins several ports into one LAN
- A cable that connects two routers together
- The range of addresses the DHCP server hands out
- The port of the router that goes to the Internet
A bridge is a switch made of software inside the router. It joins ports into one LAN and learns which MAC address is behind each port, like a real switch.
2. On which interface should the router's LAN address 10.G.0.1/24 go?
- On the bridge
- On ether1
- On ether2
- On every port, one copy each
The address goes on the bridge, the corridor that joins all the ports. On a single port, only the PCs behind that port could reach the router.
3. A PC is plugged into the group router, the link light is on, and it gets no address. What is most likely wrong?
- The DHCP server is not answering on that port
- The DNS static name is missing
- The cable is Cat5e instead of Cat6
- The PC's MAC address is wrong
The light means layer 1 works. No address means nobody answered the DHCP request: the port is not in the bridge, or the DHCP server is on the wrong interface.
4. How many addresses does the pool 10.3.0.100-10.3.0.199 contain?
- 100
- 99
- 199
- 254
From .100 to .199 both ends are included, so it is 199 − 100 + 1 = 100 addresses. The 254 is the size of the whole /24 network, not of the pool.
5. What does a DHCP server give a PC?
- Address and mask, default gateway and DNS server
- Only an IP address
- An IP address and a new MAC address
- An IP address and access to the Internet
DHCP hands out the address with its mask, the default gateway and the DNS server, for a lease time. Internet access needs a way out from the router, which DHCP does not provide.
6. Your PC got 10.3.0.199 and pings the router, but dig gw.tramuntana.internal times out. What do you fix on the router?
- Tick Allow Remote Requests in IP → DNS
- Add ether2 to the bridge
- Make the lease static
- Change the pool to start at .1
The PC reaches the router, so the bridge and DHCP work. A DNS timeout means the router refuses questions from the LAN: Allow Remote Requests turns it into the LAN's DNS server.
7. Select the two statements about saving a RouterOS configuration that are true.
- /export prints the configuration as commands you can read and paste into a report
- /system backup save makes a binary file that only a router can read
- /export and /system backup save produce exactly the same file
- /export only works from WinBox, not from the CLI
/export gives readable text: every line is a step of the setup. /system backup save makes a binary backup. They are different, so you keep both.
Next: split the LAN so the dev and design departments get their own networks on the same router — VLANs.