Something went wrong. Try again.
A basic dynamic DNS program with a Lua based configuration
Something went wrong. Try again.
dynamic-dns config_example.lua
795 B · 35 lines
Lua
at main
123456789101112131415161718192021222324252627282930313233343536local os = require("os")local http = require("http")local json = require("json")-- Domains to monitordns.cloudflare[os.getenv("CF_TOKEN")] = { "example.com",}dns.porkbun[{ os.getenv("PORK_KEY"), os.getenv("PORK_SECRET") }] = { "example.com",}
function check_aws() local resp, status = http.get("https://checkip.amazonaws.com/", {}) return resp, statusend
-- Define how to check IPv4 Addressdns.get_ipv4 = function() local ip, status = check_aws() if status == 200 then return ip end return ""end
dns.notify = function(domain, old, new) local message = domain .. " has new ip: " .. new http.post("https://ntfy.sh/test-topic-dynamic-dns", message, {})end
-- Interval to update the DNS recordsdns.interval = 4 * time.duration.hour
-- Enable HTTP RPC APIdns.api = true