Community discussions

MikroTik App
 
Chr15t0
just joined
Topic Author
Posts: 1
Joined: Wed Jul 17, 2024 11:08 am

DDNS Double NAT Script

Wed Jul 17, 2024 11:16 am

Hello
I'm trying to reach a Mikrotik Hap ax2 behind a double NAT public address. I have setup a Dynu account and found a script for a double NAT connection. On the post for the double NAT script it says " Note that you need to escape the special characters such as “ and $ and also to insert the \r\ and \n line control characters." I am a nube at scripting. Please can someone help me to fix the script to get it working?

[# get the current IP address from the internet
/tool fetch mode=http address="checkip.dynu.com" src-path="/"
dst-path="/dynu.checkip.html"
:local result [/file get dynu.checkip.html contents]

# parse the current IP result
:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local currentIP [:pick $result $startLoc $resultLen]
:global ddnsuser your_Dynu_username
:global ddnspass "your_Dynu_password"
:global ddnshost "your_Dynu_hostname"
:global ipddns [:resolve $ddnshost];

#:global ipddns

:if ($ipddns != $currentIP) do={
:log info ("DynuDDNS: IP-Dynu = $ipddns")
:log info ("DynuDDNS: IP-Fresh = $currentIP")
:log info "DynuDDNS: Update IP needed, Sending UPDATE...!"
:global str "/nic/update?hostname=$ddnshost&myip=$currentIP"
:log info "currentIP is $currentIP"
/tool fetch address=api.dynu.com src-path=$str mode=http user=$ddnsuser password=$ddnspass
dst-path=("/Dynu.".$ddnshost)
:delay 1
:global str [/file find name="Dynu.$ddnshost"];
/file remove $str
:global ipddns $currentIP
:log info "DynuDDNS: IP updated to $currentIP!"
} else={
:log info "DynuDDNS: No change needed";
}]
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 4009
Joined: Sun May 01, 2016 7:12 pm
Location: California
Contact:

Re: DDNS Double NAT Script

Wed Jul 17, 2024 5:32 pm

Who is online

Users browsing this forum: No registered users and 2 guests