This can be useful for cron
, for instance.
- You are using Linode's DNS Manager to manage a zone for your domain
- You have already created an A record for the name you want to make dynamic
- You have an API key for Linode's API
curl
andjsonpp
(jsonpp
is not necessary but makes the manual steps easier)
You need the DOMAINID
and RESOURCEID
for the A record you previously created. First, find the DOMAINID
by listing all the domains you can manage:
$ curl -v -u u:THE_API_KEY 'https://api.linode.com/?api_action=domain.list' | jsonpp
Let's say the DOMAINID
you find is 10000
.
Next, find the RESOURCEID
for the A record you want to update dynamically. You do this by getting another list and looking through it:
$ curl -v -u u:THE_API_KEY 'https://api.linode.com/?api_action=domain.resource.list&DOMAINID=10000' | jsonpp
Let's say the RESOURCEID
you find is 800
.
Those two pieces of info, plus the API key and curl
, are all you need to update that DNS record to point to the address from which the request originates:
$ curl -v -u u:THE_API_KEY 'https://api.linode.com/?api_action=domain.resource.update&DOMAINID=10000&RESOURCEID=800&TARGET=%5Bremote_addr%5D' | jsonpp
Re-get the resource info to see that it was updated:
$ curl -v -u u:THE_API_KEY 'https://api.linode.com/?api_action=domain.resource.list&DOMAINID=10000&RESOURCEID=800' | jsonpp
You can have the update run automatically every hour via your crontab:
$ crontab -e
# edit to contain:
0 * * * * curl -v -u u:THE_API_KEY 'https://api.linode.com/?api_action=domain.resource.update&DOMAINID=10000&RESOURCEID=800&TARGET=%5Bremote_addr%5D' > ~/dyndns.log 2>&1