Skip to content

Instantly share code, notes, and snippets.

@alecs
Last active March 25, 2024 22:31
Show Gist options
  • Save alecs/7c42c4dcdd66420fdf9643f684bb678d to your computer and use it in GitHub Desktop.
Save alecs/7c42c4dcdd66420fdf9643f684bb678d to your computer and use it in GitHub Desktop.
dyndns-mikrotik-ros7.rsc
:global ddnsuser "xxx"
:global ddnspass "yyy"
:global theinterface "pppoexxx"
:global ddnshost chosen.name.here
:global ipddns [:resolve $ddnshost];
:global ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ]
:if ([ :typeof $ipfresh ] = nil ) do={
:log info ("no-ip.ro: No ip address on $theinterface .")
} else={
:for i from=( [:len $ipfresh] - 1) to=0 do={
:if ( [:pick $ipfresh $i] = "/") do={
:set ipfresh [:pick $ipfresh 0 $i];
}
}
:if ($ipddns != $ipfresh) do={
:log info ("no-ip.ro: IP-dns = $ipddns")
:log info ("no-ip.ro: IP-new = $ipfresh")
:log info "no-ip.ro: Update IP needed, Sending UPDATE...!"
:global url "https://remote.pdns.domain.io/nic/update\?hostname=$ddnshost&myip=$ipfresh&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
/tool fetch url=$url mode=https user=$ddnsuser password=$ddnspass dst-path=("/no-ip-ro.".$ddnshost)
:delay 1
:global str [/file find name="no-ip-ro.$ddnshost"];
/file remove $str
:global ipddns $ipfresh
:log info "no-ip.ro: IP updated to $ipfresh!"
} else={
:log info "no-ip.ro: dont need changes";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment