Community discussions

MUM Europe 2020
 
sploit
just joined
Topic Author
Posts: 5
Joined: Sat Oct 19, 2013 8:53 pm

OVH.com Dynamic DNS Service update script

Fri Jul 28, 2017 8:49 pm

If anyone is interested, I made (read modified DynDNS script) an update script for the OVH.com Dynamic DNS Service. Feel free to use, copy, modify, re-publish.

https://github.com/acidsploit/mikrotik-routeros-scripts
:global ovhddnsuser "<OVH DynDNS USER>"
:global ovhddnspass "<OVH DynDNS PASS>"
:global theinterface "<INTERFACE THAT HAS YOUR PUBLIC IP>"
:global ovhddnshost "<OVHDynDNS HOSTNAME>"
:global ipddns [:resolve $ovhddnshost]
:global ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ]
:if ([ :typeof $ipfresh ] = nil ) do={
   :log info ("OVHDynDNS: NO IP address on $theinterface")
} else={
   :for i from=( [:len $ipfresh] - 1) to=0 do={ 
      :if ( [:pick $ipfresh $i] = "/") do={ 
    :set ipfresh [:pick $ipfresh 0 $i]
      } 
}
 
:if ($ipddns != $ipfresh) do={
   :log info ("OVHDynDNS: $ovhddnshost DNS RECORD IP = $ipddns")
   :log info ("OVHDynDNS: $theinterface CURRENT IP = $ipfresh")
   :log info ("OVHDynDNS: UPDATING $ovhddnshost -> $ipfresh")
   :global str "nic/update?system=dyndns&hostname=$ovhddnshost&myip=$ipfresh&wildcard=OFF&backmx=NO&mx=NOCHG"

   # DEBUG fetch command
   #:log info ("OVHDynDNS: /tool fetch address=www.ovh.com host=www.ovh.com src-path=$str mode=https user=$ovhddnsuser password=$ovhddnspass dst-path=(\"/OVHDynDNS.$ovhddnshost\")")
   /tool fetch address=www.ovh.com host=www.ovh.com src-path=$str mode=https user=$ovhddnsuser password=$ovhddnspass dst-path=("/OVHDynDNS.".$ovhddnshost)
   :delay 1

   :global ovhresult [/file get "OVHDynDNS.$ovhddnshost" contents]
   :log info "OVHDynDNS: OVH response: $ovhresult"

   :global str [/file find name="OVHDynDNS.$ovhddnshost"]
   /file remove $str
   
   :if ($ovhresult = "good $ipfresh\n" ) do={
      :log info "OVHDynDNS: SUCCESS"
   } else={
       :log info "OVHDynDNS: FAILED"
   }

   :global ipddns $ipfresh
   :log info "OVHDynDNS: $ovhddnshost DNS RECORD = $ipfresh!"
    } else={
     :log info "OVHDynDNS: We good!"
    }
}
Maybe publish this on the wiki, it could be useful for future reference.

Cheers!
 
mniewiera
just joined
Posts: 6
Joined: Wed Dec 27, 2017 4:52 pm

Re: OVH.com Dynamic DNS Service update script

Sat Jan 06, 2018 3:52 pm

Thanks sploit for the script!
I just found out that OVH has this dynhost option and i thought it would be perfect to use with a mikrotik script.
I'll give it a try later.
Thanks again!
 
User avatar
sebastia
Forum Guru
Forum Guru
Posts: 1796
Joined: Tue Oct 12, 2010 3:23 am
Location: Antwerp, BE

Re: OVH.com Dynamic DNS Service update script

Sat Jan 06, 2018 10:07 pm

Some constructive criticism: all these :global could be changed to :local. There is no need to store "state" between runs.
 
mniewiera
just joined
Posts: 6
Joined: Wed Dec 27, 2017 4:52 pm

Re: OVH.com Dynamic DNS Service update script

Sat Jan 06, 2018 10:59 pm

Some constructive criticism: all these :global could be changed to :local. There is no need to store "state" between runs.
So i can just replace the :global with :local ?
I'm not very good at scripting and very new to mikrotik ;-)
 
User avatar
sebastia
Forum Guru
Forum Guru
Posts: 1796
Joined: Tue Oct 12, 2010 3:23 am
Location: Antwerp, BE

Re: OVH.com Dynamic DNS Service update script

Tue Jan 09, 2018 12:09 am

Correct, and you could clean up your environment (/system/scripts/environment) of these variables.
 
mniewiera
just joined
Posts: 6
Joined: Wed Dec 27, 2017 4:52 pm

Re: OVH.com Dynamic DNS Service update script

Sat Jan 20, 2018 9:25 am

Thanks!
This works very well.
I think in a further step i'm going to remove the "OVHDynDNS: We good!" message if the update was successful.
This is spamming my log/syslog server very much ;-)
 
Maxke
just joined
Posts: 9
Joined: Sun Jan 13, 2019 10:27 pm

Re: OVH.com Dynamic DNS Service update script

Sun Jan 13, 2019 10:29 pm

Hi,

I'm new here.
Can you tell me what to do if the router is behind een modem ?
So my router has no external ip adres.

Thanks
 
User avatar
kinx
just joined
Posts: 9
Joined: Mon Sep 04, 2017 9:16 pm
Location: 127.0.0.1
Contact:

Re: OVH.com Dynamic DNS Service update script

Wed Oct 30, 2019 4:10 pm

I had a custom domain at Dyn (DynDNS) which has now been taken over by Oracle. And I'm very disappointed they are ending custom dynamic domains as of next year in March.
I'm keeping a Dyn account for legacy old clients, but I'm moving all my other more recent customers that need Dynamic DNS to OVH DynHost.

Can someone modify this script so it fetches the external IP (not from the eth1 / wan interface), since the MikroTik eth1/wan interface doesn't always have an external IP...
I saw another 'DynDNS' script here first getting the external IP from an OpenDNS website. https://diagnostic.opendns.com/myip
But I could also make my own website instead of OpenDNS for example...

Found another ipv4 checker from Google. https://domains.google.com/checkip
 
sploit
just joined
Topic Author
Posts: 5
Joined: Sat Oct 19, 2013 8:53 pm

Re: OVH.com Dynamic DNS Service update script

Wed Nov 06, 2019 10:38 am

I had a custom domain at Dyn (DynDNS) which has now been taken over by Oracle. And I'm very disappointed they are ending custom dynamic domains as of next year in March.
I'm keeping a Dyn account for legacy old clients, but I'm moving all my other more recent customers that need Dynamic DNS to OVH DynHost.

Can someone modify this script so it fetches the external IP (not from the eth1 / wan interface), since the MikroTik eth1/wan interface doesn't always have an external IP...
I saw another 'DynDNS' script here first getting the external IP from an OpenDNS website. https://diagnostic.opendns.com/myip
But I could also make my own website instead of OpenDNS for example...

Found another ipv4 checker from Google. https://domains.google.com/checkip
Here is a nifty trick for nginx to make a simple checkip service:
location = / {                                         
        add_header Content-Type text/plain; return 200 $remote_addr;                                                   
    }

Then doing:
curl myip.mydomain.com

Will give you your public ip. I don't think it can be done any more simple.

Who is online

Users browsing this forum: MSN [Bot] and 17 guests