Curl is one of those command line tools that really does make our lives easier. APIs are expected of everything these days, from your washing machine to cloud management software, and rightly so. This is just a very simple example of using Curl to update a DNS record with an IP address. In this case I use it in my home lab to update a DNS record with my home internet IP address. Unfortunately my ISP doesn’t offer a static IP, but it’s not really a problem. There are free (with limitations) and paid dynamic DNS services out there, but why not do it yourself with a couple of lines of code? [Read more…] about Use Curl and Wget to Make Your Life Easier (DNS API update with external IP)

As tempting as it is, I have no intention of jumping on the ‘Shellshock’ band wagon and writing a vague post on the subject. However, I do find this recent bash exploit interesting and worthy of investigation as it’s simple to test and has a plethora of vectors that could be exploited. I’ve read many media reports on this and unfortunately some of their layman’s terms are inaccurate or do not provide the full picture. The purpose of this blog post is for my own reference and anybody that needs starting point of where to look. For an in-depth look at this then I would recommend you read Troy Hunt’s article. For a quick technical reference then feel free to read on… [Read more…] about Shellshock Vulnerability and Potential Exploitation (not another blog post on CVE-2014-6271 / CVE-2014-7169)

You know the story… you don’t have a static IP address for your internet connection so you use dynamic DNS, except a certain dynamic DNS company are no longer offering this for free. Well, an alternative is to script this yourself with a single line of code on your own Linux box at home and get it to update your DNS for you. You can have home.yourdomain.com update with your home internet IP automatically! I use Linode to provide me with my Linux web server, which runs on CentOS 6.2, but the other great thing about Linode is that you can use their name servers and have full access to your zone files. Even better still, they provide an API to do this and it’s really easy to set up.

What you need:

A Linux machine (or Apple Mac) at home – This can either be a virtual machine running on your home PC or lab server, Ubuntu on your PC, laptop or you can even do this on your Apple Mac!

<API_KEY> – This is the API Key that you can obtain from the ‘my profile’ page on your Linode account.

<DOMAIN_ID> – To obtain this, login into Linode and click on DNS Manager. Click on the ‘zone file’ for the domain and the ID is in square brackets at the top of the zone file (I.e ; yourdomain.com [17546])

<RESOURCE_ID> – Log in to Linode, go to DNS Manager and edit the domain zone that you wish to update. Now edit the host record (I.e. home) and you’ll see the URL is something similar to: https://manager.linode.com/dns/resource/yourdomain.com?id=723215. The ID number (723215) is your Resource ID.
The wget line will call the API function and [remote_addr] will simply update it with the IP address the request is coming from (in other words, your home internet connection). If you want to get a bit more clever with your script, you could create an IF statement to check the IP address it has with your existing one. If they are different then update it, otherwise exit the script.

Automating the DNS Update:

The final step is to schedule this script to run every few hours. I use crontab for this, and it looks something like this: