Set up an agent on an OpenWrt router
Already running OpenWrt? Put the agent on the router itself — no extra box to buy or power, and everything on your network becomes reachable.
Before You Start
- A MikRouter account with an agent created under Agents.
- That agent's
tokenandtunnel host, from its detail page. You'll paste them into the router. - A router already running OpenWrt (18.06 or newer), reachable over
sshasroot— we don't install OpenWrt for you. - About 600 KB free on the router —
df -h /overlaytells you. Step 2 checks this before anything is downloaded. - Internet access on the router. The agent dials out, so you don't open a port and don't need a public IP.
Your router carries on being a router
Nothing connects in, so this works behind CGNAT and on a changing IP — no port forwarding, no public address.
Connect to the router over SSH
root. Use the router's own address — 192.168.1.1 on a fresh OpenWrt install.ssh root@192.168.1.1
If SSH is switched off, turn it on in LuCI under System›Administration›SSH Access first. Everything below is typed on the router.
Check there is room on the router
df -h /overlay
root@OpenWrt:~# df -h /overlayFilesystem Size Used Available Use% Mounted on/dev/ubi0_1 1.1M 524.0K 628.0K 46% /overlayLook at the Available column. This router has 628 KB free, which is enough.
Not enough room? There is a second route
* verify_pkg_installable: Only have 84kb available on filesystem /overlay, pkg mikrouter-agent needs 480If that's your router, stop here and use Set up an agent on a small-flash OpenWrt router instead. It keeps a few kilobytes on the router and loads the agent into memory at every boot.
Paste the one-line installer
Enter.It asks which version — press Enter for the newest — then for the settings page port, the agent server and the device token. The last two are on the agent's page in your dashboard. Enter keeps whatever is shown in brackets.
That is all: the agent is installed, starts at boot, and is already connected.
wget -qO- https://mikrouter.com/installer/install-agent-openwrt.sh | sh
root@OpenWrt:~# wget -qO- https://mikrouter.com/installer/install-agent-openwrt.sh | sh MikRouter agent installer router OpenWrt 25.12.5 (mips_24kc) packages apk (.apk) Finding the newest version ... Downloading mikrouter-agent_1.0.0_mips_24kc.apk ... checksum verifiedInstalling ...(1/1) Installing mikrouter-agent (1.0.0-r0) Executing mikrouter-agent-1.0.0-r0.post-installOK: 12.0 MiB in 147 packages MikRouter agent setupPress Enter at any of them to leave it for the settings page later. Its page will be at http://192.168.1.1:<port>/1. Settings page port [8080]: The agent server on this agent's dashboard page.2. Tunnel host [not set]: test.mikrouter.com The 48-character token on that same page.3. Device token [not set]: 0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x InstalledOpen http://192.168.1.1:8080 on this network. agent server test.mikrouter.com device token configured mikrouter-agent status what is configured, and is it running mikrouter-agent setup change these settings from a terminal logread -e mikrouter watch its logCheck that it connected
mikrouter-agent status shows the settings and whether the agent is running:root@OpenWrt:~# mikrouter-agent statusMikRouter OpenWrt agent 1.0.0 agent server test.mikrouter.com device token set settings page port 8080 settings file /etc/mikrouter-agent/config.json service running tunnel connected as Branch Router (2 open streams) log logread -e mikrouterConfirm the router is Online in the dashboard
Branch Router
OpenWrt 25.12.5OnlineAgent
Live status reported by the agent — only while it's online.
Hardware
OpenWrt 25.12.5 TP-Link EAP225-Outdoor v3
Wi-Fi network
—
Wi-Fi signal
—
IP address
192.168.1.1
Firmware
v1.0.0
RAM available
41 MB
Active streams
0 / 64
Connected
just now
Why the Wi-Fi tiles are empty
— on every router, even when Wi-Fi is working perfectly. The agent doesn't manage the radio, so it reports nothing about it — that stays in LuCI. The Hardware tile starts with OpenWrt, which is how MikRouter knows this is a router.The settings page (only if you need to change something)
http://192.168.1.1:8080. The password starts as mikrouter; change it in the Password card, which asks for the current one first. Sign out at the bottom ends the session on this browser.MikRouter Agent
Relaying connections to this network
Status
Connection
Agent server
Device token
Both are on the agent's page in the MikRouter dashboard. Emptying either one disconnects the tunnel.
SaveSettings page
Port
This page moves as soon as you save, and the tunnel is not touched. Port 80 is normally LuCI's.
Change portPassword
Current password
New password
Changing it signs this browser out.
Change passwordWi-Fi, DHCP and firewall stay with OpenWrt — configure them in LuCI. This agent only relays connections.
Saving applies it straight away — the agent reconnects with the new settings. There is nothing to restart.
Both boxes arrive holding what the router is using now, so emptying one clears it rather than leaving it alone — an empty agent server or device token disconnects the tunnel.
Port 8080, not 80 — and it is not a mistake
You can move it in the Settings page card if 8080 clashes with something. It moves as soon as you save and links you to the new address. If the port cannot be used, nothing changes and the page says why.
If the page does not open, the tunnel still works — a settings page that can't start is skipped rather than stopping the agent.
Removing the agent
Use the helper. It removes the package and your settings, which the package manager leaves behind.
mikrouter-agent uninstall
Removes the agent and its settings, including your device token. Use this when the router is leaving your hands.
mikrouter-agent uninstall --keep-settings
The same, but keeps your settings, so reinstalling later reconnects on its own.
Every mikrouter-agent command
You are already root over SSH, so nothing here needs sudo. The full list is mikrouter-agent help.
Day to day
mikrouter-agent statusThe settings, the tunnel state, and whether the agent is running.
mikrouter-agent setupAsks for the agent server, device token and settings page port.
mikrouter-agent versionPrint the installed version.
logread -e mikrouterThe agent's log. Add -f to follow it.
Changing one setting
mikrouter-agent set host <name>Agent server, from the agent's page. Note the syntax: a name and a value, no dashes.
mikrouter-agent set token <48 hex>Device token, from the same page.
mikrouter-agent set port <1-65535>Agent server port. Default 443.
mikrouter-agent set tls true|falseUse TLS for the tunnel. On by default — leave it on.
mikrouter-agent set portalPort <1-65535>Port for the settings page. Default 8080, because 80 is LuCI's. A port browsers refuse to open — 1, 21, 22, 23, 25, 53 and about seventy more — is rejected, because the page would be unreachable from a browser.
mikrouter-agent set webpass <password>Password for the settings page. Starts as “mikrouter”.
mikrouter-agent set tunnelEnabled true|falseTurn the tunnel off without stopping the agent. The settings page stays up.
mikrouter-agent set maxStreams <1-64>How many connections at once. Default 64.
The service (procd)
/etc/init.d/mikrouter-agent restartApply changed settings.
/etc/init.d/mikrouter-agent stopStop the agent. It comes back at the next boot.
/etc/init.d/mikrouter-agent disableStop it starting at boot.
mikrouter-agent uninstallRemove the agent and its settings, including your device token.
mikrouter-agent uninstall --keep-settingsRemove the agent but keep the settings, so a reinstall reconnects on its own.
What is different about running the agent on a router
| Field | Value | Note |
|---|---|---|
| Wi-Fi | not managed | OpenWrt keeps the radios. The agent has no Wi-Fi code at all. |
| DHCP / DNS | not managed | OpenWrt keeps both. The agent runs neither. |
| Settings | /etc/mikrouter-agent | Not /var — that is wiped at every reboot. |
| Service | procd | /etc/init.d/mikrouter-agent, not systemd. |
| Updates | package manager | No self-update on a router. |
| Settings page | port 8080 | LuCI has port 80. |
| Connections | 64 | The same as a computer agent, not the ESP32's handful. |