Dynamic DNS (IPv4 and IPv6) with Linode

Written on Tuesday, 2012-10-23 16:56. Tagged code, english, and perl

Here be dragons! This post is more than three years old. The information and advice it presents may be deprecated, wrong, or unvise. Thread with cation.

Do you have have free dynamic DNS through no-ip.com?

Your free host hildenae.no-ip.org, will expire in 7 days due to account inactivity.

hildenae.no-ip.org was last updated on <some-datetime-in-the-past>. Free Dynamic DNS hosts must be updated by logging into your account on our website and clicking update, this must be done every 30 days. If you are using the Dynamic Update Client and your  IP address has not changed within the past 30 days, you must manually update it to prevent them from being removed from our system.

Yeah. With a mostly static IP from my school, that started to get annoying after five or six times.

Did you know Linode supplies free DNS hosting if you have a VPS with them? Well, now you do.

Their DNS manager is also avalible via their API, and said API has a CPAN module avalible. I see a homebrewed solution comming up.

Linode has done most of the work for us - if you download and extract the module, you will find examples/dyndns.pl. This example however only works on IPv4, and uses an external service to determine the address. I hate to bother rely on external services for things like getting IP addresses, and because we have proper IPv6 routing here, having a AAAA record for my IPv6 address is also important.

The code and stuff

For the lazy of you, INET6Glue will hotpatch LWP do support IPv6 requests,

use Net::INET6Glue::INET_is_INET6;

and icanhazip.com supports the lookup of IPv6 (and 4) adresses.

my $pubip = get('http://icanhazip.com/') or exit 1;

I however, preffer to ask the hardware directly. For the IPv4 adress

my $pubip = `ip -o addr show eth1 | \
awk '/inet / { split($4,ipv4,"/"); print ipv4[1] }'

and for the temporary IPv6 address

my $pubip = `ip -o addr show eth1 |
    awk '/inet6.*temporary/ { split($4,ipv6,"/"); print ipv6[1] }'`;

The default script only lets you update a single host, and not both A and AAAA records if they are defined, but that will have to be a task for another day.


Activate comments