DDNS for IPv6. Is this working?

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Author Message
schossel
DD-WRT Novice


Joined: 05 Feb 2012
Posts: 21

PostPosted: Tue Jan 17, 2017 18:03    Post subject: DDNS for IPv6. Is this working? Reply with quote
Hi,

My ISP provides dual stack internet. I'm using a DDNS service for my IPv4 address for quite some time. This service could also be used with IPv6, but I can't figure out if it's even possible or how to do it.
They provide an update URL like: www.domain.com/?myip=<ip6addr>
I don't know if there's a variable in DD-WRT where I could get the IPv6 address.

Can somebody help me or is this not possible with DD-WRT?
Sponsor
schossel
DD-WRT Novice


Joined: 05 Feb 2012
Posts: 21

PostPosted: Wed Jan 18, 2017 20:24    Post subject: Reply with quote
So, because nobody seems to have something working, I made my own script.

Code:

cat > /tmp/ddns_ipv6.sh << 'EOF'
#!/bin/sh

# Credentials
PROVIDER=dyndns.yourprovider.com
HOSTNAME=yourhostname.yourprovider.com
USER=User1
PASSWORD=123456
# Get the current IPv6 on the local interface, here br0. If your interface is different, change it here.
IPV6_ON_INTERFACE=$(ifconfig br0 | awk '/inet6/{print $3}' | grep -v ^fe80 | cut -d/ -f1)

# Get time
TIMESTAMP=$(date +'%d.%m.%Y %H:%M:%S')

# Check if internet is up AND check if IPv6 on br0 is working
if (ping -c 2 172.217.17.132 || ping -c 2 139.130.4.5) && (ping6 -c 2 $IPV6_ON_INTERFACE)
   then
      # Get the current IPv6 on record by the DDNS provider
      IPV6_ON_RECORD=$(ping6 -n -c1 $HOSTNAME | head -n1 | awk -F'[()]' '{print $2}')   
      # Check if IPv6 did change
      if [ "$IPV6_ON_INTERFACE" != "$IPV6_ON_RECORD" ]
         then
            # If IPv6 changed, update IPv6 on record with IPv6 from local interface and save answer from DDNS provider
            UPDATE_URL="http://$USER:$PASSWORD@$PROVIDER/?hostname=$HOSTNAME&myip=$IPV6_ON_INTERFACE"
            PROVIDER_OUTPUT="$(wget -q -O - $UPDATE_URL)"
            # Write log to DD-WRT syslog
            logger IPv6 DDNS: $TIMESTAMP $PROVIDER_OUTPUT
      fi
fi
EOF
chmod 755 /tmp/ddns_ipv6.sh
sleep 10
echo "*/5 * * * * root sh /tmp/ddns_ipv6.sh" > /tmp/cron.d/ddns-ipv6


You can copy the script, fill in the things you need and put it under: Administration -> Commands -> Startup.

The script creates a new file called ddns_ipv6.sh in the /tmp folder on every reboot. The created file is executed every 5 minutes. If successful, it will be logged in DD-WRT syslog. If the IPv6 didn't change, it does nothing!
DatPratt
DD-WRT Novice


Joined: 18 Jul 2015
Posts: 23
Location: Ohio

PostPosted: Tue Sep 24, 2019 1:04    Post subject: Reply with quote
Nice script. I decided to just make a cron job to handle this. It's based on a single command that I set a web server to do as a hook for the DNS acme-challenge for lets encrypt. BTW, Certbot documentation has many similar examples for other DNS services. This might be a simpler solution for some others so I wanted to share.

My example is specifically for the Godaddy API,
which is authenticated by an API key and secret combination in a header of the HTTPS request (data input is in a header too),
it uses curl with dyndns.org to get the ipv6 address,
runs every 10 minutes (*/10),
and posts the output to /tmp/var/log/cron

But, this can easily be adapted for use with other services, like DDNS-only sites.

After registering for their API, one would adjust the key, secret, name (hostname), ttl, and domain in the URL (replace example.com) then paste all that in the Additional Cron Jobs box under Administration in the GUI.

Code:
*/10 * * * * root curl -s -X PATCH -H "Authorization: sso-key $KEY:$SECRET" -H "Content-Type: application/json" -d "[{'"type'":'"AAAA'", '"name'":'"office'", '"data'":'"`curl -s http://checkipv6.dyndns.org | cut -c 77-115`'", '"ttl'":3600}]" https://api.godaddy.com/v1/domains/example.com/records >> /tmp/var/log/cron


the only downside is...
there is no logic to compare the current address with the current DNS record, but the log will just post an error stating "Another record with the same attributes already exists" (again, this is specifically for Godaddy)

_________________
You don't have to be a professional, just keep reading...
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum