Get in Touch
How to Create Dynamic DNS in AWS Route 53 Using Python and the AWS SDK
Written by Nishant Parmar
Published22 October 2024
Web Development
Tech
Dynamic DNS (DDNS) offers a solution by automating the process of updating DNS records whenever an IP address changes. This guide provides a step-by-step approach to implementing a DDNS service using AWS Route 53 and Python.
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:
More
An interesting read? Here is more related to it.
Permanently Blocking IP Addresses with AWS WAF Rate-Based Rule Limit
12 August 2024
/
Nishant Parmar
Tech
Web Development
Top 15 React Carousel Component Libraries for Modern Web Development
17 September 2024
/
Abhishek Vasvelia
Frontend
Web Development
We Make pixel perfect things
We Make pixel perfect things
We Make pixel perfect things
We Make pixel perfect things
We Make pixel perfect things
We Make pixel perfect things
India (HQ)
201, iSquare Corporate Park, Science City Road, Ahmedabad-380060, Gujarat, India
For Sales
[email protected]
Looking For Jobs
Apply Now
LinkedIn
Instagram
X
Facebook
Youtube
Discord
Dribbble
Behance
Github