Logo Dark
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🤓):

  1. https://www.noip.com/
  2. https://www.dynu.com/

Do Route 53 have this amazing feature 🙄?

So, How do we do it 😼?

  1. Create Route 53 Hosted Zone of your domain and note the Hosted Zone ID.
Creating Route 53 Hosted Zone

Creating Records

Creating One Iam User

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

IP Address up to Date

How to run this code on instance boot up🏍?

  1. 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?

  1. 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:

  1. https://aws.amazon.com/what-is/dynamic-dns/
  2. https://github.com/nishant-p-7span/Dynamic-DNS/tree/Custom-DDNS
  3. ChatGPT 😉.

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
Deep Dive Into Nuxt 3 Server Side Data Fetching
31 August 2023
/
Jay Bharadia
Frontend
Web Development
Top 10 Most Used Open-Source Headless CMS Platforms
05 August 2024
/
Harsh Kansagara
Web Development
Most Popular Directus Extensions
07 March 2024
/
Jay Bharadia
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

Canada

24 Merlot Court, Timberlea, NS B3T 0C2, Canada

For Sales

[email protected]

Looking For Jobs

Apply Now

LinkedIn
Instagram
X
Facebook
Youtube
Discord
Dribbble
Behance
Github