MikroTik billing without a public IP: how WireGuard gets around CGNAT

By the WIFI247 team, Kenya · Updated

Short answer

A billing system has to reach your MikroTik to log paying customers in and out. If your internet link has no public IP (CGNAT, common on LTE and many fibre links in Kenya), it cannot. The fix is to have the router connect out to the billing server over a VPN. WireGuard, built into RouterOS 7, is the fastest and simplest option. The billing system then reaches the router through the tunnel, with no public IP and no port forwarding.

Why does billing need to reach your router?

Every sale ends with a command to the router: log this customer in for 3 hours, disconnect this expired PPPoE account. The billing system sends these commands through the MikroTik API. If the billing server cannot open a connection to your router, paying customers stay offline.

How to check if you are behind CGNAT

Compare two addresses:

  1. The address on your router's internet interface: /ip address print
  2. The address the internet sees: open ifconfig.me from a device behind the router.

If they are different, or the router's address falls in 100.64.0.0/10, 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16, your ISP has put you behind NAT and nothing on the internet can connect in to your router.

Your options, compared

OptionWorks behind CGNAT?Drawbacks
Buy a public IPNot neededMonthly cost; not offered on many LTE plans; router API exposed unless firewalled
Port forwardingNoOnly works if you already have a public IP
L2TP / SSTP / OpenVPNYesSlower, heavier on small routers, more settings to get wrong
WireGuardYesNeeds RouterOS 7

WireGuard reconnects quickly after the link drops, uses little CPU, and its whole configuration is a key pair and an address. That makes it the best fit for billing tunnels on small MikroTik routers.

How WIFI247 sets it up for you

When you add a router in WIFI247, you paste one command into the router's terminal. The router then:

  1. checks that it runs RouterOS 7,
  2. creates a WireGuard interface with a key pair issued for that router alone,
  3. gets a private tunnel address of its own and connects to the billing server,
  4. lets the billing server reach the router's API through the tunnel,
  5. reports back, and shows as online in your dashboard.

From then on, every sale, expiry and reconnection travels through the tunnel. It works the same on fibre, LTE, or a link you share with another ISP.

What if the tunnel goes down?

Customers who are already online stay online, because the router keeps enforcing their sessions on its own. New purchases are queued and retried automatically, so a customer who pays during an outage is connected as soon as the tunnel returns. If a router stays offline, WIFI247 alerts you on your dashboard.

Keep the API off the open internet

Whatever you choose, never open the API port (8728) or Winbox (8291) to the whole internet. Bots scan Kenyan IP ranges constantly and try passwords. Allow management only from the tunnel address of your billing server and from your own VPN.

Questions

Can MikroTik hotspot billing work without a public IP?

Yes. The router opens a VPN tunnel out to the billing server, and the billing server controls the router through that tunnel. WIFI247 does this with WireGuard automatically when you add a router.

How do I know if my MikroTik is behind CGNAT?

Compare the address on your router's internet interface with the address a site like ifconfig.me shows. If they differ, or the router's address starts with 100.64 to 100.127, 10., 172.16 to 172.31 or 192.168., you are behind NAT and have no public IP.

Does WireGuard work on RouterOS 6?

No. WireGuard is built into RouterOS 7. Upgrade the router to RouterOS 7 to use it.

What happens to customers if the VPN tunnel drops?

Customers who are already online stay online, because the router keeps enforcing their sessions. New purchases are retried automatically, and the customer is connected as soon as the tunnel is back.

Is it safe to open the MikroTik API port to the internet?

No. Never expose the API port (8728) to the whole internet. Allow it only from the VPN tunnel.

More guides

Try it on one router first

The first month is free, then from Ksh 1,000 a month. If it doesn't suit you, stop. There's no contract.