My almost free dynamic dns replacement (AWS route53)

I use amazon route53 for DNS, it is easy, cheap, portable since it is separate from my domain registrar, and they have a pretty nice API.  There is a nice CLI tool for changing DNS called cli53, the official tool, awscli, would work too but I’d have to make JSON requests my self if I used that over cli53. See the last code block for the final script and you’ll see why cli53 is just easier than aws route53 change-resource-record-sets commands.

Just run

sudo pip install cli53

to get cli53 (install pip first if you’re missing that obviously)
Next login to Amazon Web Services IAM and restrict a new group/user to only have permission to route53 + your domain. My policy looks like this, update with your route53 hosted zone:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "route53:ChangeResourceRecordSets",
                "route53:GetChange",
                "route53:GetHostedZone",
                "route53:ListHostedZones",
                "route53:ListResourceRecordSets"
            ],
           "Resource": [ 
               "arn:aws:route53:::hostedzone/ZENV1B2ABCDEF"
            ]
        },
       {
         "Effect":"Allow",
         "Action":[
            "route53:GetHostedZone",
            "route53:ListHostedZones"
         ],
         "Resource":"*"
      }
    ]
}

Your web host needs a simple application to return external IPs, or you can use a openly free one (the only free one I found was throttled), something like this works on a PHP webserver:

<?php print $_SERVER['REMOTE_ADDR']; ?>

Finally here is the script to do the real work. This will need to be installed on a computer with cli53 and curl installed (sorry, I know a router would be more convenient). I setup a user called dyndns setup cli53’s .boto configuration AWS credentials file, see CLI53’s docs for more on that. Then just put it in the crontab to run every 5 minutes and perform some basic tests to confirm it works. Like deleting the ip_address.log and make sure cron re-generates it…the real test comes when your IP address changes…I suppose I should have tested that before posting 🙂 oh well.

#!/bin/bash
 
SCRIPTPATH=$( cd $(dirname $0) ; pwd -P )
IP_LOG="${SCRIPTPATH}/ip_address.log"
if [ ! -f $IP_LOG ] ; then touch $IP_LOG ; fi;
LAST_IP=`tail -1 ${IP_LOG} | cut -d' ' -f3`
CURRENT_IP=`curl http://yourdomain.com/whatismyip.php`
 
if [ "$CURRENT_IP" != "$LAST_IP" ]; then
cli53 rrcreate yourdomain.com myip A $CURRENT_IP --replace --ttl 300
echo "$(date '+%F %T') $CURRENT_IP" &gt;&gt; $IP_LOG
fi;

How I used RSS services to email me when Google’s Nexus 4 came back on sale

This is a simple little tutorial of how to leverage and combine multiple RSS services to notify you when pages change.  You might need to do this when there is no RSS feed for a page you want to monitor or, like in my case, there’s a store which does not support email notifications for out of stock items. It could be any page, but for this example I wanted to know when they were text changed on the Google Play store so I knew when they removed the text stating that they were out of stock of the Google Nexus 4 phone. I only set this up 2 days ago or so and I was just in time. The final result was, Today I got an email saying the following text had been added to the Nexus 4 16GB page: “Ships Soon” (replacing Temporarily out of Stock)

To set this notification up, first, I got the RSS feed for the Nexus 4 page by taking the URL and submitting it to a service called page2rss (http://www.page2rss.com)

After turning whatever page into RSS with page2rss you get a sent to a page that looks like this (link here):

This is just a summary page where page2rss has tracked all the changes made to the page in the form of RSS items.  If you’re the first one to submit this link to page2rss then it starts with a fresh/blank slate and tracks all changes from that point on.  In my case others had submitted the Nexus 4 pages before me – so I could see some of the history of changes; they had been out of stock since mid December.

The RSS link, which you’ll want to copy, is on the right, under “Subscribe to Feed”. The link will look just like the summary page URL, but with rss/ in front, like this: http://page2rss.com/rss/11e73aa5895945d3e13bbedfe3d747bc

Next, I googled for an RSS notification service that sends an email every time a new RSS entry is posted to  a feed. A defunct, no longer in service, RSS notification service recommended trying an alternative, free service: BlogTrottr (http://blogtrottr.com/). This step was dead simple, just entre the RSS link from before, your email address, and leave the update frequency real time.

 

So that’s all there is to it.  After a day I got my first email notifying me of text changes to the page.  Fair warning: This won’t be true real time the second the page is updated, page2rss only scans for changes every so often and then blogtrottr also only checks for changes to the feed every so often.  As I mentioned before, these are free services and I’m not sure what their business model is so my very specific recommendation to use these 2 service won’t be relevant forever and you may have to go hunting for similar services.