Skip to content

Instantly share code, notes, and snippets.

@luispaulorsl
Created December 21, 2019 14:54
Show Gist options
  • Save luispaulorsl/5df801cd8b4e4dff4af1519a2d40da10 to your computer and use it in GitHub Desktop.
Save luispaulorsl/5df801cd8b4e4dff4af1519a2d40da10 to your computer and use it in GitHub Desktop.
Mikrotik/RouterOS Script to update DDNS on No-IP (noip.com)
# No-IP DDNS Updater
# http://www.noip.com/integrate/
:global publicIP;
:global abortUpdate;
:if ([:typeof $abortUpdate] != "bool") do={
:set $abortUpdate false;
}
:if ($abortUpdate) do={
:error "DDNS: Update aborted. Intervention required.";
}
:local currentIP;
:local targetInterface "<interface | auto>";
:local ddnsUser "<username>";
:local ddnsPass "<password>";
:local ddnsHost "<hostname>";
:local ddnsURL "http://dynupdate.no-ip.com/nic/update?hostname=$ddnsHost&myip=$currentIP";
:if ($targetInterface = "auto") do={
:local response [/tool fetch url="http://luispaulo.net/ip" as-value output=user];
:if ($response->"status" = "finished") do={
:set currentIP ($response->"data");
} else={
:set currentIP "";
}
} else={
:set currentIP [/ip address get [/ip address find interface=$targetInterface] address];
:if ([:typeof $currentIP] = nil) do={
:error "DDNS: No IP obtained.";
} else={
:set $currentIP [:pick [:tostr $currentIP] 0 [:find [:tostr $currentIP] "/"]];
}
}
:if ($currentIP != $publicIP) do={
:local response [/tool fetch url=$ddnsURL user=$ddnsUser password=$ddnsPass as-value output=user];
:if ($response->"status" = "finished") do={
:local data ($response->"data");
:set $abortUpdate (!([:pick $data 0 4] = "good" || [:pick $data 0 5] = "nochg"));
:set $publicIP $currentIP;
:log info "DDNS: Update succeeded."
} else={
:log error "DDNS: Update failed.";
}
} else {
:log info "DDNS: No IP change.";
}
@robinhugy
Copy link

not working for me on 6.49.8
i dont get nothing in log and ip not updating

@frosty024
Copy link

frosty024 commented Apr 20, 2024

April 19, 2024

Still working for me, running firmware arm64-7.14.3 on an RB5009.
Also running it on an older RB2011 and an older RB951 with firmware mipsbe-6.49.14; working fine.

The script still always reports the IP was updated because it was changed, even when it hasn't changed... But it does actually update when the IP does change, and that's all that matters.

Beware that certain special characters in your NO-IP username/password may not work on a 'tik without first escaping ( \ ) them in pre-7.0 firmware. #https://wiki.mikrotik.com/wiki/Manual:Scripting#Constant_Escape_Sequences

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment