#!/bin/sh -e | |
hostname=$1 | |
device=$2 | |
file=$HOME/.dynv6.addr6 | |
[ -e $file ] && old=`cat $file` | |
if [ -z "$hostname" -o -z "$token" ]; then | |
echo "Usage: token=<your-authentication-token> [netmask=64] $0 your-name.dynv6.net [device]" | |
exit 1 | |
fi | |
if [ -z "$netmask" ]; then | |
netmask=128 | |
fi | |
if [ -n "$device" ]; then | |
device="dev $device" | |
fi | |
address=$(ip -6 addr list scope global $device | grep -v " fd" | sed -n 's/.*inet6 \([0-9a-f:]\+\).*/\1/p' | head -n 1) | |
if [ -e /usr/bin/curl ]; then | |
bin="curl -fsS" | |
elif [ -e /usr/bin/wget ]; then | |
bin="wget -O-" | |
else | |
echo "neither curl nor wget found" | |
exit 1 | |
fi | |
if [ -z "$address" ]; then | |
echo "no IPv6 address found" | |
exit 1 | |
fi | |
# address with netmask | |
current=$address/$netmask | |
if [ "$old" = "$current" ]; then | |
echo "IPv6 address unchanged" | |
exit | |
fi | |
# send addresses to dynv6 | |
$bin "http://dynv6.com/api/update?hostname=$hostname&ipv6=$current&token=$token" | |
$bin "http://ipv4.dynv6.com/api/update?hostname=$hostname&ipv4=auto&token=$token" | |
# save current address | |
echo $current > $file |
This comment has been minimized.
This comment has been minimized.
v4 only client |
This comment has been minimized.
This comment has been minimized.
Is there a php version or a batch version of this available? |
This comment has been minimized.
This comment has been minimized.
Is there are reason why you use http for the update and not https which you have available? |
This comment has been minimized.
This comment has been minimized.
I used the following php script on my synology webdrive (/sbin/dynv6ddns.php). In addition to the script i updated the /etc/ddns_provider.conf manually with the following provider configuration:
the dynv6ddns.php: #!/usr/bin/php -d open_basedir=/sbin
<?php
if ($argc !== 5) {
echo 'badparam';
exit();
}
$account = (string)$argv[1];
$hostname = (string)$argv[3];
$ip = (string)$argv[4];
// check the hostname contains '.'
if (strpos($hostname, '.') === false) {
echo 'badparam';
exit();
}
// only for IPv4 format
if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
echo "badparam";
exit();
}
$url = 'https://dynv6.com/api/update?token='.$account.'&hostname='.$hostname.'&ipv4='.$ip;
$req = curl_init();
curl_setopt($req, CURLOPT_URL, $url);
curl_setopt($req, CURLOPT_RETURNTRANSFER, TRUE);
$res = curl_exec($req);
curl_close($req);
$query='host updated';
if (substr($res,0,strlen($query)) === $query) {
echo "good";
} else {
echo $res.' ';
echo "update failed";
} |
This comment has been minimized.
This comment has been minimized.
I made a new script for ipv4 |
This comment has been minimized.
This comment has been minimized.
Looking for the
See https://gist.github.com/danrl/f568bf6d61acb3d0e9b11986b09deada |
This comment has been minimized.
This comment has been minimized.
Hi, I am having some troubles with this script. I am totally new in scripting and dont know what to write in the console. What should I make different? |
This comment has been minimized.
This comment has been minimized.
Optionally have cron execute the script every 5 mins or so. Nothing will be sent if your IP hasn't changed.
|
This comment has been minimized.
This comment has been minimized.
I run the script on my raspberry pie. It runs fine and updates my ipv4 and ipv6 address. |
This comment has been minimized.
This comment has been minimized.
thanks for both ipv6 and ipv4 |
This comment has been minimized.
This comment has been minimized.
If IPv6 address not changed, but the (global) IPv4 address, it wont be updated.. |
This comment has been minimized.
This comment has been minimized.
Hi... ip -6 command used in line 19 not working in mac os 10.12 Sierra?!! (indeed not...) I get an error "command not found" |
This comment has been minimized.
This comment has been minimized.
Is it possible to update the records and not the normal domain name? I tried to just append it: It produced the following error: Would be nice to get a Inadyn-mt example configuration as well for Dynv6 Records. Couldnt find one online. |
This comment has been minimized.
This comment has been minimized.
Hi, im running this on a raspberry Pi behind my ISPs router. Is there a way to use this script to update the external/public IP? |
This comment has been minimized.
This comment has been minimized.
Is it not working? What error is coming up? Would you please send some more information, please? Kind regards |
This comment has been minimized.
This comment has been minimized.
Hi nephilim75, |
This comment has been minimized.
This comment has been minimized.
I am running this script on my Raspberry Pi 3.
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 When I run the script, I get this output: pi@raspberrypi:~ $ token= ./dynv6.sh satvam.dynv6.net Am I doing something wrong here? |
This comment has been minimized.
This comment has been minimized.
The IPv6 "address=…" line gives me the global temporary dynamic IPv6 host address, but what I need for DNS updates is the global dynamic (i.e., MAC-based) host IP, so I use a modified line like this: address=$(ip -6 addr list scope global permanent dynamic $device | grep -v " fd" | grep -v " temporary" | sed -n 's/.*inet6 \([0-9a-f:]\+\).*/\1/p' | head -n 1) |
This comment has been minimized.
This comment has been minimized.
for mac
|
This comment has been minimized.
This comment has been minimized.
When I am trying to run
Thx,blub4747 |
This comment has been minimized.
This comment has been minimized.
@uhardegger Thanks a lot for sharing your script! I've modified it a bit for my Synology router and added system log prints (to /var/log/messages). The modified version can be found here. The corresponding ddns_provider.conf file is uploaded here. |
This comment has been minimized.
This comment has been minimized.
Very simple and neat script that runs every 5 seconds in a loop. Has some advantages over the script above. Should work on most clients, includes a reliable way to get the IP and can be adapted to most dynamic DNS providers. Configure hostname, record type and update URL, done. For dynv6 you have to add your token in the URL. If you want to use IPV4, change IPVERSION to 4 and change url to ipv4 version of the URL. Then, simply copy it into a file like ddnsupdate.sh, chmod +x ddnsupdate.sh to make it executable and execute it from a startup script like rc.local: nohup /home/ddnsupdate.sh > /dev/null 2>&1& |
This comment has been minimized.
This comment has been minimized.
There is example of systemd unit
|
This comment has been minimized.
This comment has been minimized.
Adapted findings and requirements from this thread into a n updated (and currently working) script. Depends on Script #!/bin/bash
if [ -z "$DYNV6_HOSTNAME" -o -z "$DYNV6_TOKEN" -o -z "$DYNV6_PROTO" ]; then
echo "Usage:"
echo "DYNV6_HOSTNAME=hostname DYNV6_TOKEN=token DYNV6_PROTO=[4|6] $0"
exit 1
fi;
record=$([ "$DYNV6_PROTO" == 4 ] && echo "A" || echo "AAAA")
resolved=$(dig +short $record $DYNV6_HOSTNAME )
actual=$(dig -$DYNV6_PROTO TXT +short o-o.myaddr.l.google.com @ns1.google.com | tr -d '"')
if [ "$resolved" != "$actual" ] ; then
if [ "$DYNV6_PROTO" == "4" ] ; then
curl "http://ipv4.dynv6.com/api/update?hostname=$DYNV6_HOSTNAME&ipv4=$actual&token=$DYNV6_TOKEN"
fi
if [ "$DYNV6_PROTO" == "6" ] ; then
curl "http://ipv6.dynv6.com/api/update?hostname=$DYNV6_HOSTNAME&ipv6=$actual&token=$DYNV6_TOKEN"
fi
fi Example: DYNV6_HOSTNAME=ramalamadingdong.dynv6.net DYNV6_TOKEN=muchSecureSoSecret DYNV6_PROTO=6 ./update_dns.sh Please note that if you want to update v6 and v4 records, you will have to call the script twice. |
This comment has been minimized.
This comment has been minimized.
like some other people before me realized: when the ipv6 has not changed, then the ipv4 address is not updated even if it has changed. This is due to 27, 32,40 where the script just exits. I would open an issue for that if it were not only a gist but a full-fledged github repo. In the meantime - could i just suggest to actually put this script into a full-fledged github repo and to encourage the many people linking to their own versions in the comments here to make an effort and merge their diffs into the script so it actually becoms usable for noobs? Many thanks for considering this! |
This comment has been minimized.
This comment has been minimized.
+1 |
This comment has been minimized.
This comment has been minimized.
Nice service! I use the following # /etc/systemd/system/dyndns@.service
[Unit]
Description=Update dynv6 DNS Entries
[Service]
Type=oneshot
EnvironmentFile=/etc/conf.d/dynv6
ExecStart=/usr/local/bin/dynv6.sh %I.dynv6.net
[Install]
WantedBy=multi-user.target # /etc/systemd/system/dyndns@.timer
[Unit]
Description=Minutely dynv6 update
[Timer]
OnCalendar=minutely
Persistent=true
[Install]
WantedBy=timers.target then enable/start: sudo systemctl enable dyndns@MYHOSTNAME.timer
sudo systemctl start dyndns@MYHOSTNAME.timer |
This comment has been minimized.
This comment has been minimized.
Since the 2019-10-31 update this does no longer work. There is a new 'zone' parameter. I tried a few things like
What should the |
This comment has been minimized.
This comment has been minimized.
Use the zones ipv4.dynv6.com or ipv6.dynv6.com to enforce a specific IP protocol version. Bit I also felt |
This comment has been minimized.
This comment has been minimized.
I have the same problem. Since yesterday the update does not work anymore. |
This comment has been minimized.
This comment has been minimized.
Same issue here. Also https://dynv6.com/docs/apis currently is borked. |
This comment has been minimized.
This comment has been minimized.
Just got into the dynv6 here and same problem. |
This comment has been minimized.
This comment has been minimized.
Seems to be fixed now, without changing the url. |
This comment has been minimized.
This comment has been minimized.
Sorry, we introduced a bug that has been fixed in the meanwhile. |
This comment has been minimized.
This comment has been minimized.
I have a raspi behind a fritzbox acting as owncloud server. That worked well until Monday morning, when the IPv4 address got updated to |
This comment has been minimized.
This comment has been minimized.
Same here |
This comment has been minimized.
This comment has been minimized.
You can use Or better place it below
To allow using curl or wget, depending on your setup.
|
This comment has been minimized.
Would be great if this script has a "ipv4 only" option. In the moment it only works if you have a ipv6.