A script to use DigitalOcean as a DDNS service.
If your domain is hosted on DigitalOcean you can use this script to update the address of an A record as if DigitalOcean was a DDNS service.
You have to have an A record setup on your DigitalOcean DNS like this:
pc.example.com. 3600 IN A 172.27.171.106
Then can use this shell script to periodically update that DNS record with your current external IP address. So you could set this up on your PC at home and always have access to it via pc.example.com or something. Just like a normal DDNS service.
Clone this repository Get your api token here and your dns record via this command:
curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer YOUR API TOKEN" "https://api.digitalocean.com/v2/domains/YOUR DOMAIN/records"
and paste them into the update_ip.sh file aswell as your domain.
API_TOKEN="F00B4R" #your api token
DOMAIN="foo.bar" #your domain
ID=123456 #your dns record id
Change permissions of the update_ip.sh file:
chmod +x update_ip.sh
Edit your crontab with:
crontab -e
and add:
*/30 * * * * /path/to/the/file/update_ip.sh
Maximilian Schiller - author - BetaHuhn
This project is licensed under the MIT License - see the LICENSE.md file for details