Page 1 of 1

opendns with dynamic ip

Posted: Sat Aug 30, 2008 8:44 pm
by RFischer
I would like to have a script to update opendns.com with my router's dynamic ip. Has anyone tried (failed or not) to do this on the router? I know I could just run a updater on a computer on the lan, but I would really like to do it on the router. I am successfuly using the changeIP.com script to update a host name, and would like to add opendns update to that script since it is already figuring out if the ip address has changed and that an update is needed.

I don't have any idea how to relate OpenDNS URL to send updates and the DynDNS api information.
Even if that was understood, I am not sure if you can or how to say:

"https://updates.opendns.com/nic/update?hostname= something??" in a script.

link to opendns support about their API.
http://www.opendns.com/support/article/88

link to DNS update API from DynDNS which is what OpenDNS uses.
http://www.dyndns.com/developers/specs/syntax.html

Re: opendns with dynamic ip

Posted: Sun Aug 31, 2008 5:54 am
by changeip
we are adding the ability to update opendns when we receive a ddns update. we already have this built into our windows client. we plan on getting that working on the mikrotik ddns update script (server side) shortly. There will be a place within your account on changeip.com that will let you setup the auxillary update to opendns.

Re: opendns with dynamic ip

Posted: Mon Sep 01, 2008 1:54 am
by RFischer
That is great. Thanks.

Does this mean also that it is not possible to do this in a script on the router directly? My guess is that the requirement for SSL support on the client side would keep anything fairly easy to do from happening. I envisioned some sort of "telnet port 443" kind of thing.

Re: opendns with dynamic ip

Posted: Mon Sep 01, 2008 12:45 pm
by hilton
we are adding the ability to update opendns when we receive a ddns update. we already have this built into our windows client. we plan on getting that working on the mikrotik ddns update script (server side) shortly. There will be a place within your account on changeip.com that will let you setup the auxillary update to opendns.
Sam, this is brilliant news. I really look forward to this. If you need a beta tester, just shout.

Re: opendns with dynamic ip

Posted: Mon Oct 13, 2008 5:07 pm
by RFischer
I am still wondering if there is any way to support this directly from Router OS.
I am also very interested in being able to accomplish this no mater how it is done.
ChangeIP support would be a great way. Any progress on that front?

Re: opendns with dynamic ip

Posted: Mon Oct 13, 2008 8:23 pm
by changeip
nothing yet... once i file my taxes I will have more time :)

Re: opendns with dynamic ip

Posted: Fri Nov 28, 2008 10:23 am
by superrouter
Hi, Please let me know when you've done the opendns integration changeip , I use the changeip service and its awesome, gonna be even better with opendns support ! yay!

Re: opendns with dynamic ip

Posted: Sat Jul 04, 2009 12:14 am
by khaloudy
i have mikrotik 2.9.27
i want use this (((((schedule))))
to send to openDNS the Update for my daynmic Ip
itry this scripts in 5 mintes and not working

wget -O - -q --http-user=khaloudy --http-passwd=123456 https://updates.opendns.com/nic/update

and this

USER=khaloudy
PASS=123456
NETWORK_LABEL=home
/usr/bin/curl -k -m 60 -u $USER:$PASS https://updates.opendns.com/nic/update? ... WORK_LABEL > /dev/null

can u help me?
thank you

Re: opendns with dynamic ip

Posted: Sat Jul 04, 2009 12:25 am
by hilton
i have mikrotik 2.9.27
First upgrade to an authentic version, then ask questions.

Re: opendns with dynamic ip

Posted: Tue Jul 14, 2009 6:17 am
by khaloudy
i upgrade my mikrotk
i am using now 3.22
how i can update opendns with dynamic ip
opendns.com say:
============================================
hxxps://username:password@updates.opendns.com/nic/update?hostname=network label
(replace xx with tt)

username = your username
password = your password
network label = your network label
-----------------------------------------------------------
i don't understand how?
plz help me

Re: opendns with dynamic ip

Posted: Tue Jul 14, 2009 2:25 pm
by Letni
This can _not_ directly be done on RouterOS because the fetch command does not support HTTPS.

-Louis

Re: opendns with dynamic ip

Posted: Mon Jul 20, 2009 7:37 am
by khaloudy
so
you want to say that foget
mikrotik will not work with OpenDNS?
i get mikrotik server for this only
to save my family
no other way to stop porno or adult cites?
if he will not help me
i am not needed too
most of arab user the same
best regards

Re: opendns with dynamic ip

Posted: Mon Oct 12, 2009 7:23 am
by elnagar_ali
realy i need this script

Re: opendns with dynamic ip

Posted: Mon Oct 12, 2009 8:09 am
by changeip
okay okay... i will try to make this a higher priority for us. We will relay an update to opendns upon an update to changeip.com ddns. however, i need to clear this with them first as they would start seeing a lot of updates coming from our single network. need to make sure its okay.

Re: opendns with dynamic ip

Posted: Mon Oct 12, 2009 10:29 pm
by hilton
Brilliant, thanks Sam.

Re: opendns with dynamic ip

Posted: Fri Oct 30, 2009 2:04 pm
by hilton
okay okay... i will try to make this a higher priority for us. We will relay an update to opendns upon an update to changeip.com ddns. however, i need to clear this with them first as they would start seeing a lot of updates coming from our single network. need to make sure its okay.
Sam, any news on this? I see OpenDNS have launched their Enterprise content filter and I'd like to sell this service but I need routeros/changeip/opendns to all work together.

Cheers

Re: opendns with dynamic ip

Posted: Fri Oct 30, 2009 6:39 pm
by changeip
I am waiting on David from their to give me the okay to start proxying updates to them. They have a special server for me to use as if I used the public one it would get blocked because of the number of updates that will start hitting them.

Sam

Re: opendns with dynamic ip

Posted: Sat Oct 31, 2009 6:09 pm
by xskid
realy i need this script
I also need the option to schedule this:
https://myaccount:mypassword@updates.op ... me=network

Re: opendns with dynamic ip

Posted: Sat Jan 09, 2010 3:45 am
by cossil
Sam, any news on this?

Re: opendns with dynamic ip

Posted: Thu Mar 25, 2010 7:54 pm
by grescho
I am also following this thread with bated breath... any news? I don't know about others, but I would be happy to pay for this service.

Re: opendns with dynamic ip

Posted: Fri Mar 26, 2010 11:19 am
by hilton
I've since discovered that their content filtering service isn't all that it's cracked up to be.

From my brief googling, there appears to be a distinct lack of cloud based web content filters out their with reasonable granular settings at a fair price.

For the moment, I'm just going to install DansGuardian.

how to assign dynamic address to mikrotik router

Posted: Thu May 06, 2010 4:20 pm
by rsrinivashan
hi this is srinivashan

My ISP use following method for connect users to Internet:

my wan Ethernet interface of router connected to service provider with dhcp .

i just want to know that how to configure the wan interface to recive dynamic address.

please let me if any one know .and please let me know with the commands

thanks in Advance

thanks & regards
srinivashan
cnus01@gmail.com

Re: opendns with dynamic ip

Posted: Fri May 07, 2010 10:31 am
by janisk
rsrinivashan, add dhcp-client on your wan interface to get dynamic address from your ISP

Re: opendns with dynamic ip

Posted: Fri May 07, 2010 10:46 am
by rsrinivashan
i got it janisk, thanks a lot for ur replay


thanks srinivashan

Re: opendns with dynamic ip

Posted: Sat May 08, 2010 11:49 am
by t3wera
try this
# DNSoMatic automatic DNS updates
# User account info of DNSoMatic
:global maticuser "GmailAccount"
:global maticpass "PWD"
: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"
}

but u must go https://www.dnsomatic.com/account/ and put ur open info

Re: opendns with dynamic ip

Posted: Tue Jun 01, 2010 12:21 am
by ibeeby
The above script did most but not all of the work needed - the :global previousIP was not retained by 4.9 so I put in some additional code, using the same variables as the similar section to parse the result gathered from the web.

This script _does_ work for me using 4.9 - the remaining issue is that OpenDNS takes several minutes to update, during which time the script, if repeated at, say, 120s intervals, will try several times to update.

Anyone know how to put in a delay in a script - ideally the script will run every, say, 60s but then wait before completing after an update attempt for, say, 5 minutes to allow the updates to propagate...

# DNSoMatic Account Information
:global maticuser "<username>"
:global maticpass "password"
:global matichost "hostname"
# End of Account Information

:global previousIP

# Recover previous IP address from file
:local result [/file get $matichost contents]
:local resultLen [:len $result]
:local startLoc [:find $result "d " -1]
:set startLoc ($startLoc + 2)
:set previousIP [:pick $result $startLoc $resultLen]

# Print values for debug
:log info "DNSoMatic: Updating dynamic ip on DNS for $matichost"
# :log info "DNSoMatic: User: $maticuser ; Password: $maticpass"
:log info "DNSoMatic: Last ip address: $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 results
: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 needed"
:set previousIP $currentIP
:log info "DNSoMatic: Sending update to $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 IP $currentIP are equal: No update needed"
}

All I have done is to fix this - credit due to the original author, 't3wera', for getting it off the ground...

Ian

Re: opendns with dynamic ip

Posted: Tue Jun 01, 2010 9:37 am
by janisk
delay in script:
:delay <delay-time> -- time interval (default 1 second)

Re: opendns with dynamic ip

Posted: Tue Jun 01, 2010 10:30 am
by ibeeby
Ah yes - thanks janisk - I've added the line:

:delay 300s

before the line:

} else={

which _should_ delay termination of the script for 5 minutes - BUT it does not prevent the scheduler from ploughing ahead with the next execution after 2 minutes. However, on a quick test, this does seem to have worked as on the first occasion when the ip changed, the script ran and 2 minutes later it ran again reporting no changes needed - or maybe this is just because the DNS servers are less busy in the European morning...

Not fully conclusive.

The reason for trying to execute the script frequently is that in this case OpenDNS is being used to restrict user activity (no porn etc) and if the ip address changes then there will be a window when the OpenDNS settings will not apply until the addresses are re-synchronised. The internet connection is by way of a 3G link and so it has been found that on some days the ip address does change several times.

If this were a relatively stable xDSL connection, I'd be less bothered and perhaps just execute the script every five minutes...

Thoughts?

Re: opendns with dynamic ip

Posted: Thu Jul 01, 2010 2:35 pm
by zero
hi, im looking for a script to update my local ip table

i have local and international internet split by two ethernet ports
i have the local ip table, but need script to update it if there is new ip's

below is example of table:

/ip route remove [/ip route find gateway="adslLOCAL" static=yes]
/ip route add dst-address=41.0.0.0/11 gateway=adsllan1
/ip route add dst-address=41.75.224.0/20 gateway=adsllan1
/ip route add dst-address=41.77.232.0/21 gateway=adsllan1
/ip route add dst-address=41.78.4.0/22 gateway=adsllan1
/ip route add dst-address=41.79.240.0/22 gateway=adsllan1
/ip route add dst-address=41.112.0.0/12 gateway=adsllan1
/ip route add dst-address=41.138.64.0/21 gateway=adsllan1
/ip route add dst-address=41.144.0.0/13 gateway=adsllan1
/ip route add dst-address=41.154.0.0/16 gateway=adsllan1
/ip route add dst-address=41.156.0.0/15 gateway=adsllan1
/ip route add dst-address=41.160.0.0/12 gateway=adsllan1
/ip route add dst-address=41.177.0.0/16 gateway=adsllan1
/ip route add dst-address=41.180.0.0/15 gateway=adsllan1
/ip route add dst-address=41.183.0.0/16 gateway=adsllan1
/ip route add dst-address=41.185.0.0/16 gateway=adsllan1
/ip route add dst-address=41.188.192.0/18 gateway=adsllan1
/ip route add dst-address=41.189.64.0/19 gateway=adsllan1
/ip route add dst-address=41.191.88.0/22 gateway=adsllan1
/ip route add dst-address=41.191.128.0/18 gateway=adsllan1
/ip route add dst-address=41.192.0.0/14 gateway=adsllan1
/ip route add dst-address=41.198.0.0/16 gateway=adsllan1
/ip route add dst-address=41.202.32.0/19 gateway=adsllan1
/ip route add dst-address=41.203.0.0/18 gateway=adsllan1

Re: opendns with dynamic ip

Posted: Mon Jul 05, 2010 10:13 am
by janisk
if address-list is not expanding every fast, you can add new entries and afterwards, check for duplicates. I would do the following:

*add addresses to the list, even if i make duplicates
*once in a while read whole list using API, that could be done even from several hosts
*compile list that does not contain duplicates and refresh the list on routers

Re: opendns with dynamic ip

Posted: Mon Jul 05, 2010 11:03 am
by hilton
I think the bigger problem comes in where you need to REMOVE stale addresses from the list.

What else can one do bar removing the entire list and recreating?