You are reading this post because: you are looking for a solution how to point your website domain to your home dynamic IP which I was looking for a long time for my HomeLab project. My domain bacnh.com bought from name.com which does not support dynamic DNS and static IP subscription from my ISP is quite expensive about 25$/month.
By chance, I am using DigitalOcean paid service for almost 1 year, and DigitalOcean supports API to change DNS records for domain which is managed by DigitalOcean.
Thus, idea of this method is:
- Change your domain DNS server to DigitalOcean DNS
- Use DigitalOcean API to update A record to match your home IP address
There are many useful How-Tos posts that you can follow.
Change your current DNS server
You need to change DNS to DigitalOcean DNS, so it can take over control of your domain DNS records.
Basically, you need to change your DNS server to:
- ns1.digitalocean.com
- ns2.digitalocean.com
- ns3.digitalocean.com
Create DigitalOcean account, setup your DNS record
In order to change DNS records for your domain, pls see below steps:
- Create DigitalOcean account if you don't have
- Create your project - named whatever you like
- Add your domain into your project
- Create A record: As I want to control all main and sub-domain, I need to create A record with hostname is @ for main domain, and * for all subdomain. In case, you want to point a blog.yourdomain.com, you need to create a A record with HOSTNAME=blog.
Pls take note to change TTL value to 30 (second), as you want to change made to A record updated ASAP, so your client don't feel any interruption once you reboot your router or ISP releases new IP to your home router. Default value is 3600 = 1 hour.
Update your domain DNS record
This Github project is a very well-writen that I use to update my DigitalOcean DNS record. Before doing this, you need to get DigitalOcean API key, so the app can update domain DNS records on your behalf.
Then create a JSON configuration for your domain, let's say: info.json
Then download respective binary for your system:
- digitalocean-dynamic-dns-ip-darwin-amd64 for macOS user
- digitalocean-dynamic-dns-ip-windows-amd64.exe for Windows 64-bit user
- digitalocean-dynamic-dns-ip-linux-386 for Linux 32-bit system
- digitalocean-dynamic-dns-ip-linux-amd64 for Linux 64-bit system
- digitalocean-dynamic-dns-ip-linux-arm64 for 64-bit ARM system
- digitalocean-dynamic-dns-ip-linux-arm for 32-bit ARM system
Then, you can now ask DigitalOcean to update your home IP with my ClearLinux box.
You can create a cron job to update every 5 minutes, for example:
# run `crontab -e` to edit your crontab
# sample cron job task
# m h dom mon dow command
*/5 * * * * path/to/digitalocean-dynamic-dns-ip-linux-amd64 /path/to/info.json
Windows users
You may want to create a DOS script and add it to Windows scheduler
digitalocean-dynamic-dns-ip-windows-amd64.exe path_to_config/info.json