MikroTik RouterOS v6.49 (L2TP/IPsec)
Connect a RouterOS 6.49 device to Hotspotly over an L2TP/IPsec tunnel, run the setup script, test the connection and prepare for portal setup.
This guide connects a MikroTik running RouterOS 6.49 to Hotspotly over an L2TP/IPsec tunnel. The panel generates a setup script for your device. You paste it into the router terminal, the panel tests the tunnel and the router API, and the device is added to My Devices.
What you get
- An L2TP tunnel encrypted with IPsec between the router and Hotspotly (
l2tp-hotspotly). - A management user that can only log in from the Hotspotly server's tunnel address.
- A RADIUS client that authorises guest logins, with session disconnect (CoA) support.
- The ability to install the login page on the router from the panel in the next step.
Using RouterOS 7?
On RouterOS 7, WireGuard is faster and is the recommended path: MikroTik RouterOS v7 (WireGuard).
Prerequisites
- RouterOS 6.49.x. On older versions, portal setup stops with
"RouterOS version not supported (6.49 or later)". The
versionline of/system resource printshows your version. - No WireGuard. RouterOS 6 has no WireGuard. When you pick RouterOS v6 in the wizard, the WireGuard card is disabled and the note "WireGuard is only available on RouterOS v7. RouterOS v6 uses L2TP/IPsec." appears.
- Outbound UDP 500, 4500 and 1701. If a firewall or ISP modem sits in front of the router, allow outgoing traffic on these ports (IPsec and L2TP).
- Terminal access. A RouterOS terminal through Winbox, WebFig or SSH.
- Correct clock. During portal setup the router downloads files over HTTPS; a wrong clock breaks certificate validation.
- An active Hotspotly subscription with a free device slot in your plan.
Add the device
- In the panel, go to My Devices → Add Device → MikroTik RouterOS. The "Add New Device" wizard opens.
- Under RouterOS version, choose RouterOS v6. The L2TP/IPsec card is selected automatically.
- Click Generate Script. The "MikroTik Setup Script" box shows the script for your device.
- Click Copy and paste the script into the router terminal (see below).
- Click Next → Run Test. The panel checks the tunnel first, then the router API. When you see "Connection Successful!", the device model and RouterOS version are listed.
- Enter a Device Name and, optionally, a Location, then click Complete.
Closed the wizard?
If you close the wizard after generating the script, the device stays in the list as "Pending Setup". Use Continue Setup on its card to see the same script again and continue where you left off.
Run the script
Paste the script into a Winbox New Terminal window or an SSH session and wait for every line to run. The last line reads "Kurulum tamamlandi! Panelden devam ediniz." (setup finished, continue in the panel). Script comments are in Turkish in every language.
The script has four steps. In the excerpt below, secret values are shown as <...>; the panel
fills in the real values.
| Step | What it does |
|---|---|
| Adim 1 | An L2TP client named l2tp-hotspotly: use-ipsec=yes, allow=chap,mschap2, add-default-route=no (your internet traffic is not routed into the tunnel). connect-to is the Hotspotly VPN server. |
| Adim 2 | A hotspotly-api user. address= limits its logins to the server's tunnel address. |
| Adim 3 | Four firewall rules for the tunnel interface: Hotspotly Tunnel Drop, API Access (TCP 8728), Ping, Established. Everything except the server is dropped. |
| Adim 4 | The RADIUS client (service=hotspot,dhcp, source address = the device's tunnel IP) and a UDP 3799 rule for CoA. |
Unlike the WireGuard script, the L2TP script has no key report and downloads nothing from the internet. Once it has finished, go straight to Next.
Do not run the script twice on the same router
Most lines in the L2TP script only add. On a second run the client and user fail with "already
exists" errors, and the firewall rules are added a second time. If something goes wrong, follow
the clean reinstall steps.
Verify the connection
If the panel test passes, the tunnel works. To check from the router side as well:
Expected results:
- The
l2tp-hotspotlyclient is running. active-peerslists an established IPsec peer with the VPN server.- Ping to the server's tunnel address gets replies. This is the
address=value in the script and in/radius add address=. - The RADIUS entry shows
service=hotspot,dhcpandsrc-address=<the device's tunnel IP>. - The firewall has five rules with a Hotspotly comment (Tunnel Drop, API Access, Ping, Established, RADIUS CoA).
Once the device is added, its Device Information card shows the tunnel fields: Tunnel Type L2TP/IPsec, Tunnel IP and VPN Status.
Before portal setup: certificate and clock
The L2TP script downloads nothing, but portal setup in the next step downloads the login page files to the router over HTTPS and validates the certificate. RouterOS has no trusted root certificate by default. Import the Let's Encrypt root certificate (ISRG Root X1) once and check the clock:
The SHA-256 fingerprint in the /certificate print detail output must match
96bcec06264976f37460779acf28c5a7cfe8a3c0aae11a8ffcee05c0bddf08c6. If it does not, remove the
certificate and do not use it. If the clock is wrong, set up the NTP client; portal setup also
configures NTP and the time zone.
Do not use check-certificate=no
Turning off certificate validation could let an attacker replace the login page and send your guests somewhere else. Fix the problem by importing the root certificate.
Devices with flash storage
On RouterOS 6 devices with NAND flash (for example RB951), persistent files live under flash/.
Portal setup detects this and puts the login page files under flash/hotspotly/<hotspot-id>/.
You do not need to do anything.
Clean reinstall
If the script stopped halfway, was pasted on the wrong router, or the test keeps failing, start over instead of running the script again:
- In My Devices, find the "Pending Setup" card and click Continue Setup → Cancel Setup. The VPN entry on the Hotspotly side is deleted.
- Remove the old entries on the router by hand (commands below).
- Generate a new script with Add Device → MikroTik RouterOS and run it only once. The new script has a new username, password and tunnel address.
A fully set-up device
These commands delete the tunnel and the RADIUS entry; on a working device guest logins stop. Use them only on a device whose setup is incomplete or that you have cancelled.
Troubleshooting
When the connection test fails, the panel shows the reason sent by the server. These server messages are currently shown in Turkish in every language; the English meaning is given below.
| Symptom | Likely cause | Fix |
|---|---|---|
| Test: "VPN tüneli erişilebilir değil…" (VPN tunnel not reachable; make sure you ran the script) | The script was not run or stopped halfway; outbound UDP 500/4500/1701 is blocked. | Check that the client is running with /interface l2tp-client print detail. If not, read `/log print where topics~"l2tp |
| Test: "VPN tüneli aktif ancak API bağlantısı kurulamadı…" (tunnel up, but no API connection) | The hotspotly-api user was not created, or the router API service (TCP 8728) is disabled or limited to other addresses. |
Check with /user print where name="hotspotly-api" and /ip service print. If api is disabled, run /ip service enable api; if it has an address= limit, add the server's tunnel address. |
| Test: "API bağlantı hatası: …" (API connection error) | The router rejected the API login. | Make sure nobody changed the user's password on the router. If it changed, do a clean reinstall. |
"Already exists" style failure errors in the terminal, or duplicate firewall rules |
The script was run a second time on the same router. | Follow the clean reinstall steps. |
bad command name wireguard in the terminal |
A WireGuard script was pasted on RouterOS 6 (no line runs). | Cancel the setup, choose RouterOS v6 in the wizard and generate a new script. |
| "Maksimum cihaz limitine (…) ulaşıldı" when generating the script (device limit reached) | Your plan's device slots are full; unfinished setups also use a slot. | Delete unused "Pending Setup" entries with Cancel Setup. |
| "VPN sunucusu henüz yapılandırılmamış." when generating the script (VPN server not configured) | Something is missing in the Hotspotly configuration. | Contact support. |
| Portal setup: "RouterOS version not supported (6.49 or later)" | RouterOS is older than 6.49. | Upgrade the router to the 6.49.x long-term release. |
| Portal setup: "Router could not download the login files" | No root certificate, or the router clock is wrong. | Complete the certificate and clock step and try again. |
For more, see VPN connection test failed and certificate problems.
Security and privacy notes
- The script contains device-specific passwords and the IPsec secret. Do not share it by email, in chat apps or in support tickets, and mask these values if you take a screenshot.
- The
hotspotly-apiuser has full rights but can only log in from the Hotspotly server's tunnel address. Do not change the user, its password or the Hotspotly firewall rules, or the panel cannot reach the router. - The tunnel uses
add-default-route=no: your business and guest internet traffic does not go through it. Only management, RADIUS authorisation and session records use the tunnel. - Guest session records (RADIUS accounting, plus the DHCP and hotspot syslog records kept for Turkish Law 5651) travel between the router and Hotspotly only through the encrypted tunnel. For privacy notices and consent, see the Legal texts and guest consent guide.
Next steps
- Guest network and hotspot server on MikroTik: portal setup does not create the hotspot server; it must already exist on the router.
- Apply to router and compliance check: install the login page files, hotspot profile and RADIUS settings on the router.
- Set up your first hotspot: an end-to-end example.