123456789101112131415161718192021222324252627 |
- #! /bin/bash
- # This script will determine the current IPv6 address of the host and call
- # an external URL to update the dynamic dns entry
- user=""
- password=""
- server_url=""
- if [ -e /tmp/dnsping_oldaddr ];
- then
- old_addr=$(cat /tmp/dnsping_oldaddr)
- else
- old_addr=""
- fi
- new_addr=$(ip -o -6 addr | grep -v -e fc00:: -e fd00:: | grep global | grep -v "preferred_lft 0sec" | grep -v temporary | awk '{print $4}' | cut -d "/" -f 1)
- if [ "$old_addr" != "$new_addr" ];
- then
- if [ ! -z "$new_addr" ];
- then
- echo "detected new ip address: $new_addr"
- curl --user ${user}:${password} "https://${server_url}/?ipv6=$new_addr"
- echo "$new_addr" > /tmp/dnsping_oldaddr
- fi
- fi
|