# OpenDNS IP Update Script

**URL:** <https://forum.mikrotik.com/t/opendns-ip-update-script/178349>\
**Category:** Scripting\
**Created:** [August 28, 2024, 5:45pm UTC](https://forum.mikrotik.com/t/opendns-ip-update-script/178349 "2024-08-28T17:45:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefan2600](https://forum.mikrotik.com/letter_avatar/stefan2600/32/6_449c533f586939b6e5f246632a46421f.png) [@stefan2600](https://forum.mikrotik.com/u/stefan2600)\
**Post date:** [August 28, 2024, 5:45pm UTC](https://forum.mikrotik.com/t/opendns-ip-update-script/178349/1 "2024-08-28T17:45:20Z")

</div>

Hello @ all,

i have a problem with a script. I have an Mikrotik OS 7.13 and i will update my wan ip to opendns home. I used this script:  
#--------------- Change Values in this section to match your setup ------------------

# User account info of OpenDNS

# Update-only password (obtained from OpenDNS Support). With two-factor authentication enabled, the use of an update only password is required.

:local odnsuser "[email@address.com](mailto:email@address.com)"  
:local odnspass "update-only-password"

# Set the hostname or label of network to be updated. This is the name of your OpenDNS network on the Dashboard.

# Hostnames with spaces are unsupported. Replace the value in the quotations below with your host name.

# Only one host is supported

# Use "[all.dnsomatic.com](http://all.dnsomatic.com)" for the matichost to update all items in dnsomatic with this IP.

# Note, you must have admin or edit (Read/Write/Grant in the OpenDNS Dashboard) to update IP addresses.

:local odnshost "networkname"

# Change to the name of interface that gets the changing IP address

# May not be needed for your model number - commenting out this line may still work for single interface devices or if this is not supplied in the DNS-O-Matic script currently being used

:local inetinterface "ether1"

#------------------------------------------------------------------------------------

# No more changes needed, one optional change

:global previousIP;

:log info "Fetching current IP"

# Get the current public IP using DNS-O-Matic service.

/tool fetch url="[http://myip.dnsomatic.com/](http://myip.dnsomatic.com/)" mode=http dst-path=mypublicip.txt

# Read the current public IP into the currentIP variable.

:local currentIP [/file get mypublicip.txt contents]

:log info "Fetched current IP as $currentIP"

# --------- Optional check to only run if the IP has changed (one line: :if)

# to enable, set line below to: ":if ($currentIP != $currentIP) do={"

:if ($currentIP != 1) do={  
:log info "OpenDNS: Update needed"  
:set previousIP $currentIP

# The update URL. Note the "\3F" is hex for question mark (?). Required since ? is a special character in commands.

# Some older editions of the MicroTik/WinBox OS require the following line instead (http) whereas newer versions require https.

# :local url "[http://updates.opendns.com/nic/update\3Fhostname=$odnshost](http://updates.opendns.com/nic/update%5C3Fhostname=$odnshost)"

:local url "[https://updates.opendns.com/nic/update\3Fhostname=$odnshost](https://updates.opendns.com/nic/update%5C3Fhostname=$odnshost)"  
:log info "OpenDNS: Sending update for $odnshost"

/tool fetch url=($url) user=$odnsuser password=$odnspass mode=http dst-path=("/net\_odns.txt")

:delay 2;

:local odnsReply [/file get net\_odns.txt contents];

:log info "OpenDNS update complete."

:log info "OpenDNS reply was $odnsReply";

} else={

:log info "OpenDNS: Previous IP $previousIP and current IP equal, no update need"  
}

I change to begin on the script my User, Password and Networkname. ether1 is the name for my outpout port. When i run this script, i get a message in the log files:  
executing script script1 from www failed, please check it manually

Please can someone help me? Sorry, my english is not very good.

Greatings Stefan

---

<div class="post-metadata">

**Author:** ![stefan2600](https://forum.mikrotik.com/letter_avatar/stefan2600/32/6_449c533f586939b6e5f246632a46421f.png) [@stefan2600](https://forum.mikrotik.com/u/stefan2600)\
**Post date:** [August 29, 2024, 4:54pm UTC](https://forum.mikrotik.com/t/opendns-ip-update-script/178349/2 "2024-08-29T16:54:33Z")

</div>

I was now able to find the problem myself.  
In this line  
/tool ​​fetch url=($url) user=$odnsuser password=$odnspass mode=http dst-path=(“/net\_odns.txt”) you just have to replace mode=http with mode=https and the IP address is then passed on to Open DNS.
