Community discussions

MikroTik App
 
nachannon
just joined
Topic Author
Posts: 6
Joined: Wed Dec 30, 2020 6:26 pm

ROS v7 wont update changeip script

Thu Jan 06, 2022 8:34 pm

I recently updated my router to ver7 and now my DDNS script no longer will update my public address ver6 worked fine. I have debugged the script as far as
# :log info [/tool dns-update name=$ddnshost address=$ddnsip key-name=$ddnsuser key=$ddnspass ] // worked fine in ver6
:log info  [/tool dns-update address=[:pick $ddnsip0 [:find $ddnsip "/"]] dns-server=$DNSServer name=$ddnshost  key=$ddnspass key-name=$ddnsuser ttl=64 zone="user.changeip.net"]
seems im not understanding the zone and dns-server values can anyone help out as to what i must do in ver7 to make this script work.
:global ddnsuser "info@user.com"
:global ddnspass "user21#"
:global ddnshost "user.changeip.net"
:local ddnsport 80
:global ddnscheckpoint
:local mydns [/ip dns get dynamic-servers]
:global DNSServer  "170.178.190.178"
# [:pick $mydns 0]
:if ([:typeof $ddnscheckpoint] = "time") do={
 :log info ("DDNS: Last check was " . ([/system clock get time] - $ddnscheckpoint))
} else={
 :log info "DDNS: Cannot determine checkpoint, set now."
 :global ddnscheckpoint ( [/system clock get time] - 1d )
}
  
# Get the current IP
:if ([/system clock get time] - $ddnscheckpoint > [:totime 180s] || [/system clock get time] - $ddnscheckpoint < [:totime 0s]) do={
 :log info "DDNS: Performing remote IP detection."
 /tool fetch address="ip.changeip.com" host="ip.changeip.com" src-path=("/?" . [/int eth get 0 mac-address ]) dst-path="ip.changeip.com.txt" mode=http port=$ddnsport
 :global ddnscheckpoint [/system clock get time]
} else={
 :log info "DDNS: Please be considerate and wait a few seconds longer."
 :break
}

# Parse the IP address received from fetch script.
 :global ddnslastip
 :local html [/file get "ip.changeip.com.txt" contents]
 :local ddnsip [:pick $html ([:find $html "<!--IPADDR="] + 11) [:find $html "-->"] ]
 
# Is it a valid IP and is it different than the last one?
 :if ([:typeof [:toip $ddnsip]] = "ip" AND $ddnsip != $ddnslastip ) do={
 :log info "DDNS: Sending UPDATE with $ddnsip"
# :log info [/tool dns-update name=$ddnshost address=$ddnsip key-name=$ddnsuser key=$ddnspass ]
:log info  [/tool dns-update address=[:pick $ddnsip0 [:find $ddnsip "/"]] dns-server=$DNSServer name=$ddnshost  key=$ddnspass key-name=$ddnsuser ttl=64 zone="user.changeip.net"]
 :global ddnslastip $ddnsip
 } else={
 :log info "DDNS: No update required."
 }
}

thanks
Nigel
 
w0lt
Long time Member
Long time Member
Posts: 537
Joined: Wed Apr 02, 2008 2:12 pm
Location: Minnesota USA

Re: ROS v7 wont update changeip script

Fri Jan 07, 2022 1:30 am

I recently updated my router to ver7 and now my DDNS script no longer will update my public address ver6 worked fine. I have debugged the script as far as
# :log info [/tool dns-update name=$ddnshost address=$ddnsip key-name=$ddnsuser key=$ddnspass ] // worked fine in ver6
:log info  [/tool dns-update address=[:pick $ddnsip0 [:find $ddnsip "/"]] dns-server=$DNSServer name=$ddnshost  key=$ddnspass key-name=$ddnsuser ttl=64 zone="user.changeip.net"]
seems im not understanding the zone and dns-server values can anyone help out as to what i must do in ver7 to make this script work.
:global ddnsuser "info@user.com"
:global ddnspass "user21#"
:global ddnshost "user.changeip.net"
:local ddnsport 80
:global ddnscheckpoint
:local mydns [/ip dns get dynamic-servers]
:global DNSServer  "170.178.190.178"
# [:pick $mydns 0]
:if ([:typeof $ddnscheckpoint] = "time") do={
 :log info ("DDNS: Last check was " . ([/system clock get time] - $ddnscheckpoint))
} else={
 :log info "DDNS: Cannot determine checkpoint, set now."
 :global ddnscheckpoint ( [/system clock get time] - 1d )
}
  
# Get the current IP
:if ([/system clock get time] - $ddnscheckpoint > [:totime 180s] || [/system clock get time] - $ddnscheckpoint < [:totime 0s]) do={
 :log info "DDNS: Performing remote IP detection."
 /tool fetch address="ip.changeip.com" host="ip.changeip.com" src-path=("/?" . [/int eth get 0 mac-address ]) dst-path="ip.changeip.com.txt" mode=http port=$ddnsport
 :global ddnscheckpoint [/system clock get time]
} else={
 :log info "DDNS: Please be considerate and wait a few seconds longer."
 :break
}

# Parse the IP address received from fetch script.
 :global ddnslastip
 :local html [/file get "ip.changeip.com.txt" contents]
 :local ddnsip [:pick $html ([:find $html "<!--IPADDR="] + 11) [:find $html "-->"] ]
 
# Is it a valid IP and is it different than the last one?
 :if ([:typeof [:toip $ddnsip]] = "ip" AND $ddnsip != $ddnslastip ) do={
 :log info "DDNS: Sending UPDATE with $ddnsip"
# :log info [/tool dns-update name=$ddnshost address=$ddnsip key-name=$ddnsuser key=$ddnspass ]
:log info  [/tool dns-update address=[:pick $ddnsip0 [:find $ddnsip "/"]] dns-server=$DNSServer name=$ddnshost  key=$ddnspass key-name=$ddnsuser ttl=64 zone="user.changeip.net"]
 :global ddnslastip $ddnsip
 } else={
 :log info "DDNS: No update required."
 }
}

thanks
Nigel

Mine doesn't work either.
I would really like to know what's broke in the script.
I've spent way too much time trying to get it to work.
I wish ROS had a script editor that you could step through each line one at a time to find out at least where it stopped.

-tp
 
nachannon
just joined
Topic Author
Posts: 6
Joined: Wed Dec 30, 2020 6:26 pm

Re: ROS v7 wont update changeip script

Fri Jan 07, 2022 1:44 pm

Well at least I'm not alone with this problem I dont know why mikrotix have to change things around in ver7 when they have been working perfectly for years in ver6 very frustrating and the documentation is not very clear in ver7.
I debuged it to this line
:log info  [/tool dns-update address=[:pick $ddnsip0 [:find $ddnsip "/"]] dns-server=$DNSServer name=$ddnshost  key=$ddnspass key-name=$ddnsuser ttl=64 zone="user.changeip.net"]
This is where the script stops executing with little or no log info as to what's happened. Hopfully someone here can put some light on the problem.

Nigel
 
Sob
Forum Guru
Forum Guru
Posts: 9121
Joined: Mon Apr 20, 2009 9:11 pm

Re: ROS v7 wont update changeip script

Fri Jan 07, 2022 8:42 pm

From what I see, dns-update in v6 has undocumented support for changeip.com. You can omit "dns-server" and "zone" parameters and router then sends some request to https://nic.changeip.com, instead of doing regular DNS update (= request to DNS server on port 53). In v7, this was either removed, or "dns-server" and "zone" were made mandatory by mistake. Only MikroTik knows which one it is.

I'm not familiar with changeip.com, but at first sight I see only http(s) based API. So it doesn't seem that you'll get far with dns-update. But you can switch to http(s) updates, as described in dns-update on 7.1.1. I recommend using https, for which you'll need to import root certificate used by changeip server.
 
nachannon
just joined
Topic Author
Posts: 6
Joined: Wed Dec 30, 2020 6:26 pm

Re: ROS v7 wont update changeip script

Sat Jan 08, 2022 6:45 pm

Hi Sob thanks very much for the pointer I have it working again now using https
for any one that needs a working script
:global ddnsuser "info@blabla.com"
:global ddnspass "password"
:global ddnshost "blabla.changeip.net"
:local ddnsport 80
:global ddnscheckpoint
:local mydns [/ip dns get dynamic-servers]

:if ([:typeof $ddnscheckpoint] = "time") do={
 :log info ("DDNS: Last check was " . ([/system clock get time] - $ddnscheckpoint))
} else={
 :log info "DDNS: Cannot determine checkpoint, set now."
 :global ddnscheckpoint ( [/system clock get time] - 1d )
}
  
# Get the current IP
:if ([/system clock get time] - $ddnscheckpoint > [:totime 180s] || [/system clock get time] - $ddnscheckpoint < [:totime 0s]) do={
 :log info "DDNS: Performing remote IP detection."
 /tool fetch address="ip.changeip.com" host="ip.changeip.com" src-path=("/?" . [/int eth get 0 mac-address ]) dst-path="ip.changeip.com.txt" mode=http port=$ddnsport
 :global ddnscheckpoint [/system clock get time]
} else={
 :log info "DDNS: Please be considerate and wait a few seconds longer."
 :break
}

# Parse the IP address received from fetch script.
 :global ddnslastip
 :local html [/file get "ip.changeip.com.txt" contents]
 :local ddnsip [:pick $html ([:find $html "<!--IPADDR="] + 11) [:find $html "-->"] ]
 
# Is it a valid IP and is it different than the last one?
 :if ([:typeof [:toip $ddnsip]] = "ip" AND $ddnsip != $ddnslastip ) do={
 :log info "DDNS: Sending UPDATE with $ddnsip"
 :local ddnsurl ("https://nic.ChangeIP.com/nic/update\3Fip=" . $ddnsip . "&hostname=" . $ddnshost)
 /tool fetch url=$ddnsurl user=$ddnsuser password=$ddnspass dst-path=ddns-res.txt
  :global ddnslastip $ddnsip
 :log info "DDNS:  Updated with $ddnsip"
 } else={
 :log info "DDNS: No update required."
 }
}
As Sob suggested for https easy way is to just open webbrowser goto https://nic.changeip.com/nic/update enter your username and password then click on screen and select inspect from drop down menu go to security tab select view certificate then just follow onscreen instructions to export the cert to your drive then open winbox and drag the cert file to Files in winbox. Once you have done that go to system / certificates and import. I tested the script and my DDNS updated fine. Im only assuming I imported the certificate correctly as it works but I was unsure regarding check-certificate=yes
Thanks again Sob
Regards
Nigel
 
Sob
Forum Guru
Forum Guru
Posts: 9121
Joined: Mon Apr 20, 2009 9:11 pm

Re: ROS v7 wont update changeip script

Sat Jan 08, 2022 7:04 pm

Two things:

- Be sure to get the root certificate named "USERTrust RSA Certification Authority". If you'd get site's certificate for *.changeip.com, it's only valid for a year and current one expires in four months, so you would need to keep getting new ones. If you get the root certificate, its expiration is in 2038, so as long as changeip doesn't change CA, it will work for many years.

- You want check-certificate=yes for fetch, because it doesn't verify certificates by default. Without this option, you can as well not bother with installing any certificate, because it's equally insecure.
 
x7007
just joined
Posts: 5
Joined: Thu Feb 19, 2015 4:57 pm

Re: ROS v7 wont update changeip script

Sun Sep 17, 2023 4:18 am

Hi, where do I put the check-certificate=yes and where do I see the UserTrust RSA? because I have ESET and it shows me as ESET

Who is online

Users browsing this forum: No registered users and 55 guests