Page 1 of 1

Dynamic DNS Update Script for Now-DNS.com

Posted: Wed Oct 21, 2015 11:16 pm
by NowIP
Hi MikroTik users,

Now-DNS has put together this simple script to use to update our dynamic DNS service from your MikroTik router.
It does rely on having https support for the fetch command (which recent versions have).
Setup a scheduler task to run the script as often as you require.
# Now-DNS automatic Dynamic DNS update

#--------------- Change Values in this section to match your setup ------------------

# No-DNS User account info
:local NowUser "your_email"
:local NowPass "your_password"

# Your hostname you want to update
# To specify multiple hosts, separate them with commas.
:local NowHost "freeddns.now-dns.org"

#------------------------------------------------------------------------------------

:local url "https://now-dns.com/update\3F"

:log info "Now-DNS: sending update for $host"

/tool fetch url=($url . "hostname=$NowHost") user=$NowUser password=$NowPass mode=https dst-path=("now-dns.txt")

:log info "Now-DNS: host $host updated with IP $currentIP"
We hope it is useful.

Thanks

Steve

Re: Dynamic DNS Update Script for Now-IP.com

Posted: Mon Oct 26, 2015 3:20 pm
by vkotsiuk
Hi!

Sorry for my English.
This is my variant update script:
# Now-IP automatic Dynamic DNS update

#--------------- Change Values in this section to match your setup ------------------

# No-IP User account info
:local username "login@domain.net";
:local password "password";

# To specify multiple hosts, separate them with commas.
:local hostnames "host.now-ip.net,host.myiphost.com";

# Global interface name
:local wanInterface "ether1-gateway";

#------------------------------------------------------------------------------------

# Get current wan interface ip address.
:local currentIP;
do {
  :set currentIP [:local ip [/ip address get [find interface=$wanInterface] address]; :pick $ip 0 [:find $ip "/"]];
  :log debug "current ip $currentIP"
} on-error={
  :log error "can`t get ip address on the interface '$wanInterface'";
  :error;
}

# Check match dns records
:local match true;
:local resolvedIP;
:foreach hostname in=[:toarray $hostnames] do={
  do {
    :set resolvedIP [:resolve $hostname];
  } on-error={
    :log error "can`t resolve hostname '$hostname'";
    :set match false;
  }
  :if ($resolvedIP != $currentIP ) do={
    :set match false;
    :log debug "resolved '$hostname' ip address $resolvedIP no match to current $currentIP";
  } else {
    :log debug "resolved '$hostname' ip address match to current $currentIP";
  }
};

# Update dns records if no match
:if (match != true ) do={
  :local url "https://now-ip.com/update\3F";
  :log info "Now-IP: sending update for '$hostnames'";
  /tool fetch url=($url . "hostname=$hostnames" . "&myip=" . $currentIP) user=$username password=$password mode=https dst-path=("now-ip.txt");
  :local result [/file get "now-ip.txt" contents];
  :log info "Now-IP: host $host updated with $result";
} else {
  :log info "Now-IP: dns resolved corect";
}

Re: Dynamic DNS Update Script for Now-IP.com

Posted: Mon Sep 05, 2016 12:49 am
by fastfoot
script no longer works , after any fetch using https got :
failure: ssl connection error: received alert: unrecognized name (6)
any one can help with ?

MT 6.36.2

Re: Dynamic DNS Update Script for Now-DNS.com

Posted: Wed Nov 09, 2016 12:31 am
by NowIP
Hi,

Are you still having problems updating? Now-IP has been renamed to Now-DNS https://now-dns.com you should update your script to reflect this.

Thanks

Steve

Re: Dynamic DNS Update Script for Now-DNS.com

Posted: Sun Sep 09, 2018 2:00 am
by rodrigoadachi
My code

Does not update, I've tried in several ways
:local username "*************";
:local password "*************";
:local hostnames "*************";
:global LIST "ip-dns";
#------------------------------------------------------------------------------------

# Get current external IP
:global previousIP
:local currentIP [/tool fetch url="http://myip.dnsomatic.com/index.html" mode=http dst-path=currentIP; :delay 1; /file get currentIP contents; /file remove currentIP]
/ip firewall address-list set [find list="$LIST"] address="$currentIP";
:if ($previousIP != $currentIP ) do={
  :log info "now-dns: Found a different ip address $currentIP"
  :set previousIP $currentIP
} else {
  :log info "now-dns: Your ip address is up to date $currentIP";
}

# Update dns records
:local url "https://now-dns.com/update\3F";
/tool fetch url=($url."hostname=".$NowHost."&myip=".$currentIP) mode=https user=$username password=$password src-path=$path keep-result=no;
:log info "now-dns: host $hostnames updated with ip $currentIP";