2014-05-30

DDNS and IPv6?

Ever tried setting up DDNS with IPv6? I recently had to learn that there is a remarkable range of tools and services that do not work with IPv6.

ddclient does not support IPv6, nor does inadyn.
inadyn-mt claims to support IPv6, but if that is true, it is at least hard to configure.

Also not all DDNS-Services offer IPv6 support with freedns.afraid.org being one notable exception. This service also allows setting the IPv6 via a URL.

A pragmatic solution to get DDNS working with IPv6 could be running the following Python script periodically using a cronjob:
 
#!/usr/bin/env python
''' update ipv6 record on freedns.afraid.org '''

import netifaces
import subprocess
import sys

iface_name = "eth0"
pwd_hash = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr"

try:
addrs = netifaces.ifaddresses(iface_name)
ipv6_str = addrs[netifaces.AF_INET6][0]['addr']
#check if link local adress
if ipv6_str[0:5] == "fe80:":
raise Exception()

except:
sys.exit("could not determine ipv6 address");


subprocess.call(
[
"wget",
"-q",
"--read-timeout=0.0",
"--waitretry=5",
"--tries=400",
"https://freedns.afraid.org/dynamic/update.php?"+pwd_hash+"&address="+ipv6_str
]
)

The script can also be downloaded here. It requires the package netifaces, which can be installed using pip. Moreover wget needs to be installed. You need to adjust the interface name and the password hash manually.
$> sudo apt-get install python-pip
$> sudo pip install netifaces

I suggest simply copying the script to /opt, making it executable and adding a cronjob for it.
$> sudo crontab -e

add the following line to the crontab
 */30 * * * *    /opt/ipv6_update.py

and restart the cron daemon
$> sudo /etc/init.d/cron restart

If you are using a network manager, eg. wicd or network-manager, the Python script above can be hooked in there. For wicd the script would have to be copied to
/etc/wicd/scripts/postconnect

1 comment:

  1. Hi Volker,

    I'm sorry you found ipv6 setup with inadyn-mt difficult. It's pretty simple though.

    One needs an ip server that will return your ipv6 address, and then, of course, your dynamic dns server needs to support ipv6 addresses in updates.

    A sample configuration that uses an ipv6 capable ip server, and ipv6 capable dynamic dns server:

    --dyndns_system default@dyndns.org
    --username test
    --password test
    --alias test.dyndns.org ip6
    --ip_server_name ip6.me /

    Notice the alias option has two parameters - the alias, and address type, which in this case, is ip6 (other options are ip4, dual, coupled, and auto, the default).

    Note also, inadyn-mt can update both address types, ip4, ip6, in cases of dual stack clients, and ip servers.

    All of this info can be referenced in the readme.html that resides in inadyn-mt root directory, or the inadyn-mt man page, alias, and ipv6 sections.

    inadyn-mt works as ever without an ip type alias option parameter. In such cases, default type 'auto' is used, wherein ip type is determined by ip server, which with default ip server - usually checkip.dyndns.org - ip4 will be the address type returned.

    Incidentally, at this writing, dhis.org is another reliable ipv6 capable ip server. There are others, via google search.

    Bryan

    ReplyDelete