JustASRV

MikroTik RouterOS

RouterOS has no generic dyndns2 client, but /tool fetch supports HTTPS with Basic authentication (RouterOS 6.43 and later, and v7). A small script run by the scheduler does the job, including change detection and a heartbeat.

1. Trust the certificate chain

/tool fetch only verifies the server if the router trusts the issuing CA. Import Let's Encrypt's ISRG Root X1 certificate (/tool fetch url=https://letsencrypt.org/certs/isrgrootx1.pem, then /certificate import file-name=isrgrootx1.pem) and add check-certificate=yes to both fetch commands below. Newer RouterOS 7 releases also ship a built-in CA store; check /certificate settings on your version. Without either, the token still travels encrypted, but the server's identity is not verified.

2. Add the script

System › Scripts, name justasrv, policy read, write, test, policy:

:local fqdn "acme-main.ddns.justasrv.com"
:local token "jas_YOUR_TOKEN"
:global jasLastIp
:global jasBeat
:if ([:typeof $jasBeat] != "num") do={ :set jasBeat 0 }
:local ip ""
:do {
  :set ip ([/tool fetch url="https://ddns.justasrv.com/ip" mode=https output=user as-value]->"data")
} on-error={ :log warning "JustASRV: cannot reach ddns.justasrv.com" }
:set jasBeat ($jasBeat + 1)
# update on change, or every 2nd run (10 minutes with a 5-minute schedule) as a heartbeat
:if ($ip != "" && ($ip != $jasLastIp || $jasBeat >= 2)) do={
  :do {
    :local r ([/tool fetch url=("https://ddns.justasrv.com/nic/update?hostname=" . $fqdn) mode=https \
      user=$fqdn password=$token output=user as-value]->"data")
    :if ([:pick $r 0 4] = "good" || [:pick $r 0 5] = "nochg") do={
      :if ($ip != $jasLastIp) do={ :log info ("JustASRV: " . $r) }
      :set jasLastIp $ip
      :set jasBeat 0
    } else={ :log warning ("JustASRV: " . $r) }
  } on-error={ :log warning "JustASRV: update rejected (check token / hostname)" }
}

3. Schedule it

/system scheduler add name=justasrv interval=5m on-event=justasrv start-time=startup

Check Log for lines starting with JustASRV:. The default thresholds (stale 30 min) fit this schedule.

RouterOS's /tool fetch reports HTTP 4xx responses as errors rather than returning the body, so an invalid token shows as "update rejected". The exact reason (badauth, nohost…) is in the hostname's history in the portal.