How to Create Dynamic DNS in AWS Route 53 Using Python and the AWS SDK
22 October 2024
Table of contents
What Is Dynamic DNS?
Why we need Dynamic DNSš¤?
Dynamic DNS Service Providers (Freeš¤):
Do Route 53 have this amazing feature š?
So, How do we do it š¼?
- Create Route 53 Hosted Zone of your domain and note the Hosted Zone ID.



sudo apt update
mkdir ddns && cd ddns
nano ddns.py
sudo apt install python3-boto3
sudo apt install python3-requests
sudo chmod +x ddns.py
python3 ddns.py

How to run this code on instance boot upš?
- Create systemd service file:
sudo nano /etc/systemd/system/update-dns.service
[Unit]
Description=Update Route 53 DNS with Public IP
After=network.target
[Service]
ExecStart=/usr/bin/python3 /home/ubuntu/ddns/ddns.py
WorkingDirectory=/home/ubuntu/
StandardOutput=inherit
StandardError=inherit
Restart=always
User=ubuntu
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable update-dns.service
sudo systemctl start update-dns.service
How to run this script every 5 min?
- Edit crontab file:
crontab -e
*/5 * * * * /usr/bin/python3 /home/ubuntu/ddns/update_dns.py
sudo systemctl enable cron
sudo systemctl start cron
sudo systemctl status cron
How Useful it is?
References:
WRITTEN BY

Pruthvi Menpara
Pruthvi is a cloud computing architect who makes sure businesses scale and perform at their best using AWS and Azure. Heās passionate about building robust cloud infrastructures that provide the perfect balance of security and scalability.
WRITTEN BY
Pruthvi Menpara
Pruthvi is a cloud computing architect who makes sure businesses scale and perform at their best using AWS and Azure. Heās passionate about building robust cloud infrastructures that provide the perfect balance of security and scalability.
More
An interesting read? Here is more related to it.
12 August 2024
Pruthvi MenparaMaking IT Possible
Making IT Possible
Making IT Possible
Making IT Possible
Making IT Possible
Making IT Possible
India (HQ)
201, iSquare Corporate Park, Science City Road, Ahmedabad-380060, Gujarat, India
For Sales
[email protected]
Looking For Jobs
Apply Now