HotSpot - Captive portal
CLI reference:/ip/hotspot/ip/hotspot/active/ip/hotspot/profile/ip/hotspot/user/profile/ip/hotspot/user/ip/hotspot/host/ip/hotspot/walled-garden/ip/hotspot/walled-garden/ip/ip/hotspot/ip-binding/ip/hotspot/cookie
A HotSpot asks the users of a network to log in before they get network access. A device that connects to the HotSpot network gets an IP address and can resolve DNS names, but every web page that it opens over HTTP is replaced by the login page of the router, and all other traffic is rejected. After the user logs in, the device has network access until the user logs out or a limit is reached.
The HotSpot can:
- authenticate users from a list on the router or on a RADIUS server;
- limit each user by time, by traffic amount, and by data rate;
- log in known devices without a login page, by their MAC address;
- give time-limited trial access without an account;
- let selected sites, services, and devices through without login (walled garden and IP bindings);
- show your own login page, see HotSpot customisation.
Before you start
- HotSpot works with IPv4 only.
- Device-mode can block HotSpot. Check that
hotspotisyesin/system/device-mode/print. - One HotSpot server runs on one interface. To serve several ports, put them in a bridge and run the HotSpot on the bridge interface, not on a bridge port. Do not put the interface that leads to the Internet into this bridge.
- A user rate limit creates a simple queue. Simple queues do not limit FastTracked connections, see Simple queue.
- If you set up the HotSpot on the interface through which you manage the router, you lose access until you log in on the login page. Manage the router through another interface, or add an IP binding for your computer first, as described in the IP bindings section of this page.
Set up a HotSpot
The /ip/hotspot/setup command asks a few questions and creates the HotSpot server together with everything that it needs.
| Question | What to answer |
|---|---|
hotspot interface | The interface with the clients. On a router with the default configuration this is bridge. |
local address of network | The address of the router on this interface. The address that the interface already has is offered. |
masquerade network | yes adds a source NAT rule for the HotSpot network. |
address pool of network | The addresses for the clients. If the interface has a DHCP server, its pool is offered. |
select certificate | Answer none, unless you use the https login method. |
ip address of smtp server | Keep 0.0.0.0. |
dns servers | The DNS servers that the router itself uses. The answer is written to /ip/dns, so do not enter the address of the router here. |
dns name | A name for the login page, for example hotspot.lan. The router resolves this name to its own address for the clients. Leave it empty to use the IP address. |
name of local hotspot user, password for the user | The first user account. These two questions are asked only when the router has no HotSpot user yet. |
On a router with the default configuration, with bridge as the HotSpot interface and hotspot.lan as the DNS name, the setup creates this configuration:
/ip/hotspot/profile
add dns-name=.lan hotspot-address=192.168.88.1 name=hsprof1
/ip/hotspot
add address-pool=default-dhcp disabled=no interface= \
name=hotspot1 profile=hsprof1
/ip/hotspot/user
add name=user1
/ip/firewall/nat
add action=masquerade chain=srcnat \
comment="masquerade hotspot network" src-address=192.168.88.0/24
The address-pool of the server does more than name the client addresses. With a pool, the HotSpot also serves a device whose own IP settings do not fit the network, for example a laptop with a static address from another network. The router answers for the gateway that the device expects and translates the address of the device to a free address of the pool; /ip/hotspot/host/print shows that address as to-address. With address-pool=none, the addresses are not translated and such a device gets no answer.
If the interface has no DHCP server, the setup also creates an IP pool and a DHCP server for it. The existing firewall rules of the router are not changed; the HotSpot adds its own dynamic rules, which are listed at the end of this page.
Check that the server runs:
/ip/hotspot/print
Columns: NAME, INTERFACE, ADDRESS-POOL, PROFILE, IDLE-TIMEOUT
# NAME INTERFACE ADDRESS-POOL PROFILE IDLE-TIMEOUT
0 hotspot1 default-dhcp hsprof1 5m
Connect a device to the HotSpot network and open an HTTP page, for example https://example.com. The login page of the router opens instead. The device is now in the host list:
/ip/hotspot/host/print
Flags: H - DHCP
Columns: MAC-ADDRESS, ADDRESS, TO-ADDRESS, SERVER, IDLE-TIMEOUT
# MAC-ADDRESS ADDRESS TO-ADDRESS SERVER IDLE-TIMEOUT
0 H 52:54:09:80:02:01 192.168.88.254 192.168.88.254 hotspot1 5m
1 H 52:54:09:81:02:01 192.168.88.253 192.168.88.253 hotspot1 5m
Log in with the user that you created. The host gets the A (authorized) flag, and the session is in the active list:
/ip/hotspot/active/print
Columns: USER, ADDRESS, UPTIME
# USER ADDRESS UPTIME
0 user1 192.168.88.254 2s
To log a user out, remove the session from /ip/hotspot/active. The user can also open the status page, https://hotspot.lan/status, and log out there.
Add users and limits
Users are in /ip/hotspot/user. A user profile in /ip/hotspot/user/profile holds the settings that several users share.
Add a user:
/ip/hotspot/user/add name=anna password=ChangeMe-1
Limit the data rate and the session time
Create a profile for guests and a user with this profile:
/ip/hotspot/user/profile/add name=guest rate-limit=512k/2M \
session-timeout=1h shared-users=1 address-list=-guests
/ip/hotspot/user/add name=guest1 password=ChangeMe-2 profile=guest
rate-limitis the upload/download limit of each user of the profile. The first value limits what the user sends, the second what the user receives.session-timeoutlogs the user out after this time.shared-usersis the number of devices that can be logged in with the same user name at the same time. A login from one more device fails with the message "no more sessions are allowed for user".address-listadds the address of each logged-in user to a firewall address list. Use the list in your own firewall, mangle, or queue rules.
While guest1 is logged in, the router has a dynamic simple queue and an address list entry for the user. Both are removed when the user logs out:
/queue/simple/print where dynamic
/ip/firewall/address-list/print where list=-guests
Flags: D - DYNAMIC
0 D name="<hotspot-guest1>" target=192.168.88.253/32 parent=none
packet-marks="" priority=8/8 queue=default-small/default-small
limit-at=512k/2M max-limit=512k/2M burst-limit=0/0 burst-threshold=0/0
burst-time=0s/0s bucket-size=0.1/0.1
Flags: D - DYNAMIC
Columns: LIST, ADDRESS, CREATION-TIME
# LIST ADDRESS CREATION-TIME
0 D -guests 192.168.88.253 2026-11-13 20:45:06
Limit the total time and traffic of a user
session-timeout in the profile limits one session, and the user can log in again. The limits of the user itself count over all sessions:
/ip/hotspot/user/add name=daypass password=ChangeMe-3 limit-uptime=1d \
limit-bytes-total=2G
When a limit is reached, the user is logged out. A new login fails with the message "user daypass has reached uptime limit" or "user daypass has reached traffic limit". The counters of the user are in /ip/hotspot/user/print detail. To let the user in again, reset them:
/ip/hotspot/user/reset-counters daypass
Run a script at login and logout
The on-login and on-logout scripts of a user profile run for every user of the profile. This example writes a line to the log:
/ip/hotspot/user/profile/set guest \
on-login=":log info \"HotSpot login: \$user \$address\"" \
on-logout=":log info \"HotSpot logout: \$user \$cause\""
/log/print where message~"^HotSpot log"
2026-11-13 20:45:47 ,info HotSpot login: guest1 192.168.88.253
2026-11-13 20:45:49 ,info HotSpot logout: guest1 admin reset
2026-11-13 20:51:40 ,info HotSpot login: guest1 192.168.88.254
2026-11-13 20:51:45 ,info HotSpot logout: guest1 request
2026-11-13 20:51:50 ,info HotSpot login: guest1 192.168.88.254
2026-11-13 20:51:54 ,info HotSpot logout: guest1 admin reset
The scripts can use these variables:
| Variable | Value |
|---|---|
$user, $username | The user name. |
$address | The IP address of the device. |
$"mac-address" | The MAC address of the device. |
$interface | The HotSpot interface. When the HotSpot runs on a bridge, this is the bridge, unless use-ip-firewall is enabled in the bridge settings; then it is the bridge port of the device. |
$cause | Only in on-logout: why the session ended, for example user request, session timeout, or traffic limit reached. |
$"uptime-secs" | Only in on-logout: the session time in seconds. |
$"bytes-in", $"bytes-out", $"bytes-total" | Only in on-logout: the bytes that the user sent and received. |
$"packets-in", $"packets-out", $"packets-total" | Only in on-logout: the packets that the user sent and received. |
Select the login methods
The login-by setting of the server profile in /ip/hotspot/profile selects how users can log in. Several methods can be enabled at the same time. The default is cookie,http-chap.
| Method | How the user logs in |
|---|---|
http-chap | With a user name and password on the login page. The page does not send the password itself: JavaScript on the page hashes it together with a challenge from the router. |
http-pap | With a user name and password on the login page. The password is sent as plain text. A login link or an external page that sends the password directly needs this method. |
https | As http-pap, but the login page is opened over HTTPS. Set ssl-certificate in the server profile; the certificate has to be valid for the dns-name of the profile. The server then has the S flag in /ip/hotspot/print. |
cookie | Automatically, with a browser cookie from an earlier login with a user name and password. The cookie is valid for http-cookie-lifetime. |
mac-cookie | Automatically, by the MAC address of a device that has logged in before, for example a phone. It is a separate method from cookie and does not use the browser. |
mac | Automatically, when a user with the MAC address of the device as its name exists. |
trial | With a link on the login page, without an account, for a limited time. |
Without http-pap, a login that sends the plain password fails with the message "web browser did not send challenge response (try again, enable JavaScript)".
Log in over HTTPS
With the https method, the login page opens over HTTPS, so the user name and the password are encrypted between the device and the router. The certificate of the login page has to meet two conditions:
- It is valid for the DNS name of the login page, which is the
dns-nameof the server profile. - The devices of the users trust the authority that issued it. A certificate from a public certificate authority meets this condition without any setup on the devices.
This example uses the IP Cloud name of the router as the name of the login page, and a Let's Encrypt certificate for that name. The IP Cloud DDNS service has to be enabled; see Let's Encrypt certificate. To use a name of your own domain instead, see Certificate for your own domain name.
Request the certificate:
/certificate
add-acme name=-cert domain-names=[/ip/cloud/get -name]
When the certificate is issued, it has the flags K and a in /certificate/print. Then set the name, the certificate and the login method in the server profile:
/ip/hotspot/profile
set hsprof1 dns-name=[/ip/cloud/get -name] \
ssl-certificate=-cert login-by=cookie,http-chap,https
The server now has the S flag:
[admin@MikroTik] > /ip/hotspot/print
Flags: S - HTTPS
Columns: NAME, INTERFACE, ADDRESS-POOL, PROFILE, IDLE-TIMEOUT
# NAME INTERFACE ADDRESS-POOL PROFILE IDLE-TIMEOUT
0 S hotspot1 default-dhcp hsprof1 5m
To check the result, connect a device to the HotSpot network and open an HTTP site. The device is redirected to https://<name>/login, where <name> is the IP Cloud name, and the login page opens without a certificate warning. Users do not type the name: they get to the login page through the redirect.
Remember devices with a MAC cookie
With mac-cookie, the user logs in once. After that, the router logs the device in by itself each time it comes back, until the cookie expires. This suits phones, which leave and join the network often.
/ip/hotspot/profile/set hsprof1 login-by=cookie,http-chap,mac-cookie
The user profile must have add-mac-cookie=yes, which is the default, and mac-cookie-timeout sets how long the cookie is valid. The cookies are in /ip/hotspot/cookie; a MAC cookie has the M flag:
/ip/hotspot/cookie/print
Flags: M - MAC-COOKIE
Columns: USER, MAC-ADDRESS, EXPIRES-IN
# USER MAC-ADDRESS EXPIRES-IN
0 M anna 52:54:09:80:02:01 2d23h59m58s
1 anna 52:54:09:80:02:01 2d23h59m58s
The cookie is removed when the user logs out on the status page. To make a device log in again, remove its cookie from this list.
Log in devices by MAC address
With mac, a device needs no login page at all. Add a user whose name is the MAC address of the device:
/ip/hotspot/profile/set hsprof1 login-by=cookie,http-chap,mac
/ip/hotspot/user/add name=00:00:5E:00:53:10 comment="reception TV"
A MAC address is easy to copy, so use this method only for devices that cannot show a login page.
Give trial access
With trial, the login page shows a "Free trial available" link. A user who follows it gets access for trial-uptime-limit and can use the trial again after trial-uptime-reset:
/ip/hotspot/profile/set hsprof1 login-by=cookie,http-chap,trial \
trial-uptime-limit=30m trial-uptime-reset=1d
The router creates a dynamic user named T- and the MAC address of the device for each trial, with the profile set in trial-user-profile. When the time is used up, a new trial login fails with the message "has reached uptime limit" until the reset time passes.
Let traffic through without login
Sites: walled garden
The walled garden lists the web sites that a device can open before login, for example your own site or a payment page. Rules in /ip/hotspot/walled-garden match HTTP and HTTPS requests by the host name of the site:
/ip/hotspot/walled-garden/add dst-host=example.com
/ip/hotspot/walled-garden/add dst-host=*.example.com
dst-host and path must match the whole value. Use * for any number of characters and ? for one character. A value that starts with : is a regular expression. It matches any part of the value, unless you anchor it with ^ at the start and $ at the end:
/ip/hotspot/walled-garden
add dst-host=":^example\\.com\$" action=allow
An HTTPS request is matched by its host name only. A rule that has path or method matches HTTP requests and no HTTPS requests.
Rules in /ip/hotspot/walled-garden/ip match packets by address, protocol, and port, so they also work for services other than the web:
/ip/hotspot/walled-garden/ip/add action=accept \
dst-host=pay.example.com
/ip/hotspot/walled-garden/ip/add action=accept protocol=tcp \
dst-port=443 dst-address=192.0.2.10
With dst-host, the router adds a dynamic rule with the address that the name resolves to.
The hits counter of a walled garden rule shows that it is used:
/ip/hotspot/walled-garden/print
Flags: X - DISABLED, D - DYNAMIC
Columns: DST-HOST, DST-PORT, ACTION, HITS
# DST-HOST DST-PORT ACTION HITS
0 D 443 allow 0
;;; place rules here
1 X allow 0
2 example.com allow 2
3 *.example.com allow 1
Devices: IP bindings
An IP binding in /ip/hotspot/ip-binding sets how the HotSpot treats one device, selected by its MAC address or IP address:
/ip/hotspot/ip-binding/add mac-address=00:00:5E:00:53:20 type=bypassed \
comment="office printer"
/ip/hotspot/ip-binding/add mac-address=00:00:5E:00:53:21 type=blocked
bypassed- the device has network access without login. It is in the host list with thePflag and is not in the active list.blocked- the device has no access at all, also not to the login page.regular- the device logs in as usual; withto-address, the HotSpot translates its address to this address.
To create a binding for a device that is already connected, use /ip/hotspot/host/make-binding on its entry in the host list.
Authenticate users with RADIUS
To keep the users on a RADIUS server, add the server for the hotspot service and enable RADIUS in the server profile:
/radius/add service= address=192.0.2.5 secret=ChangeMe-4
/ip/hotspot/profile/set hsprof1 use-radius=yes
Users that exist in /ip/hotspot/user still log in from the local list. A session that RADIUS authenticated has the R flag in /ip/hotspot/active. The reply of the server can set the limits of the session, for example Session-Timeout for the session time and Mikrotik-Rate-Limit for the rate limit. With radius-accounting=yes, which is the default, the router also sends accounting records for each session.
The attributes are listed on the RADIUS page. User Manager is a RADIUS server that runs on RouterOS.
How HotSpot behaves
Hosts and sessions
- Every device that sends traffic to the HotSpot interface gets an entry in
/ip/hotspot/host.found-byshows the packet that created the entry. - A logged-in user has an entry in
/ip/hotspot/active. The session ends when the user logs out, when a limit orsession-timeoutis reached, when the device does not answer for thekeepalive-timeoutof the user profile, or when you remove the entry. /ip/hotspot/active/loginlogs a connected device in from the console, without the login page.
What a device can do before login
- Its DNS requests are answered by the router.
- HTTP requests to a site in the walled garden pass. All other HTTP requests show the login page.
- Everything else is rejected, including ping to the router: TCP with a reset, other protocols with an ICMP "prohibited" message.
Routing marks
The login page is served by the router itself. A mangle rule that puts a routing mark on all traffic from the HotSpot network, for example for load balancing between two uplinks, also marks the requests to the login page, and the page no longer opens. Exclude the traffic to the router from such a rule with dst-address-type=!local.
Firewall rules that HotSpot adds
A running HotSpot server adds dynamic rules to the NAT and filter tables. They are placed before your own rules.
In /ip/firewall/nat, the dstnat chain sends the packets of HotSpot clients to the hotspot chain:
/ip/firewall/nat/print dynamic
Flags: D - DYNAMIC
0 D chain=dstnat action=jump jump-target= hotspot=from-client
1 D chain= action=jump jump-target=pre-
2 D chain= action=redirect to-ports=64872 protocol=udp dst-port=53
3 D chain= action=redirect to-ports=64872 protocol=tcp dst-port=53
4 D chain= action=redirect to-ports=64873 protocol=tcp
hotspot=local-dst dst-port=80
5 D chain= action=redirect to-ports=64875 protocol=tcp
hotspot=local-dst dst-port=443
6 D chain= action=jump jump-target=hs-unauth protocol=tcp hotspot=!auth
7 D chain= action=jump jump-target=hs-auth protocol=tcp hotspot=auth
8 D chain=hs-unauth action=redirect to-ports=64874 protocol=tcp dst-port=80
9 D chain=hs-unauth action=redirect to-ports=64874 protocol=tcp dst-port=3128
10 D chain=hs-unauth action=redirect to-ports=64874 protocol=tcp dst-port=8080
11 D chain=hs-unauth action=redirect to-ports=64875 protocol=tcp dst-port=443
12 D chain=hs-unauth action=jump jump-target=hs-smtp protocol=tcp dst-port=25
13 D chain=hs-auth action=redirect to-ports=64874 protocol=tcp hotspot=http
14 D chain=hs-auth action=jump jump-target=hs-smtp protocol=tcp dst-port=25
The rules redirect to four ports of the router, which /ip/service/print where dynamic lists:
| Port | Service | What it does |
|---|---|---|
| 64872 | resolver | Answers the DNS requests of the HotSpot clients, also those that a client sends to another DNS server. |
| 64873 | hotspot | Serves the login page and the other HotSpot pages over HTTP. |
| 64874 | wproxy | Receives the HTTP requests of clients that are not logged in. It lets the requests to walled garden sites through and answers the others with a redirect to the login page. |
| 64875 | wproxy | Receives the HTTPS requests of clients that are not logged in and lets the requests to walled garden sites through. |
hotspotredirects DNS requests and the requests to the login page to the HotSpot service, and sends the other TCP packets tohs-unauth(not logged in) orhs-auth(logged in).hs-unauthredirects HTTP, the proxy ports 3128 and 8080, and HTTPS to the HotSpot service, which checks the walled garden and shows the login page. The rules for ports 3128 and 8080 catch the requests of a browser that is set to use a proxy server.hs-authredirects the packets of logged-in users that have thehttpHotSpot mark to the proxy on port 64874.hs-smtpis empty untilsmtp-serveris set in the server profile. Then it has a rule that sends the SMTP connections (TCP port 25) of the clients to that server.- A walled garden IP rule for TCP appears in
hs-unauthas areturnrule, so the matching packets are not redirected. pre-hotspotis for your own rules: add rules to this chain to handle packets of HotSpot clients before the HotSpot rules.
In /ip/firewall/filter, the packets of clients that are not logged in go to their own chains:
/ip/firewall/filter/print dynamic where chain~"hs-" or
Flags: D - DYNAMIC
0 D chain=forward action=jump jump-target=hs-unauth hotspot=from-client,!auth
1 D chain=forward action=jump jump-target=hs-unauth-to hotspot=to-client,!auth
2 D chain=input action=jump jump-target=hs-input hotspot=from-client
3 D chain=input action=drop protocol=tcp hotspot=!from-client
dst-port=64872-64875
4 D chain=hs-input action=jump jump-target=pre-hs-input
5 D chain=hs-input action=accept protocol=udp dst-port=64872
6 D chain=hs-input action=accept protocol=tcp dst-port=64872-64875
7 D chain=hs-input action=jump jump-target=hs-unauth hotspot=!auth
8 D chain=hs-unauth action=reject reject-with=tcp-reset protocol=tcp
9 D chain=hs-unauth action=reject reject-with=icmp-net-prohibited
10 D chain=hs-unauth-to action=reject reject-with=icmp-host-prohibited
-
hs-unauthhandles the packets from clients that are not logged in, andhs-unauth-tothe packets to them. Both reject everything that a walled garden IP rule does not allow. -
hs-inputaccepts the connections of clients to the HotSpot service on the router. -
pre-hs-inputis for your own rules for packets from HotSpot clients to the router. -
Rule 3 drops connections to the HotSpot service ports that do not come from a HotSpot client.
Each rule in /ip/hotspot/walled-garden/ip appears in the filter as two dynamic return rules, one in hs-unauth for the packets to the destination and one in hs-unauth-to for the replies. In the NAT table only the rules for TCP appear.
Read more
- HotSpot customisation - your own login page.
- CLI reference:
/ip/hotspot,/ip/hotspot/profile,/ip/hotspot/user,/ip/hotspot/user/profile,/ip/hotspot/active,/ip/hotspot/host,/ip/hotspot/walled-garden,/ip/hotspot/walled-garden/ip,/ip/hotspot/ip-binding,/ip/hotspot/cookie,/ip/hotspot/setup.