Dynamic DNS with Route53

Brandon Wagner
Aug 25, 2017 · 2 min read

Ever wanted to cheaply setup a dynamic DNS for your house so that you can easily remote in through a VPN or some other means? I had that feeling one day and didn’t want to get a DynDNS account just to set this up. Since I already had an AWS account, I wanted to do this with Route53 which is AWS’s very easy to use DNS service. I cranked out a pretty simple Python CLI application to do the trick.

You can setup this script to run on a server or your local computer to update a DNS record on AWS Route53 to point to your home’s WAN IP address. I’ll walk through a general setup to trigger this script to run every 15 minutes on a Mac/Linux system (this can work on a Raspberry Pi as well):

First let’s get the script cloned and installed:

git clone git@github.com:bwagner5/Dynamic-IP-Route53.git
cd Dynamic-IP-Route53/
./setup.py install

Now you can run update_ip.py from anywhere. Next, get the location where it was installed. You can use the which program to get that information:

which update_ip.py

Keep the output of which for a little later.

We’ll be using crontab to setup this script to run every 15 minutes.

  1. Make sure you have an AWS account setup, Route53 setup as your DNS provider for a domain you own (you can register the domain within Route53 or point name servers to Amazon from any registrar), and an AWS CLI profile setup for the user you’re running the cron with (https://docs.aws.amazon.com/cli/latest/userguide/installing.html).
  2. (OPTIONAL) sudo su <user> to switch to a user you’ll run the cron with.
  3. crontab -e this will open the crontab (a plain text file) for the user. It will prompt you to use your CLI editor of choice. I’ll use vim.
  4. Insert the following text into the document:
*/15 * * * * <OUTPUT OF YOUR which> --fqdn home.example.com --zone_name example.com

And that should do it for the auto-update cron.

Usage:

usage: update_ip.py --zone_name <zone_name> --fqdn <fqdn>

Update Public IP to Route53

optional arguments:
-h, --help show this help message and exit
--zone_name ZONE_NAME
Zone Name (i.e. example.com)
--fqdn FQDN Fully Qualified Domain Name (i.e. home.example.com)

You can check out the code here and feel free to submit PR’s!

https://github.com/bwagner5/Dynamic-IP-Route53

)
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade