DuckDNS.org Dynamic DNS updater
Posted: Mon Nov 16, 2015 6:08 am
DuckDNS.org allow you to update your IP by requesting "https://duckdns.org/update/exampledomain/yourtoken", it also works via HTTP so I've used this to create a simple updater for the ESP8266. Hope someone else finds it useful.
Since conn:connect only seem to work with an IP address, the first part resolves the IP for duckdns.org, then creates the http request.
The IP address for the update is determined automatically by DuckDNS, you can also specify it manually as a 3rd argument to the http request if you like.
Code: Select all
dr=net.createConnection(net.TCP, 0)
dr:dns("www.duckdns.org",function(conn,ip)
myip=ip
end)
conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload) print(payload) end)
conn:connect(80,myip)
conn:send("GET /update/your-domain-here/your-token-goes-here HTTP/1.1\r\n")
conn:send("Host: www.duckdns.org\r\n")
conn:send("Accept: */*\r\n")
conn:send("User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n")
conn:send("\r\n")
Since conn:connect only seem to work with an IP address, the first part resolves the IP for duckdns.org, then creates the http request.
The IP address for the update is determined automatically by DuckDNS, you can also specify it manually as a 3rd argument to the http request if you like.