NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.

Forum Discussion

Teufl_at_Readyn's avatar
Feb 15, 2014

IPV6 (DDNS) Update Script for afraid.org

Hello Everybody,

since I had problems updating my Readynas IPv6 IP, I would like to post my solution for DDNS via afraid.org. Beforehand, there is an app for dynamic dns updating you could try first: DDclient. Depending on your needs, that may be enough and it works with other DDNS-Pages.

To keep it simple, I'll just make a point by point description for relative linux-newbies. Although, I wrote a script, a good friend of mine rewrote the attached version completely. He also told me where to copy things. So, I hope everything is kind off sensible. ;)

Basically, you have to do three things: Get your update-adress (1-3), create the script (4-6), and execute it periodically (7).

1. Create an account at afraid.org

2. Login and create a subdomain

3. On afraid.org go to "Dynamic DNS" and copy the "Direct Link". It looks like this:
http://freedns.afraid.org/dynamic/update.php?A2asdfjpoAlk234asdf8234Wasdf432435AsdfOiDFla
IMPORTANT The part after update.php? (Authentication Token) shouldn't be made public! Somewhere I read it's a hash-value of your username and password. Since there is a Button to "Rotate Authentication Token", it is pretty obvious you shouldn't shout it around.

4. Copy your update link or just the "Authentication Token" into the attached script and name it (i.e. ddnsafraid.sh)

5. Create a folder in the /var/ directory of your NAS and copy the script to this folder (mkdir /var/ddns)

6. Make the script executable with chmod +x /var/ddns/ddnsafraid.sh

7. Use crontab -e and add the following line. It executes the script every hour at 4/9/14/... minutes. You can replace the numbers with another * to execute it every minute. I used the intervall provided from the example at afraid.org.
4,9,14,19,24,29,34,39,44,49,54,59 * * * * /var/ddns/ddnsafraid.sh


8. Wait and check the log-file or the entries at afraid.org for success!

I just wrote the script today and haven't tested it fully. I'll update the thread some days from now to tell you if there are any changes necessary or if it is running just fine.

#!/bin/bash

LOG_FILE=/var/log/ddns.log
IP6ADDR_FILE=/var/ddns/ip6address

ip6_cur=`/sbin/ifconfig eth0 | grep "inet6 addr" | grep -Evi -m 1 "inet6\s+(addr:\s+)?(fe80|fd)" | awk '{print $3}' | awk -F'/' '{print $1}'`

if [ -f $IP6ADDR_FILE ]; then

ip6_old=`cat "$IP6ADDR_FILE"`

if [ $ip6_cur = $ip6_old ]; then
# Do nothing, because IPs are equal
exit
fi

fi

# Update IP
update_url="https://freedns.afraid.org/dynamic/update.php?ABCD1234EFGHiklasdf32034lUasdfAalsdfU23asdf4==\&address=$ip6_cur"

wget -nv -O - $update_url >> "$LOG_FILE" 2>&1 &

# Write new ip to file
echo $ip6_cur > "$IP6ADDR_FILE"


IP6, IPV6, DDNS, DynDNS, Afraid.org, DDclient, IP Update, Remote, Update IP-Adress, DS-Lite

4 Replies

  • For those following in these footsteps, two changes are needed to the script above.

    1) It's /bin/ip, not /sbin/ip. At least on my Readynas Ultra4
    2) The = on line 12 should be ==
  • mdgm-ntgr's avatar
    mdgm-ntgr
    NETGEAR Employee Retired
    It may be different on the Ultra 4 as the Ultra 4 runs RAIDiator 4.2.x whereas the RN312 runs ReadyNAS OS 6 which is based on a newer version of Debian.
  • It seemes the output of "ip addr show" or ifconfig has changed so the first output is the local IPv6 Adress. Quick talk to my friend brought the following conclusion, which I will (have added) in the above script, also.

    If you have the script already in use, replace

    ip6_cur=`/sbin/ip addr show eth0 | grep -m 1 "inet6" | awk '{print $2}' | awk -F'/' '{print $1}'`

    with

    ip6_cur=`/sbin/ifconfig eth0 | grep "inet6 addr" | grep -Evi -m 1 "inet6\s+(addr:\s+)?(fe80|fd)" | awk '{print $3}' | awk -F'/' '{print $1}'`
    .

NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology! 

Join Us!

ProSupport for Business

Comprehensive support plans for maximum network uptime and business peace of mind.

 

Learn More