Lab 09-07 · Logs, supout.rif and documenting the router¶
MTCNA
Module 9 · RouterOS tools. Official course slides 373–378: how to contact MikroTik support, the supout.rif support output file and autosupout.rif, System → Logs (in memory by default, to disk, or to a remote syslog server), debug logging rules, the resources to check before asking (documentation, forum, MUM), and the advice to add meaningful comments and a network diagram. The slides have no LAB block for this part; this lab turns it into one.
Imagine you go to the doctor and say "I felt bad at some point, I don't remember when, and I don't know what I ate". The doctor can do very little. Now imagine you bring a diary: "Tuesday 18:00, fever 38.5; ate seafood at 14:00". Same doctor, much better diagnosis.
Routers are the same. When something breaks at three in the morning, the person fixing it (you, a colleague, MikroTik support) needs a diary of what happened, a full medical report of the router, and a router whose configuration explains itself. By default a RouterOS router keeps its diary only in RAM, and forgets everything when it reboots. In this lab you fix that.
What you will learn
- Read System → Logs and explain topics and actions
- Keep logs on disk so they survive a reboot
- Send logs to a remote syslog server
- Turn on debug logging for one topic, and switch it off again
- Create a supout.rif file for MikroTik support
- Document the router with comments and a system note
- Avoid the trap of logs that vanish on reboot, exactly when you need them
The router's diary: topics and actions¶
A log is the list of events the router writes down: logins, DHCP leases, interfaces going up or down, errors. Each message carries one or more topics (
system,dhcp,info,error...).
The analogy for this lab: the log is the router's diary. Logging rules decide which pages of the diary (topics) are written where (actions):
| Action | Where the diary is written | Survives a reboot? |
|---|---|---|
| memory | RAM, last 1000 lines (the default) | No |
| disk | Files on the router's storage (log.0.txt, log.1.txt...) |
Yes |
| remote | Sent over the network to a syslog server (UDP 514) | Yes, on another machine |
| echo | Printed in the open terminal | No |
flowchart LR
EV["<b>Event</b><br>topics: dhcp, info"]
subgraph RULES["Logging rules (System → Logging)"]
R1["info → memory"]
R2["info → disk"]
R3["info → remote"]
end
MEM["RAM<br>lost on reboot"]
DISK["log.0.txt<br>on the router"]
SYS["<b>logserver</b><br>192.168.88.10<br>/var/log/remote.log"]
EV --> R1 & R2 & R3
R1 --> MEM
R2 --> DISK
R3 -->|"UDP 514"| SYS
Syslog is the standard way for devices to send their log lines to a central server over the network (UDP port 514).
Why a remote server, if the disk already survives reboots? Because if the router dies, or someone breaks in and deletes its files, the copy on another machine is still there.
supout.rif: the full medical report
The log is a diary. supout.rif (support output) is a complete check-up: configuration, logs, hardware state, processes, everything in one file. Only MikroTik can open it fully; you can upload it in your account on mikrotik.com to see what it contains before sending it. If the router crashes, the watchdog can create an autosupout.rif by itself.
The scenario¶
flowchart LR
INET["<b>internet</b><br>198.51.100.10"]
CAP["<b>class-ap</b><br>10.0.0.1 · 198.51.100.1"]
subgraph R1["r1 · working, but undocumented"]
WAN["ether2 (WAN)<br>10.0.0.x by DHCP"]
BR["<b>bridge1</b><br>192.168.88.1/24"]
end
PC1["<b>pc1</b><br>your laptop<br>DHCP 192.168.88.x"]
LOG["<b>logserver</b><br>syslog server<br>192.168.88.10"]
INET ---|"198.51.100.0/24"| CAP
CAP ---|"10.0.0.0/24"| WAN
WAN --- BR
BR ---|"ether3"| PC1
BR ---|"ether4"| LOG
| Node | Role | Address |
|---|---|---|
internet |
"The Internet" | 198.51.100.10 |
class-ap |
Class gateway: DHCP, DNS, NAT | 10.0.0.1/24 |
r1 |
Your router: works, but no comments, logs only in RAM | WAN by DHCP, LAN 192.168.88.1/24 |
pc1 |
Your laptop | DHCP from r1 |
logserver |
Syslog server: writes every line it receives on UDP 514 to /var/log/remote.log |
192.168.88.10 |
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.
Start the lab¶
Download the lab files and unzip them: 09-07-support-logging.zip. Open a terminal inside the 09-07-support-logging folder.
Give RouterOS about two minutes to boot. You need three terminals:
ssh admin@clab-mtcna-09-07-r1 # password: admin
docker exec -it clab-mtcna-09-07-pc1 bash
docker exec -it clab-mtcna-09-07-logserver tail -f /var/log/remote.log
The third one stays open and shows, live, every line the syslog server receives. For now it is empty.
At any moment, CLAB_EXEC="docker exec" ./check.sh tells you what is already solved.
Step 1 · Read the diary and its rules¶
WinBox: Log (left menu), and System → Logging for the rules.
Expected: the log shows your SSH login (system,info,account user admin logged in...). The rules are the
four defaults: info, error and warning go to memory, critical to echo. The actions already
include disk and remote, but no rule uses them, and remote points at 0.0.0.0.
Check yourself
- If r1 rebooted right now, which of these log lines would you still be able to read? Why?
Done when you can name the four default rules.
Step 2 · Write the diary to disk¶
First tune the existing disk action: file name log, 1000 lines per file, keep 3 files. Then add rules that
send info, warning and error to it.
WinBox: System → Logging → Actions, double-click disk, set the values. Then Rules → +: Topics
info, Action disk. Repeat for warning and error.
/system logging action set [find name=disk] disk-file-name=log disk-lines-per-file=1000 disk-file-count=3
/system logging add topics=info action=disk
/system logging add topics=warning action=disk
/system logging add topics=error action=disk
/file print where name~"log"
Expected: a file log.0.txt appears in Files. When it reaches 1000 lines it becomes log.1.txt and a new
log.0.txt starts; with 3 files the oldest one is deleted, so the disk never fills up.
One topic per rule
topics=info,warning does not mean "info or warning". It means messages that have both topics at
once, which is almost none. Write one rule per topic.
Done when log.0.txt exists.
Step 3 · Send the diary to the syslog server¶
WinBox: System → Logging → Actions, double-click remote: Remote Address 192.168.88.10, Remote Port
514. Then add three rules with Action remote.
/system logging action set [find name=remote] remote=192.168.88.10 remote-port=514
/system logging add topics=info action=remote
/system logging add topics=warning action=remote
/system logging add topics=error action=remote
:log warning "Hello syslog, this is r1"
:log warning "..." writes your own line into the log, a handy way to test.
Expected in the logserver terminal:
Every new login or DHCP lease now appears there too.
Check yourself
- The syslog line starts with
192.168.88.1. Which address would it show if the server were on the Internet side? (Hint: which interface does the packet leave from?)
Done when your test line appears on the logserver.
Step 4 · Turn on debug logging, then turn it off¶
Normal logs say what happened. Debug logs say how, packet by packet. The course: to see detailed (debug) logs, create a new rule and add the debug topic.
WinBox: System → Logging → Rules → +: Topics dhcp and debug, Action memory, Comment
TEMPORARY: DHCP debugging.
Here two topics are exactly what you want: messages that are dhcp AND debug. Now make pc1 ask for an address again. On pc1:
On r1:
Expected: many lines like dhcp,debug,packet Msg-Type = discover, Msg-Type = ack: the whole DHCP
conversation, field by field.
Now remove the rule. Debug logging is noisy, fills the memory, and on a busy router costs CPU:
Check yourself
- Write the four DHCP message types you saw, in order. (You met them in Module 2.)
- Why does the comment of the rule start with
TEMPORARY?
Done when you have seen the DHCP debug lines and the debug rule is gone.
Step 5 · Create the supout.rif¶
When you open a ticket with MikroTik support, they ask for this file first.
WinBox: Make Supout.rif (left menu), or:
Expected: created: 100% and a file supout.rif of about 500 KiB in Files. You would download it (WinBox
Files, drag it to your desktop) and attach it to the ticket.
Before you write to support
The course lists what to check first: the documentation (help.mikrotik.com, which replaced wiki.mikrotik.com), the user forum (forum.mikrotik.com) and the MUM talks (mum.mikrotik.com, videos of MikroTik User Meetings). Most questions are already answered there. When you do contact support, send the supout.rif, a clear description, and your network diagram.
Done when supout.rif is in Files.
Step 6 · Make the router explain itself¶
Open /export and read it as if you were a stranger. add address=192.168.88.1/24 interface=bridge1: what is
it for? Which port goes where? Comments answer that inside the configuration, and they travel with every
export and backup.
WinBox: almost every window has a Comment button (the yellow note icon). In the CLI, add comment=:
/ip address set [find address="192.168.88.1/24"] comment="LAN gateway"
/ip dhcp-client set [find interface=ether2] comment="WAN: address from class-ap"
/ip firewall nat set [find action=masquerade] comment="LAN to Internet: hide the LAN behind the WAN address"
/interface set ether2 comment="WAN to class-ap"
/interface bridge set bridge1 comment="LAN: ether3 pc1, ether4 logserver"
Comments are shown as ;;; lines in every print:
Finally, a system note: a short text the router shows to everybody who logs in. Perfect for "who looks after this router and what is special about it". WinBox: System → Note.
/system note set note="r1 - MTCNA lab 09-07. WAN ether2 (DHCP from class-ap 10.0.0.1), LAN bridge1 192.168.88.0/24. Logs: disk log.N.txt + syslog 192.168.88.10. Admin: you@mtcna.lab" show-at-login=yes show-at-cli-login=yes
show-at-login shows it when someone logs in with WinBox or WebFig, show-at-cli-login when someone opens the
terminal (SSH, console). Next time anyone logs in, the router introduces itself.
Check yourself
- Write one more comment you would add to this router, and on which item.
- Why is a comment inside the configuration better than a note in a notebook in the drawer?
Done when the key items have comments and the note shows at login. Run CLAB_EXEC="docker exec" ./check.sh:
it must end with RESULT: lab solved.
If something goes wrong¶
| Symptom | Likely cause | Fix |
|---|---|---|
action already exists with such a name |
You tried to add an action called disk or remote |
They exist by default: use set [find name=disk] ... |
No log.0.txt |
No rule uses the disk action yet | /system logging add topics=info action=disk |
| Nothing on the logserver | Remote action still 0.0.0.0, or no rule with action=remote |
Step 3, both parts |
A rule shows flag I (invalid) |
Its action was deleted | /system logging remove [find where invalid] |
topics=info,warning logs almost nothing |
Several topics in one rule mean AND | One rule per topic |
check.sh complains about debug |
The temporary debug rule is still there | /system logging remove [find comment~"TEMPORARY"] |
Clean up¶
Key takeaways¶
- By default RouterOS logs to memory only: the diary is lost on reboot.
- Logging rules send topics to actions: memory, disk, remote (syslog, UDP 514), echo; one topic per rule, several topics mean AND.
- Debug logging (e.g.
topics=dhcp,debug) shows the details of one feature; switch it off when done. - supout.rif (
/system sup-output) is the full report MikroTik support asks for; the watchdog can create autosupout.rif after a crash. - Comments and a system note make the configuration explain itself to the next person.
Quick check¶
1. Where does RouterOS keep its log with the default settings?
- In memory, so it is lost when the router reboots
- On disk, in log.0.txt
- On a syslog server
- Nowhere, logging is off by default
The default rules send info, warning and error to the memory action (the last 1000 lines in RAM).
A reboot erases them.
2. Which port and protocol does remote syslog use by default?
- UDP 514
- TCP 22
- UDP 161
- TCP 25
Syslog uses UDP 514. TCP 22 is SSH, UDP 161 is SNMP and TCP 25 is SMTP.
3. What does a logging rule with topics=dhcp,debug log?
- Messages that have both the dhcp and the debug topic
- Every DHCP message plus every debug message
- Only DHCP errors
- Nothing, because two topics are not allowed
Several topics in one rule work as AND. That is exactly what you want for debugging one feature, and exactly what you do not want when you mean "info or warning".
4. What is supout.rif?
- A file with the router's full state, made for MikroTik support
- A backup you can restore on another router
- The router's licence key
- A list of the router's users and passwords
supout.rif (support output) collects configuration, logs and system state for MikroTik's engineers. To restore a router you use a backup or an export, not a supout.
5. Why send logs to a remote server if they are already on disk?
- If the router dies or is tampered with, the copy on another machine survives
- Remote logs are more detailed than disk logs
- The disk action only works for errors
- RouterOS deletes disk logs every hour
The disk survives a reboot, but not a broken router or an intruder who deletes files. A syslog server keeps an independent copy, and can collect the logs of many devices in one place.
6. A colleague will look after your school's router while you are on holiday. Pick the two things that help her most.
- Comments on the important rules and addresses
- A system note with who to call and what is special
- A debug logging rule for every topic
- Disabling the log so it does not fill up
Comments explain each item where it is, and a system note greets her at login with the essentials. Debug on everything would bury her in noise.
This was the last lab of the MTCNA course. You can now build, secure, shape, tunnel, monitor and document a MikroTik network: time to book the exam.