Dynamic IP's on a dedicated server

A messy perl script that helps achieve this

What is my problem?

I have a server, it hosts various things like email, and a few web sites.

I am cheap, so I hosted it at home.

Home ISP gives me a dynamic IP (though it hasn't actually changed in a few years...)

If it does change, all my services are down!

What can I do to solve this?

Email: have a backup MX record, I use rollernet.us. It is free for low usage :D

Web: ... Cope ...

DNS: Secondary DNS, I use rollernet.us and puck.nether.net

So thats it?

Not really, backup DNS only lasts a few weeks, and backup mail only about a week

Really need to change the A record in the DNS zone

Could do manually, but may be on holiday

So... Why don't I use a dynamic DNS service?

Because I can get around it :P

If I had a script to update the zone file when the IP changes, then notifies secondaries...

Enter Perl

Cron job that runs every 5 minutes (time of dynamic lease)

Secondary DNS communicate via ipv6, which is static

perl script to fetch current ip, update zone files, and update registrar

Web is broken for a bit, but mail will go through as normal (the way it should..)

What is in the perl script?

3 components: Fetching current ip, updating zone, updating registrar

Fetching current IP

IP is fetched from a handful of "whatismyip" type sites, via HTTP and some via DNS

Uses LWP and Net::DNS

Can be overridden

Updating zone file

Reads a template file which has 127.0.0.1 as the "external" ip

Substitutes real ip, and writes to correct location

Uses DNS::ZoneParse (has some bugs with SPF records..)

Reloads NSD database with new zones, which then notifies secondaries

Updating registrar

Need to update glue A record for the domain

Use LWP with a temporary cookie jar, and just "click" along

Can't make use of old IP as it may be very old, or we don't know it

Instead make assumption that any glue record is hosted on our server

And thats it

Working system, with backups around world

When IP changes, small amount of downtime, but incoming emails still happen

Script picks up the change, and updates all the things

Back to working system

Questions? Code?

THE END

BY Hugh Davenport <hugh@davenport.net.nz>