Friday, 28 November 2008

Can I has IP?

A quicky Perl utility that interrogates the DNS-O-Matic IP page which returns your public IP address.#!/usr/bin/perl

# cihip (Can I Has IP?)

use strict;
use warnings;
use LWP::Simple;

my ( $address, $error ) = get_address();

if ( $error ) {

print ( "$error\n" );
die "cihip failed: $error\n";

}

sub get_address {

$address = get( "http://myip.dnsomatic.com/" );

if ($address) {

print "$address\n";

} else {

$address = 0;
$error = "IP address query failed:\n";

}

return ( $address, $error );

}

Wednesday, 26 November 2008

DNS-O-Matic Updater


News: update-dnsomatic stable version 0.1 released 29 November 2008 at 13:00 GMT. I have moved the project to Goggle Code as my home server is only up 90% as a rule.

As I am a user of both opendns and dyndns I realized a while ago that it was a bit of a chore to keep them both up-to-date with my ever fluctuating home IP address. On discovering that DNS-O-Matic will update them at one fell swoop, I was hooked.

Time passed and as I was writing up installing ddclient, I was inspired to see if I could knock up a client of my own which would be designed specifically with DNS-O-Matic in mind.

Well, 24 hours and one abuse report from dyndns (sorry guys) later and it is done.

Specs

It's written in Perl and doesn't use any fancy modules so should work out of the box once installed.

It is written very much with Unix/Linux in mind but is simple enough to amend for other operating systems.

It only perfoms update notifications if your IP address has changed since it was last run.

Where?


The whole package complete with README, a sample configuration file and install.sh script can be found here.

How?


After downloading, extract the file update-dnsomatic-0.1.2.tar.gz and then edit the file config with a minimum of your DNS-O-Matic user id and password.tar xvzf update-dnsomatic-0.1.2.tar.gz
cd update-dnsomatic-0.1.2/

# edit ./config with your editor of choice
# A sample config file:
user = my_user_id
pass = my_password
#

# as root or sudo:
./install.sh

You may wish to assign the myhost configuration item with your domain name if you only wish to update that domain. If you don't assign myhost then all your DNS-O-Matic services will be updated.

A picture of the DNS-O-Matic status information. One update done by me and two by them.

Tuesday, 25 November 2008

OpenDNS and Ubuntu

I have been using OpenDNS for a few months now and it's about time that I wrote it up.

If you want to be able to use all the facilities that OpenDNS offer, then ideally you need to setup a DynDNS account and an OpenDNS account.

First things first, I have configured my router to use the OpenDNS nameservers 208.67.222.222 and 208.67.220.220.

Configuring DynDNS

You may wish to use my own DNS-O-Matic updater, which I have written about here.

Having created a free account with DynDNS, I needed to install ddclient on my home server.

Installing ddclient on the server

If your router can talk to dyndns, ignore this section.
sudo apt-get install ddclient
Configuring ddclient

Edit the contents of /etc/ddclient.conf using sudo

The contents of my file looks something like this:
daemon=600
cache=/tmp/ddclient.cache
pid=/var/run/ddclient.pid
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
login=my_dyndns_account_name
password=my_dyndns_password
protocol=dyndns2
server=members.dyndns.org
wildcard=YES
my.dyndns.domain

It is worth checking file /etc/default/ddclient to see if ddclient is run as a daemon.
# Configuration for ddclient scripts
# generated from debconf on Tue Oct 14 15:19:15 BST 2008
#
# /etc/default/ddclient

# Set to "true" if ddclient should be run every time a
# new ppp connection is
# established. This might be useful, if you are using
# dial-on-demand
run_ipup="false"

# Set to "true" if ddclient should run in daemon mode
run_daemon="true"

# Set the time interval between the updates of the
# dynamic DNS name in seconds.
# This option only takes effect if the ddclient runs in
# daemon mode.
daemon_interval="300"


Configuring OpenDNS


Having created an OpenDNS account, visit https://www.opendns.com/dashboard/networks/ and click the ADD THIS NETWORK button.

Updating OpenDNS

Now that your two accounts are up and running, your need to periodically notify OpenDNS of your current IP address and your account name. This can be done using a script that I took from the OpenDNS forum here. I have a tidy and slightly different script on my home server here. Simply follow the instructions at the top of the file and away you go.

To check that OpenDNS is working, visit this link for a report: http://www.opendns.com/welcome/