This project sets up a dynamic DNS service using Docker, AWS Route 53, and AWS CLI. The service periodically checks for any changes to your current IP address and if it detects one then it updates your DNS record with your current IP address using the AWS CLI. Realistically this can work with any provider who has API to update the records, I chose AWS because I am fairly familiar with it.
- You own a domain you can point the nameservers to.
- You have some sort of device (like Raspberry Pi or any random computer) in your desired network that can run this.
I'm using Raspberry Pi with Ubuntu server 24.04 so my examples here are according to that. You should use your distributions documentation.
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo groupadd docker
sudo usermod -aG docker $USER
Log into aws.amazon.com and Search Route 53 -> Hosted Zones -> Create Hosted Zone
.
After you created it take note of the nameservers and hosted zone id.
Add IAM policy for CLI usage. For that
Search IAM -> Policies -> Create Policy
name it something like Route53DynamicDNSPolicy
and add (replace YOURHOSTEDZONEID with actual ID).
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"route53:ChangeResourceRecordSets",
"route53:ListHostedZones",
"route53:ListResourceRecordSets"
],
"Resource": [
"arn:aws:route53:::hostedzone/YOURHOSTEDZONEID"
]
}
]
}
And attach it to user. For that go to
IAM -> Users -> Create User
name it anything (like DDNS) and attach your policy to the created user.
Click on User
, click Security Credentials
and click Create Access Key
.
Select Command Line Interface (CLI)
, tick confirmation box and click Create
.
Write down the Access key
and Secret Access key
for later use in step 6.
Go to your domain registrar and change the nameservers to the 4 that were listed in step 2. This is different for everyone as everyone has their own registrar but it should look something like this:
Back in AWS Route 53 click:
Route 53 -> Hosted Zones -> <your-hosted-zone> -> Create record
.
Name it ddns.yourdomain.com
and set type to A. The value is not important at the moment as we are rewriting it automatically later on.
That should be mostly all from AWS side.
In your home server, do
cd /opt
git clone https://github.com/albertlaiuste/aws-ddns.git ddns
cd ddns/
Fill in the values for .env with values from step 2.
mv .env.example .env
nano .env # Ctrl+O to save, Ctrl+X to exit. Or use other editors, like vim.
And run the container
docker compose up -d
You can observe the service using
docker logs aws-ddns -f