howtophil icon

noip-ipv6-lynx-duc.sh

howtophil | PRO | 07/21/22 03:12:21 PM UTC (Edited) | 0 ⭐ | 973 👁️ | Never ⏰ | []
Bash |

1.67 KB

|

None

|

0 👍

/

0 👎

#!/bin/bash
 
#------------------------------------------------------------
# This is a modification of the script found here:
# https://github.com/TheGuywithTheHat/noip-ipv6-duc
# The original dev wrote it because the noip-duc
# tends to ignore ipv6 changes.
# I could not get it to work with curl (as in the original).
# So, I use lynx -dump and also toss errors into /dev/null
# to keep it running.
# I have probably introduced some bugs.
# This works for me. Might not for you. Original might be
# better for your purposes... who knows?
# I make no guarantees about the reliability of this script.
# -Phillip J Rhoades
#------------------------------------------------------------
 
interface="YOUR NETWORK INTERFACE (eth0,wps,etc)"
user="YOUR-NOIP-EMAIL-USERNAME"
pass="YOUR-NOIP-PASSWORD"
hostname="YOUR.NOIP.HOST.NAME"
 
url="https://dynupdate.no-ip.com/nic/update"
agent="Personal noip-ducv6/linux-v1.0"
 
lastaddr=''
 
update_ip () {
    export addr=$(ip -6 addr show dev $interface | sed -e'/inet6/,/scope global/s/^.*inet6 \([^ ]*\)\/.*scope global.*$/\1/;t;d'|head -n1 2>/dev/null)
    if [[ $lastaddr != $addr ]] && [[ $addr != "" ]]; then
        echo "updating to $addr"
    set -e
    out=$(lynx -auth="$user:$pass" -dump "https://dynupdate.no-ip.com/nic/update?myipv6=$addr&hostname=$hostname" 2>/dev/null)
        echo $out
        if [[ $out == nochg* ]] || [[ $out == good* ]]; then
            lastaddr=$addr
        elif [[ $out == 911 ]]; then
            echo "911 response, waiting 30 minutes"
            sleep 25m
        else
            echo "FINE"
            #exit 1
        fi
    fi
}
 
update_ip
while sleep 5m; do
    update_ip
done
 

Comments