MikroTik RouterOS v7 (WireGuard)
Connect your RouterOS 7 device to Hotspotly over a WireGuard tunnel with the single script the panel generates.
This guide connects a MikroTik device running RouterOS 7 to Hotspotly. When you finish, there is an encrypted WireGuard tunnel between the router and Hotspotly. The panel reaches the router through this tunnel, and RADIUS requests use it too. The guest network and the login page are not covered here; they are the next steps.
In short
In the panel: Add Device → MikroTik RouterOS → RouterOS v7 → WireGuard → Generate Script. Paste the script into the router terminal in one piece. When the panel shows Router key received, tunnel ready, run the test and complete the setup. It takes 5–10 minutes.
Prerequisites
| You need | Details |
|---|---|
| RouterOS 7.x | WireGuard only exists on v7. For RouterOS 6.49 use the L2TP/IPsec guide. /system resource print shows your version. |
| Terminal access | Winbox → New Terminal, WebFig → Terminal, or SSH, with a full-permission admin account. |
| Outbound internet | The router must be able to reach UDP 51820 (WireGuard) and HTTPS (TCP 443) outbound. The router is the client; you do not need to open any inbound port. |
| Correct clock | If the router clock is wrong, the HTTPS certificate cannot be verified. Using NTP is recommended. |
| Hotspotly account | Access to the customer panel and a free device slot in your plan. |
What changes on the router?
The script only removes and rewrites entries whose name or comment starts with "Hotspotly": the
wg-hotspotly interface, the hotspotly-api user, firewall rules commented Hotspotly … and the
Hotspotly RADIUS entry. It also enables /radius incoming (CoA) on UDP 3799. Your own WireGuard
interfaces, users and rules are left alone.
1. Add the device
On the My Devices page, click Add Device at the top right and choose MikroTik RouterOS from the brand list. The Add New Device wizard opens with three steps: Connection Type, Connection Test and Device Details.
Under RouterOS version, keep RouterOS v7 selected and choose the WireGuard card with the Recommended badge as the connection type.
Pick the right version
The version and connection type are locked after the script is generated. If you picked the wrong one, close the wizard, then cancel the device from the list with Continue Setup → Cancel Setup and start again.
2. Prepare the certificate
The router reports the key it generates to Hotspotly over HTTPS and verifies the server certificate. RouterOS has no trusted root certificate (CA) by default, so on a new or reset router the report fails. Before you run the script, import the Let's Encrypt root certificate (ISRG Root X1). The wizard's Certificate preparation (before the script) box shows the same commands; it opens by itself once the wait passes one minute.
The file is downloaded without verification, so compare the fingerprint in the
/certificate print detail output. The SHA-256 value must be:
If it differs, remove the certificate (/certificate remove [find name~"isrgrootx1"]) and stop.
You can also compare it with Let's Encrypt's certificates page.
The date and time in /system clock print must be correct as well.
Important
Do not work around the problem with check-certificate=no. With verification turned off, someone
in the path could report a fake key and take over the other end of the tunnel.
3. Generate and run the script
- In the wizard, click Generate Script. The MikroTik Setup Script box appears.
- Copy the whole script with the Copy button at the top right of the box.
- Open New Terminal in Winbox (or connect over SSH) and paste the script in one piece. The script is a single
{ … }block; RouterOS reads the whole block before running it. - Wait for the final line
Hotspotly: WireGuard anahtari bildirildi. Panelden devam ediniz.(the router messages are in Turkish: "key reported, continue in the panel").
Do not paste line by line
In its last step the script reads the router's public key into a :local variable. If you enter
the commands one at a time, that variable is lost and the key cannot be reported. Always paste the
script as a whole.
The script contains secrets
It holds a router-specific API password, a RADIUS secret and a one-time report link. Do not share the script by email, in a support ticket or in a screenshot.
What the script does
The script comments are in Turkish ("Adim" = step).
| Step | What happens on the router |
|---|---|
| Adim 1 | Creates the wg-hotspotly interface if it does not exist; RouterOS generates the key itself. If the interface already exists, its key is kept. |
| Adim 2 | Adds the Hotspotly server as the only peer: allowed-address is just the server's tunnel address, endpoint-port=51820, persistent-keepalive=25s. |
| Adim 3 | Assigns the tunnel address the panel reserved for this device as a /32 on wg-hotspotly. |
| Adim 4 | Creates the hotspotly-api user, which can only log in from the server's tunnel address. |
| Adim 5 | Firewall rules for the tunnel interface: Hotspotly Tunnel Drop, API Access (TCP 8728), Ping, Established. Everything except the server is dropped. |
| Adim 6 | Hotspotly RADIUS client (service=hotspot,dhcp, a per-device secret, the tunnel IP as source) and /radius incoming on UDP 3799 for CoA, with a firewall rule. |
| Adim 7 | Reports the router's public key to a one-time, time-limited HTTPS link. The private key never leaves the router. |
The script can be run again: it removes the Hotspotly entries first and writes them anew. A
shortened sample with the secret values replaced by <...>:
4. Wait for the key
When the script runs, the router generates its own WireGuard key and reports only the public key to Hotspotly. Meanwhile the wizard shows Waiting for the router's WireGuard key; once the key arrives, usually within seconds, it changes to Router key received, tunnel ready. The Next button stays disabled until then.
If you close the wizard at this point, the device stays in the list as Pending Setup. When you come back with Continue Setup, the panel regenerates the script with a new report link, and any script you copied earlier stops working.
5. Test the connection and complete
- Go to the Connection Test step with Next and click Run Test. The panel pings the router through the tunnel and tries the API connection.
- When you see Connection Successful!, continue with Next. If you see Connection Failed, check the troubleshooting table below.
- In the Device Details step, fill in Device Name (required), Location and Description.
- Click Complete. The device appears in the list.
Verify on the router
If the panel test passed, these checks are optional; they help when you are chasing a problem.
Take <SERVER_TUNNEL_IP> from the allowed-address line in the script.
What to expect:
- The
wg-hotspotlyinterface exists; the only peer is the Hotspotly server, itsallowed-addressis the server's tunnel address andlast-handshakeis a few seconds ago. - The ping gets replies.
- The RADIUS entry has the server's tunnel address as
address,service=hotspot,dhcpand the device's tunnel address assrc-address. After portal provisioning its comment changes tohotspotly:<version>. /radius incomingshowsaccept=yes,port=3799.- Five Hotspotly firewall rules: Tunnel Drop, API Access, Ping, Established and RADIUS CoA.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| The terminal prints “anahtar bildirilemedi … SERTIFIKA” (key not reported, certificate), often after a “guvenilir CA sertifikasi yok” (no trusted CA) warning | The router does not trust ISRG Root X1, or its clock is wrong. | Run the certificate preparation commands, then run the same script again. You do not need to regenerate it until the link expires. |
| The wizard shows “The key report link has expired. Regenerate the script and run it on the router again.” | The report link is time-limited and single-use, and it has expired. | Get a new script with Regenerate script and run it on the router. |
| Running the script a second time, the report fails | The link was already used, or the script was regenerated since. | If the key was already received, nothing to do. Otherwise take the current script from the panel. |
| “This key is registered to another device. Remove the wg-hotspotly interface on the router and regenerate the script.” | The router's key is used by another device record. | As the message says: on the router run /interface wireguard remove wg-hotspotly, then regenerate and run the script. |
| “The tunnel address or key conflicts with another entry on the VPN server. Cancel the setup and start again; if it happens again, contact support.” | The tunnel address or key conflicts with another entry on the server. | Cancel the setup and start again; if it happens again, contact support. |
| “The VPN server is not responding. Run the script on the router again in a moment.” | The VPN server is temporarily not responding. | Wait a moment and run the same script again. |
An error like bad command name wireguard and nothing was added |
The script was pasted into RouterOS v6. The whole block is rejected, so no line runs. | Cancel the setup and follow the RouterOS v6.49 (L2TP/IPsec) guide. |
| Key reported, but Connection Failed | The router cannot reach UDP 51820 outbound (upstream modem or firewall); last-handshake is empty. |
Check the outbound rules and the handshake with /interface wireguard peers print detail. More in the FAQ. |
Security notes
- The WireGuard private key is generated on the router and never leaves it; Hotspotly only sees the public key.
- The
hotspotly-apiuser can only log in from the server's tunnel address; on the tunnel interface every connection that is not from the server is dropped by the firewall. - The RADIUS secret and the API password are generated per device. Do not share the script.
- No guest data is processed in this step. Guest logins and records start after portal provisioning.
Next steps
- Guest network and hotspot server: portal provisioning needs an existing hotspot server on the router.
- Apply to router and compliance check: writing the login page files and RADIUS settings to the router.
- Your first hotspot: the end-to-end checklist.