Last active
January 21, 2025 09:39
-
-
Save bmiro/49523ee157b6be1e7c7633a392d64040 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mikrotik script to update DuckDNS.org domain, to use it: | |
# - Download it as `duckdns-update` | |
# - Tune your `duckToken` and `duckDomain` variables | |
# - Copy it to your router: | |
# `scp duckdns-update user@you-router:` | |
# - Add the script | |
# `/system script add name=duckdns-update source=[ /file get duckdns-update contents ]` | |
# - Add a periodic task to execute it | |
# `/system scheduler add name=duckdns-updater interval=1h on-event=duckdns-update` | |
# - Or execute it manully | |
# `/system script run duckdns-update` | |
# Set needed variables | |
:local duckToken "your-token-uuid" | |
:local duckDomain "examplesubdomain" | |
:global previousIP | |
:log info ("DuckDNS: Check") | |
/tool fetch mode=http address="whatismyip.akamai.com" host="whatismyip.akamai.com" src-path="/" dst-path=/ip.txt | |
:local externalIP [/file get ip.txt contents] | |
:if ($externalIP != $previousIP) do={ | |
:set previousIP $externalIP | |
/tool fetch mode=https url="https://www.duckdns.org/update?domains=$duckDomain&token=$duckToken&ip=$externalIP" dst-path=duckdns.txt; | |
:local result [/file get duckdns.txt contents]; | |
:log info "Duck DNS update result: $result"; | |
} else={ | |
:log info ("DuckDNS: IP not changed") | |
} |
Thank you. At last I found a working one.!
here is a bit more advanced variant
https://github.com/beeyev/Mikrotik-Duckdns-Dynamic-IP-Updater
I had to change line 20 by removing "/" before ip.txt.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes! for the advise :D