Logic Machine Forum
dyndns.org - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: General (https://forum.logicmachine.net/forumdisplay.php?fid=2)
+--- Thread: dyndns.org (/showthread.php?tid=264)



dyndns.org - josep - 06.04.2016

Hello, I would to know if it's possible to send public IP to services like dyndns.org when public IP changes, thank you very much.


RE: dyndns.org - zoltan - 06.04.2016

(06.04.2016, 13:58)josep Wrote: Hello, I would to know if it's possible to send public IP to services like dyndns.org when public IP changes, thank you very much.

Check here:
http://forum.logicmachine.net/showthread.php?tid=159


RE: dyndns.org - admin - 06.04.2016

Most dynamic DNS services can be updated via a simple HTTP request.

Example for Duck DNS (https://www.duckdns.org). Add this code to a scheduled script with run frequency tuned to how often your IP can change.
Code:
domain = 'logicmachine'
token = '12345678-1234-1234-1234-123456789012'
require('ssl.https').request('https://www.duckdns.org/update?domains=' .. domain  .. '&token=' .. token .. '&ip=')



RE: dyndns.org - josep - 06.04.2016

I use DynDNS account and I find this information, if I need update via HTTP but not HTTPS the expression is require (ssl.hhtps) or anothrer, thank you

https://help.dyn.com/remote-access-api/perform-update/


RE: dyndns.org - zoltan - 06.04.2016

(06.04.2016, 15:25)josep Wrote: I use DynDNS account and I find this information, if I need update via HTTP but not HTTPS the expression is require (ssl.hhtps) or anothrer, thank you

https://help.dyn.com/remote-access-api/perform-update/

I beleive it will work with https. Bonus is that it's much more secure than http.

Just tested this 
Code:
http://username:password@members.dyndns.org/nic/update?hostname=yourhostname&myip=ipaddress&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG
https://username:password@members.dyndns.org/nic/update?hostname=yourhostname&myip=ipaddress&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG
And both gives the same correct result: badauth

When updating any dynamic DNS service make sure you are sending update only when the IP is changed. Many will ban/suspend the account if the update is to frequent. Use the sample from the first link to determine if the IP was changed - only then send the update with the second sample. By this method you can get the fastest possible refresh without risking a much longer delay.


RE: dyndns.org - admin - 07.04.2016

DynDNS also requires this:
Quote:All clients must send a well-formed user agent that includes company name, model number, and software build revision.

It can be done for both HTTP and HTTPS requests like this (after require):
Code:
socket.http.USERAGENT = 'EMBS - LogicMachine - 1'



RE: dyndns.org - josep - 10.04.2016

thank you, It works fine!


RE: dyndns.org - zoltan - 10.04.2016

(10.04.2016, 16:48)josep Wrote: thank you, It works fine!

Hey Josep,

Can you post your solution for future reference? Don't forget to delete your key and user data before that.


RE: dyndns.org - josep - 11.04.2016

require('socket.http')

socket.http.timeout = 60

data = socket.http.request('http://checkip.dyndns.org/')


if not data then
log('No se puede comprobar la IP externa')
return
end

wan = "(%d+).(%d+).(%d+).(%d+)"
wan = string.sub(data, string.find(data, wan))
log(wan)

wanip = storage.get('wan_ip')


if wanip == nil then wanip = "0.0.0.0"
storage.set('wan_ip', wanip)
else

if wanip == wan then
--do nothing
else

subject = 'Nova IP: ' .. wan .. ''
message = 'La direcció IP ha canviat: http://' .. wan .. ':8080'
mail('mail@mail.com', subject, message)
--log("La nova IP publica externa es : " .. wan)
alert("La IP publica actual es: " .. wan) --ver registro alertas para cambios de IP
storage.set('wan_ip', wan)
log("S,envia mail. Nova IP: " .. wan)



require('ssl.https').request('https://user:password@members.dyndns.org/nic/update?hostname=name.dyndns.org&myip=' .. wan .. '&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG')


end
end

wan = storage.get('wan_ip')
log("La IP publica actual es: " .. wan)


RE: dyndns.org - buuuudzik - 09.08.2016

How can I add to my script WAN IP address?

I want to communicate with dnsdynamic.org to update my IP address.

Command:
https://login:password@www.dnsdynamic.org/api/?hostname=your_hostname&myip=127.0.0.1

I must change myip to WAN IP.

I tried to do this based on the above example:
Code:
require('socket.http')
socket.http.timeout = 60

wan = socket.http.request('http://myip.dnsdynamic.org/')
log(wan)

require('ssl.https').request('https://buuuudzik@gmail.com:vl!45z8N@www.dnsdynamic.org/api/?hostname=house01.ddns01.com&myip=' .. wan)


I have an error:
Line 0: bad argument #2 to 'connect' (number expected, got string)

Do you what is the problem?


RE: dyndns.org - admin - 09.08.2016

Code:
ip = require('socket.http').request('http://myip.dnsdynamic.org/')
if ip then
  require('ssl.https').request('https://login:password@www.dnsdynamic.org/api/?hostname=your_hostname&myip=' .. ip)
end



RE: dyndns.org - buuuudzik - 09.08.2016

(09.08.2016, 09:11)admin Wrote:
Code:
ip = require('socket.http').request('http://myip.dnsdynamic.org/')
if ip then
 require('ssl.https').request('https://login:password@www.dnsdynamic.org/api/?hostname=your_hostname&myip=' .. ip)
end

Unfortunately this error is still appearing on my Error listSad

I tried disable and enable the script.


RE: dyndns.org - admin - 09.08.2016

Since your username has '@', it confuses the url parser. You can do your request like this:
Code:
ip = require('socket.http').request('http://myip.dnsdynamic.org/')
if ip then
  auth = require('mime').b64('USERNAME:PASSWORD')
  host = 'xyz.ddns01.com'

  log(require('ssl.https').request({
    url = 'https://www.dnsdynamic.org/api/?hostname=' .. host .. '&myip=' .. ip,
    headers = { authorization = 'Basic ' .. auth }
  }))
end



RE: dyndns.org - mooselight - 23.10.2018

Dear all,
As dnsdynamic.org stopped working recently, I suggest you to replace it with http://checkip.amazonaws.com/.
Works fine for me.
BR


Code:
ip = require('socket.http').request('http://checkip.amazonaws.com/')