This is a follow up to the post Dynamic DNS with Route 53
The Setup
When working on web dev projects, it’s becoming increasingly common that the mobile layout of a website is well considered early on in a project, and I find that the easiest way to achieve this is to physically see the pages on a device.
The Issue
This can become problematic if dynamic addressing is involved if the development site is being served from a local client. To overcome this, you might start off the day by looking up the IP address of the development machine and then navigating the test device to it.
Should you have a short DHCP lease time, your address may change throughout the day, cause a repetition of this process.
Should you be using a framework such as Django, you might end up with something like ALLOWED_HOSTS += ['10.{}.{}.{}'.format(i,j,k) for i in range(256) for j in range(256) for k in range(256)]
in your settings.py
file to prevent a Host header mismatch error.
None of this is particularly glamorous.
But there is a better way!
The Solution
AWS IAM
My previous post details how to setup an IAM user with the required permissions: AWS IAM
Updating the Update Script
The Python script used in the previous post requests the current public IP address the request came from. However, for our local development environment we need the IP address of an interface on the machine the scrip is being run on.
All but two lines of the original script dealt with the uploading of the IP address to AWS, however determining the IP address of a local interface takes more than a web request.
It may be important to note that this solution currently will only use the first IPv6 address listed on an interface as determined by ifconfig
. It is likely that there is a better solution than this if IPv6 is in use, however for the foreseeable future IPv4 is unlikely to be going anywhere at a LAN level, so this solution is likely to have use far into the future.
The changes to the script to determine a local IP address
To configure supply the interface name, mine is en0
on my desktop machine, and the IP version.
Download the complete DynDNS_Local_R53.py script here.
As per the previous post, setup a job scheduler to run the script and you’re good to go!