Community discussions

 
sploit
just joined
Topic Author
Posts: 4
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: 4
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: 1776
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: 4
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: 1776
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: 4
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

Who is online

Users browsing this forum: No registered users and 11 guests