Why log a hotspot’s traffic?
Because behind the NAT every guest shares the same public address. If one day an authority sends a request about a certain address at a certain time, without a log there’s no way to trace it back to the device. The log is what links time, private address, MAC, and destination.
⚠️ Warning: the log contains personal data. Which data to keep, for how long, and how to protect it depends on the operator’s legal obligations: decide that with a consultant, not with a howto.
In the example the guest network is 172.16.0.0/22 on the bridge-hs bridge, as in the howto on how to create a WiFi hotspot with MikroTik. Replace the network and the names with your own.

Step 1: does the router have the right time?
A log with the wrong time is worth as much as an empty one: the request says “at 21:14,” and you have to find exactly that line. So, first of all, the clock:
/system ntp client set enabled=yes
/system ntp client servers add address=pool.ntp.org
/system clock set time-zone-name=Europe/Rome
Check that the NTP client is synchronized:
/system ntp client print
Step 2: how do I log the connections?
With a rule in the forward chain that logs only the first packet of each connection, not every packet: otherwise the log blows up.
/ip firewall filter add chain=forward src-address=172.16.0.0/22 connection-state=new \
action=log log-prefix="HS" comment="Hotspot connection log" place-before=0
action=log writes the line and lets the packet move on to the following rules: it blocks nothing. place-before=0 puts it at the top, before the rules that accept forwarded traffic.
A real line, taken from my lab:
firewall,info HS forward: in:bridge-lan out:ether5, connection-state:new src-mac 50:00:00:1E:00:00, proto TCP (SYN), 192.168.88.199:44928->104.20.21.8:80, len 60
Everything is there: interfaces, the client’s MAC, protocol, source address and port, destination address and port. The date and time are added by the logging system.
Step 3: where do I store the log?
Not in the router’s memory: it’s wiped on every reboot and holds only a few thousand lines. The right place is an external syslog server. In the example it’s 10.6.0.50, a server on my lab network: use the address of your own syslog server.
/system logging action add name=sysloghs target=remote remote=10.6.0.50 remote-port=514
/system logging add topics=firewall action=sysloghs
/system logging add topics=hotspot,info action=sysloghs
⚠️ Warning: in RouterOS 7 the action name can contain only letters and numbers. With name=syslog-hs the router answers action name can contain only letters and numbers.
The second rule also sends the hotspot events to syslog, that is user logins and logouts, which you need to tie a private address to a user at a given moment. On the server, in the lab, lines like these came in:
hotspot,account,info,debug test (192.168.88.199): logged in
firewall,info HS forward: in:bridge-lan out:ether5, connection-state:new src-mac 50:00:00:1E:00:00, proto TCP (SYN), 192.168.88.199:44928->104.20.21.8:80, len 60
On the syslog server keep a rotated, protected archive. Topics, actions, and examples are all in the MikroTik manual: Log.
Step 4: how do I check that it works?
Connect a device to the hotspot, log in, and open a site. On the router:
/log print where message~"HS "
/system logging print where action=sysloghs
The first command shows you the firewall lines, the second that the rules toward syslog are there. Then check that the same lines actually reach the server: a syslog that’s configured but unreachable won’t warn you about anything.
Step 5: what about Traffic Flow?
The firewall log writes one line of text per new connection. Traffic Flow does a different job: the router summarizes the traffic into flows (who talked to whom, with which protocol and which ports, how many packets and how many bytes) and sends them to a server, the collector, in a standard format: NetFlow v9 or IPFIX. They’re UDP packets, compact, meant to be stored and queried, not read by eye.
There’s one more reason to choose it on a hotspot. In IPFIX, out of the box, RouterOS also exports the address and port after the NAT (nat-src-address and nat-src-port). The authority’s request starts right there: “public address X, port Y, at 21:14.” With IPFIX every flow holds the private address, the device MAC, and the public address and port together: the path back to the device is already traced, without cross-referencing tables by hand.
On the router
/ip traffic-flow set enabled=yes interfaces=bridge-hs
/ip traffic-flow target add dst-address=10.6.0.50 port=2055 version=ipfix
interfaces=bridge-hs limits the collection to the guests’ traffic; 10.6.0.50 is the collector, use your own address. The router sends the flows once they close: a connection idle for 15 seconds (inactive-flow-timeout) or open for more than 30 minutes (active-flow-timeout) leaves for the collector. You can check the exported fields like this:
/ip traffic-flow ipfix print
On the server: nfdump
As the collector I use nfdump, open source and in the official Debian and Ubuntu packages (github.com/phaag/nfdump). Two programs: nfcapd receives the flows and saves them to disk, nfdump queries them. On a Debian 12:
apt install nfdump
The package starts nfcapd on its own, listening on UDP port 2055, with the data in /var/cache/nfdump: a new file every 5 minutes. There’s nothing else to configure. If the server has a firewall, open UDP port 2055 only for the router’s address.
How long to keep them is up to the operator, not nfdump (see the warning at the top). Once you’ve decided, say 180 days, the cleanup is done by nfexpire, to put in a daily cron:
nfexpire -e /var/cache/nfdump -t 180d
What the collector receives
In my lab I connected a Linux PC behind a CHR doing the NAT and opened two sites. The PC has the private address 192.168.72.254, the router goes out to “the internet” with 192.168.250.72. After a few seconds the collector had these flows:
nfdump -R /var/cache/nfdump -o 'fmt:%ts %pr %sap -> %dap NAT %nsap %ismc %byt' 'proto tcp'
Date first seen Proto Src IP Addr:Port Dst IP Addr:Port X-Src IP Addr:Port In src MAC Addr Bytes
2026-10-09 13:37:22.592 TCP 192.168.72.254:50820 -> 104.20.23.154:80 NAT 192.168.250.72:50820 50:00:00:1f:00:00 447
2026-10-09 13:37:22.632 TCP 104.20.23.154:80 -> 192.168.250.72:50820 NAT 104.20.23.154:80 50:00:00:1a:00:01 1204
2026-10-09 13:37:22.832 TCP 192.168.72.254:37542 -> 130.255.112.53:443 NAT 192.168.250.72:37542 50:00:00:1f:00:00 2101
2026-10-09 13:37:22.872 TCP 130.255.112.53:443 -> 192.168.250.72:37542 NAT 130.255.112.53:443 50:00:00:1a:00:01 75334
Each connection produces two flows, one per direction. Read the third line, the outbound one toward 130.255.112.53:443:
- Src IP Addr:Port: the device, with its private address and port,
192.168.72.254:37542; - X-Src IP Addr:Port: how the internet saw it after the NAT,
192.168.250.72:37542. On a real hotspot this is the public address; - In src MAC Addr: the device’s MAC,
50:00:00:1f:00:00; - Bytes: how much it sent. The site’s reply, on the fourth line, weighs 75 KB.
The search that really matters
The request comes in: “public address 192.168.250.72, port 37542.” A single command line:
TZ=Europe/Rome nfdump -R /var/cache/nfdump -q -o 'fmt:%ts %pr %sap -> %dap %nsap %ismc' \
'proto tcp and src xip 192.168.250.72 and src xport 37542'
2026-10-09 15:37:22.832 TCP 192.168.72.254:37542 -> 130.255.112.53:443 192.168.250.72:37542 50:00:00:1f:00:00
There’s the time, the private address, and the device’s MAC. With that hour’s hotspot login (Step 6) you also have the user’s name. On a large archive add -t with the time range of the request, so nfdump reads only the files from those minutes.
⚠️ Mind the time zone. The router sends the times in absolute form, nfdump shows them in the server’s time zone. My lab server is in UTC: without TZ=Europe/Rome the same connection shows up at 13:37 instead of 15:37. With a request “at 21:14,” a two-hour difference makes you find the wrong device.
nfdump isn’t the only one: GoFlow2 and pmacct are open source collectors too that read IPFIX. I tested it with nfdump. Details and the fields on the MikroTik side are in the MikroTik manual: Traffic Flow.
Step 6: how do I tie the IP to a user?
The firewall log holds the private address and the MAC; the user’s name is in the hotspot log, on the login line. Cross-referencing them by hand is tedious: there’s a dedicated howto on writing the username in every log line.
Step 7: what do I check before putting it into production?
A router that keeps the guests’ browsing data has to be the first one protected. If you haven’t done it yet, follow the Basic hardening of a MikroTik router.
Tested in the lab on PNETLab with a CHR running RouterOS 7.24.5 (stable), a hotspot, and a Linux client: log rule, sending to a remote syslog server (firewall lines and hotspot logins received), NTP client. Traffic Flow in IPFIX tested on a second CHR 7.24.5 doing the NAT, toward nfdump 1.7.1 on Debian 12: flows received with the address and port after the NAT and the client MAC, search by public address and port.
Frequently asked questions
How do you log the connections of a MikroTik hotspot’s users?
With a firewall rule in the forward chain, connection-state=new and action=log, limited to the hotspot network: it logs the first packet of every connection with the client’s addresses, ports, and MAC.
Why should the log be sent to a syslog server?
Because the MikroTik’s in-memory log is limited and is lost on reboot. An external syslog server keeps the lines over time and lets you archive and search them.
Why does the router reject the logging action’s name?
In RouterOS 7 the name of an action in /system logging action can contain only letters and numbers: syslog-hs is rejected, sysloghs is fine.
What’s the difference between the firewall log and Traffic Flow?
The firewall log writes one line of text per new connection; Traffic Flow exports the flows in NetFlow or IPFIX format, with bytes, duration and, in IPFIX, also the address and port after the NAT, toward a dedicated collector.
What server do I use to receive a MikroTik’s Traffic Flow?
A NetFlow/IPFIX collector. One open source option is nfdump: on Debian you install it with apt install nfdump and it already receives on UDP port 2055. With nfdump you can search a flow even by the address and port after the NAT (src xip, src xport).
Does logging slow the router down?
Logging only the new connections, and not every packet, costs little. With many users it’s still better to send the log to an external server and not keep it in memory.
This howto brings up to RouterOS 7 a 2016 article from my old blog wirelessguru.it, now offline.



