dot02
June 16, 2022, 9:17am
21
nope, no hidden chars. You only need to adapt the 1st few lines according to your OVH subscription. You onky need to be careful on the OVH format (which you get from your OVH dashboard).
Let’s say your dynamic sub-domain is plop.mydomain.com , then it should look like this (be very careful with the last line, is must match this format!):
:local ovhddnsuser "ThisisMe"
:local ovhddnspass "ThisIsMySecurePWD"
:local theinterface "lte1"
:local ovhddnshost "mydomain.com-plop"
If you wish, you can create a DynDNS user for me on your OVH dashboard and I can try to update the record for you, just to test (in this case, PM me)
if tested on terminal, ? must be replaced with ? (or simply with \3F for every case)
and why probably you get 301 than redrect to main page because “nic/updatesystem” page not exist…
(nic/update**? **system=)
The scipt contains some errors and after is adapted for CGNAT some parts are superfluos.
added { and } at start and at the end to test it on terminal.
# original author: sploit on MikroTik forum
# modified for CGNAT from: dot02 on MikroTik forum
{
:local ovhddnsuser "<OVH_USERNAME>"
:local ovhddnspass "<OVH_PWD>"
:local ovhddnshost "<OVH_DYNDNS_NAME>"
:local ipddns [:resolve $ovhddnshost]
:local ipfresh [:resolve "myip.opendns.com" server=208.67.222.222]
:if ($ipddns != $ipfresh) do={
:log info "OVHDynDNS: $ovhddnshost DNS RECORD IP = $ipddns"
:log info "OVHDynDNS: This RouterBOARD CURRENT IP = $ipfresh"
:log info "OVHDynDNS: UPDATING $ovhddnshost -> $ipfresh"
:local url "https://www.ovh.com/nic/update\3Fsystem=dyndns&hostname=$ovhddnshost&myip=$ipfresh&wildcard=OFF&backmx=NO&mx=NOCHG"
/tool fetch url=$url user=$ovhddnsuser password=$ovhddnspass dst-path="OVHDynDNS.$ovhddnshost"
:delay 1s
:local ovhresult [/file get "OVHDynDNS.$ovhddnshost" contents]
:log info "OVHDynDNS: OVH response: $ovhresult"
/file remove [find where name="OVHDynDNS.$ovhddnshost"]
:if ($ovhresult = "good $ipfresh\n" ) do={
:log info "OVHDynDNS: SUCCESS"
:log info "OVHDynDNS: $ovhddnshost DNS RECORD = $ipfresh!"
} else={
:log info "OVHDynDNS: FAILED"
}
} else={
:log info "OVHDynDNS: We good!"
}
}
dot02
June 16, 2022, 11:54am
24
Thanks! Your version looks much cooler indeed! I’ll update my router this evening!
One question though. If we look at these lines:
:local ovhresult [/file get “OVHDynDNS.$ovhddnshost” contents]
/file remove [find where name=“OVHDynDNS.$ovhddnshost”]
is this file only stored in the memory or actually written to the flash card every single time? If so, the flash card might not like the constant writings for extended period of time…
gyto6
June 16, 2022, 12:43pm
25
The scipt contains some errors and after is adapted for CGNAT some parts are superfluos.
added { and } at start and at the end to test it on terminal.
# original author: sploit on MikroTik forum
# modified for CGNAT from: dot02 on MikroTik forum
{
:local ovhddnsuser "<OVH_USERNAME>"
:local ovhddnspass "<OVH_PWD>"
:local ovhddnshost "<OVH_DYNDNS_NAME>"
:local ipddns [:resolve $ovhddnshost]
:local ipfresh [:resolve "myip.opendns.com" server=208.67.222.222]
:if ($ipddns != $ipfresh) do={
:log info "OVHDynDNS: $ovhddnshost DNS RECORD IP = $ipddns"
:log info "OVHDynDNS: This RouterBOARD CURRENT IP = $ipfresh"
:log info "OVHDynDNS: UPDATING $ovhddnshost -> $ipfresh"
:local url "https://www.ovh.com/nic/update\3Fsystem=dyndns&hostname=$ovhddnshost&myip=$ipfresh&wildcard=OFF&backmx=NO&mx=NOCHG"
/tool fetch url=$url user=$ovhddnsuser password=$ovhddnspass dst-path="OVHDynDNS.$ovhddnshost"
:delay 1s
:local ovhresult [/file get "OVHDynDNS.$ovhddnshost" contents]
:log info "OVHDynDNS: OVH response: $ovhresult"
/file remove [find where name="OVHDynDNS.$ovhddnshost"]
:if ($ovhresult = "good $ipfresh\n" ) do={
:log info "OVHDynDNS: SUCCESS"
:log info "OVHDynDNS: $ovhddnshost DNS RECORD = $ipfresh!"
} else={
:log info "OVHDynDNS: FAILED"
}
} else={
:log info "OVHDynDNS: We good!"
}
}
Thanks, I tested your edited code, and it seems to work. But as strange as it's, the previous :log info doesn't show up in the logs, only the final.
OVHDynDNS: We good!
if tested on terminal, ? must be replaced with ? (or simply with \3F for every case)
and why probably you get 301 than redrect to main page because "nic/updatesystem" page not exist...
(nic/update**? **system=)
I noticed it indeed, I didn't want to flood already more the thread, and I was not aware about the ? or \3F, good to know!
gyto6
June 18, 2022, 9:46am
26
After some investigations, I think that the original script is still functionnal.
Got an illumination when the script detected the Domain Name with its private address. So each time, it asks to OVH to edit the Public IP address from the domain name. OVH answered with an “nochg” message (no change). And after a while, the script enters a perpetual failure due to OVH blocking the redundant modification queries with the already in place public IP address in its DNS Zone.
I’ve an DNS Server in my LAN, and I’d troubleshoots with IPv6 not advertising my inner DNS server address. I had to set it in IP->DNS to get it advertised, and I also changed my IPv4 to the inner one whereas the DHCPv4 was functionnal.
So you must set a public DNS IPv4 address in IP->DNS to get the script working and not get blocked by OVH.
dot02
June 19, 2022, 7:05pm
27
good to know! The script does update 100.64.0.0/10, though.
z3n0
September 8, 2024, 7:34pm
28
Hello everyone, I re-use this topic for continuity.
I’ve used this script but IP address registered in the DNS record is private IP and not public IP. So, its caused by NAT.
Futhermore, I’ve 2 WAN (configured as failover, so with different metric but this is not a problem because I could enable wan load balancing for keep alive both).
I’ve duplicated the script to manage the WAN interfaces separately but I would ask your help for solve the private IP problem.
Thank you for your support!
:local ovhddnsuser "XXXXXX"
:local ovhddnspass "XXXXXX"
:local theinterface "ether1"
:local ovhddnshost "XXXXXX"
:local ipddns [:resolve $ovhddnshost]
:local ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ]
:for i from=( [:len $ipfresh] - 1) to=0 do={
:if ( [:pick $ipfresh $i] = "/") do={
:set ipfresh [:pick $ipfresh 0 $i]
}
}
:if ($ipddns != $ipfresh) do={
:global str "nic/update?system=dyndns&hostname=$ovhddnshost&myip=$ipfresh&wildcard=OFF&backmx=NO&mx=NOCHG"
/tool fetch address=www.ovh.com host=www.ovh.com src-path=$str mode=https user=$ovhddnsuser password=$ovhddnspass dst-path=("/ovhddns.".$ovhddnshost)
:delay 1
:global ovhresult [/file get "ovhddns.$ovhddnshost" contents]
:global str [/file find name="ovhddns.$ovhddnshost"]
/file remove $str
}
dot02
December 21, 2025, 2:32am
29
apparently, OVH has changed the URL to update the Dyndns record, so the old script doesn’t work anymore. Here’s the new one to adapt the script:
https://dns.eu.ovhapis.com/nic/update?system=dyndns&hostname=$HOSTNAME&myip=$IP
cyayon
November 3, 2026, 10:36am
30
Hi all,
here is a better version I just wrote.
# check dynhost and update as required (OVH)
#
# version 20261102
# if iface defined, CurrentIPs will be checked on iface (or fetched from ifconfig.co)
#:local iface "vlan832-orange1.wan1"
:local iface ""
# skip ipv6 or not
#:local skipIP6 "true"
:local skipIP6 ""
# echo -n "user:pass" | base64
:local Base64Auth "xxxxx"
:local dynHost "xxxx"
:local email "xxx@xxx"
:local LogHeader "check-ovhdyn"
:local CurrentIP4
:local CurrentIP6
:local RegisteredIP4
:local RegisteredIP6
:local IPTmp
:local FileTmp4 ("check-ovhdyn_ip4.tmp");
:local FileTmp6 ("check-ovhdyn_ip6.tmp");
:local Resolver4 "1.1.1.1"
:local Resolver6 "1.1.1.1"
:local msg
:local Date [/system clock get date];
:local Time [/system clock get time];
:local Hour [:pick [/system clock get time] 0 2];
:global dynHostStatus
:global dynHostRun
# init Status
:if ( [:tostr $dynHostStatus] = "" ) do={
:set dynHostStatus ($Time . " " . $Date);
}
:set dynHostRun ($Time . " " . $Date);
:set dynHostStatus "OK"
#
# Registered (resolve)
#
#:put "Checking Registered IPs Resolvers $Resolver4 $Resolver6 "
:set RegisteredIP4 [:resolve domain-name=$dynHost server=$Resolver4 type=ipv4];
:if ($skipIP6 != "true") do={
:set RegisteredIP6 [:resolve domain-name=$dynHost server=$Resolver6 type=ipv6];
} else={
:set RegisteredIP6 "skip"
}
:set msg "$LogHeader : Registered IPv4 $RegisteredIP4 - IPv6 $RegisteredIP6"
:log info "$msg"
:put "$msg"
# Check for errors
:if ([:typeof $RegisteredIP4] = nil) do={
:set dynHostStatus "ERROR"
:set msg "$LogHeader : Registered IPv4 empty !"
:put "$msg"
:error "$msg"
}
:if ([:typeof $RegisteredIP6] = nil) do={
:set dynHostStatus "ERROR"
:set msg "$LogHeader : Registered IPv6 empty !"
:put "$msg"
:error "$msg"
}
#
# Get CurrentIP via iface (if defined) or via ifconfig.co
# via iface is not tested (in case of multiple IPs)
# todo : multiple retries / services other than ifconfig.co
#
#:put "Checking Current IPs"
:if ($iface != "") do={
#:put "Checking CurrentIPs from iface $iface"
:set IPTmp [/ip address get [find interface=$iface] address];
:set CurrentIP4 [:pick [$IPTmp] 0 [:find $IPTmp "/"]];
:if ($skipIP6 != "true") do={
:set IPTmp [/ipv6 address get [find interface=$iface] address];
:set CurrentIP6 [:pick [$IPTmp] 0 [:find $IPTmp "/"]];
} else={
:set CurrentIP6 "skip"
}
} else={
#:put "Checking CurrentIPs from fetch"
:set CurrentIP4 ([/tool fetch url="http://ifconfig.co/ip" output=user ip-type=ipv4 as-value]->"data")
:set CurrentIP4 [:pick $CurrentIP4 0 [:find $CurrentIP4 "\n"]]
:if ($skipIP6 != "true") do={
:set CurrentIP6 ([/tool fetch url="http://ifconfig.co/ip" output=user ip-type=ipv6 as-value]->"data")
:set CurrentIP6 [:pick $CurrentIP6 0 [:find $CurrentIP6 "\n"]]
} else={
:set CurrentIP6 "skip"
}
}
:set msg "$LogHeader : Current IPv4 $CurrentIP4 - IPv6 $CurrentIP6"
:log info "$msg"
:put "$msg"
# Check for errors
:if ([:typeof $CurrentIP4] = nil) do={
:set dynHostStatus "ERROR CurrentIP4"
:set msg "$LogHeader : Current IPv4 empty !"
:put "$msg"
:error "$msg"
}
:if ([:typeof $CurrentIP6] = nil) do={
:set dynHostStatus "ERROR CurrentIP6"
:set msg "$LogHeader : Current IPv6 empty !"
:put "$msg"
:error "$msg"
}
#
# update
#
#:put "Checking Update IPs"
:if ($RegisteredIP4 != $CurrentIP4) do={
:set msg "$LogHeader : Current IPv4 $CurrentIP4 not match Registered $RegisteredIP4, updating"
:log info "$msg"
:put "$msg"
:local UpdateUrl "https://dns.eu.ovhapis.com/nic/update?system=dyndns&hostname=$dynHost&myip=$CurrentIP4";
#:set msg "Query IPv4 URL : $UpdateUrl"
#:log info "$msg"
#:put "$msg"
:local Header "Authorization: Basic $Base64Auth";
#:put "Header: $Header";
#:put "Fetching...";
#/tool fetch url=$UpdateUrl http-header-field=$Header mode=https dst-path=$FileTmp4;
:local Response ([/tool fetch url=$UpdateUrl http-header-field=$Header output=user as-value]->"data")
:if (([:pick $Response 0 5] = "good ") || ([:pick $Response 0 5] = "nochg")) do={
:set dynHostStatus "UPDATE4"
:set msg "$LogHeader : Updated IPv4 $dynHost $CurrentIP4"
:log info "$msg"
:put "$msg"
} else={
:set dynHostStatus "ERROR Update4"
:set msg "$LogHeader : Update ERROR IPv4 $dynHost $CurrentIP4 response: $Response"
:log error "$msg"
:error "$msg"
}
:delay 1;
:do {
:set msg "$LogHeader : Current IPv4 updated $CurrentIP4 for $dynHost ($Response)"
#:log info "$msg"
#:put "$msg"
/tool e-mail send to=$email subject="$msg"
} on-error={
:log warning "$LogHeader : WARNING email send failed"
#:set dynHostStatus "WARNING Email4"
}
} else={
:set msg "$LogHeader : Current IPv4 $CurrentIP4 match Registered $RegisteredIP4"
:log info "$msg"
:put "$msg"
}
# skipIPv6 update
:if ($skipIP6 = "true") do={
:set msg "$LogHeader : skipIP6 defined, exiting"
:log info "$msg"
:return "$msg"
}
:if ($RegisteredIP6 != $CurrentIP6) do={
:set msg "$LogHeader : Current IPv6 $CurrentIP6 not match Registered $RegisteredIP6, updating"
:log info "$msg"
:put "$msg"
:local UpdateUrl "https://dns.eu.ovhapis.com/nic/update?system=dyndns&hostname=$dynHost&myip=$CurrentIP6";
#:set msg "Query IPv6 URL : $UpdateUrl"
#:log info "$msg"
#:put "$msg"
:local Header "Authorization: Basic $Base64Auth";
#:put "Header: $Header";
#:put "Fetching...";
#/tool fetch url=$UpdateUrl http-header-field=$Header mode=https dst-path=$FileTmp6;
:local Response ([/tool fetch url=$UpdateUrl http-header-field=$Header output=user as-value]->"data")
:if (([:pick $Response 0 5] = "good ") || ([:pick $Response 0 5] = "nochg")) do={
:if ($dynHostStatus = "UPDATE4") do={
:set dynHostStatus "UPDATE46"
} else={
:set dynHostStatus "UPDATE6"
}
:set msg "$LogHeader : Updated IPv6 $dynHost $CurrentIP6"
:log info "$msg"
:put "$msg"
} else={
:set dynHostStatus "ERROR Update6"
:set msg "$LogHeader : Update ERROR IPv6 $dynHost $CurrentIP6 response: $Response"
:log error "$msg"
:error "$msg"
}
:delay 1;
:do {
:set msg "$LogHeader : Current IPv6 updated $CurrentIP6 for $dynHost ($Response)"
#:log info "$msg"
#:put "$msg"
/tool e-mail send to=$email subject="$msg"
} on-error={
:log warning "$LogHeader : WARNING email send failed"
#:set dynHostStatus "WARNING Email6"
}
} else={
:set msg "$LogHeader : Current IPv6 $CurrentIP6 match Registered $RegisteredIP6"
:log info "$msg"
:put "$msg"
}