Community discussions

MikroTik App
 
shampoleya
just joined
Topic Author
Posts: 7
Joined: Mon Feb 27, 2012 1:51 am

DNS-O-Matic update script problem

Mon Feb 27, 2012 2:13 am

i use MikroTiK v3.30, i used that script below to update my IP for DNS-O-Matic for along time and it worked fine
since just 2 days ago, it doesn't work fine ; every time i run it ; its stopped at (sending update)
please, help me to solve this problem
# DNSoMatic automatic DNS updates
# User account info of DNSoMatic
:global maticuser "user"
:global maticpass "password"
:global matichost ""
# No more changes need

:global previousIP

# Print values for debug
:log info "DNSoMatic: Updating dynamic IP on DNS for host $matichost"
:log info "DNSoMatic: User $maticuser y Pass $maticpass"
:log info "DNSoMatic: Last IP $previousIP"

# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
:local result [/file get dyndns.checkip.html contents]

# parse the current IP result
:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local endLoc [:find $result "</body>" -1]
:global currentIP [:pick $result $startLoc $endLoc]
:log info "DNSoMatic: IP actual $currentIP"

# Touching the string passed to fetch command on "src-path" option
:local str "/nic/update?hostname=$matichost&myip=$currentIP&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"

:if ($currentIP != $previousIP) do={
:log info "DNSoMatic: Update need"
:set previousIP $currentIP
:log info "DNSoMatic: Sending update $currentIP"
:log info [ :put [/tool fetch host=MT user=$maticuser password=$maticpass mode=http address="updates.dnsomatic.com" src-path=$str dst-path=$matichost]]
:log info "DNSoMatic: Host $matichost updated on DNSoMatic with IP $currentIP"
}  else={
:log info "DNSoMatic: Previous IP $previousIP and current $currentIP equal, no update need"
}
 
User avatar
elgo
Member Candidate
Member Candidate
Posts: 151
Joined: Sat Apr 02, 2011 2:34 am
Location: France

Re: DNS-O-Matic update script problem

Tue Feb 28, 2012 12:19 pm

Credentials as global variables... seriously?
Do you usually set your passwords as an environnement variable?
 
shampoleya
just joined
Topic Author
Posts: 7
Joined: Mon Feb 27, 2012 1:51 am

Re: DNS-O-Matic update script problem

Tue Feb 28, 2012 3:32 pm

actually, i didn't write this script my self , i copied it from this link
http://wiki.mikrotik.com/wiki/Dynamic_D ... behind_NAT
and then i changed username,password as mine , and it worked fine but now i didn't know whats happened !!!
 
shampoleya
just joined
Topic Author
Posts: 7
Joined: Mon Feb 27, 2012 1:51 am

Re: DNS-O-Matic update script problem

Tue Feb 28, 2012 7:22 pm

finally, I've found the solution for this problem
it simplicity exist in this line
:log info [ :put [/tool fetch host=MT user=$maticuser password=$maticpass mode=http address="updates.dnsomatic.com" src-path=$str

we must chane host to "updates.dnsomatic.com" to be like that --> host=updates.dnsomatic.com instead of host=MT
 
offmynet
just joined
Posts: 2
Joined: Wed Jun 09, 2010 1:27 am

Re: DNS-O-Matic update script problem

Thu Mar 15, 2012 11:27 pm

Thank you shampoleya, I had the same problem and now with your solution it works perfect.