Hi all,
Since i've not been able to find how to update dynamic DNS provider DNSEXIT with new syntax, i post the script i finally use in my HAP AX3 with RouterOS v7.14.1
Hope this helps somebody.
Great job Mikrotik Team with scripting and scheduler functionality!
Best regards
Jordi Bosch
Script Usage and Settings
Mikrotik script to update ip on free dynamic DNS provider DNSEXIT
This script gets WAN IP address and then compares with host resolved ip; if differs then updates dns with new ip and sends email
Also i used /system scheduler to run the script - for example every day
To send mail alarm you need to configure SMTP settings in /tool e-mail - otherwise comment the line --> /tool e-mail
You need to set these 4 following variables acordingly to your Mikrotik environment
:local ApiKey "put_here_your_free_dnsexit_api_key";
:local hostname "here_your_hostname_like_www.mydomain.com";
:local WANInter "interface_name_where_public_IP_is_assigned_for_example_ether1";
:local MailAddr "mail_address_tosend_alarm";
###########################
:global IpCurrent [/ip address get [find interface=$WANInter] address];
#since ip has format like 1.2.3.4/21 we will look for the slash position
:local slashposition [:find $IpCurrent "/" 0];
:if ( [:typeof $slashposition] = "num") do={
:global NewIP [:pick $IpCurrent 0 $slashposition];
:local ResolvedIp [:resolve $hostname];
:if ( $ResolvedIp != $NewIP) do={
/tool fetch url="https://api.dnsexit.com/dns/ud/?apikey=$ApiKey&host=$hostname" keep-result=no;
:log info "DNSEXIT Update: $hostname to $NewIP - resolved IP was $ResolvedIp";
/tool e-mail send to=$MailAddr subject="WAN IP changed in Mikrotik" body="Change Detected--- Ip is $NewIP and $hostname IP was $ResolvedIp";
} else={
:log info "DNSEXIT: don't need changes - Current Ip is $NewIP and resolved IP is $ResolvedIp";
}
}