Advertisement
howtophil

noip-ipv6-lynx-duc.sh

Jul 21st, 2022 (edited)
675
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.67 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #------------------------------------------------------------
  4. # This is a modification of the script found here:
  5. # https://github.com/TheGuywithTheHat/noip-ipv6-duc
  6. # The original dev wrote it because the noip-duc
  7. # tends to ignore ipv6 changes.
  8. # I could not get it to work with curl (as in the original).
  9. # So, I use lynx -dump and also toss errors into /dev/null
  10. # to keep it running.
  11. # I have probably introduced some bugs.
  12. # This works for me. Might not for you. Original might be
  13. # better for your purposes... who knows?
  14. # I make no guarantees about the reliability of this script.
  15. # -Phillip J Rhoades
  16. #------------------------------------------------------------
  17.  
  18. interface="YOUR NETWORK INTERFACE (eth0,wps,etc)"
  19. user="YOUR-NOIP-EMAIL-USERNAME"
  20. pass="YOUR-NOIP-PASSWORD"
  21. hostname="YOUR.NOIP.HOST.NAME"
  22.  
  23. url="https://dynupdate.no-ip.com/nic/update"
  24. agent="Personal noip-ducv6/linux-v1.0"
  25.  
  26. lastaddr=''
  27.  
  28. update_ip () {
  29.     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)
  30.     if [[ $lastaddr != $addr ]] && [[ $addr != "" ]]; then
  31.         echo "updating to $addr"
  32.     set -e
  33.     out=$(lynx -auth="$user:$pass" -dump "https://dynupdate.no-ip.com/nic/update?myipv6=$addr&hostname=$hostname" 2>/dev/null)
  34.         echo $out
  35.         if [[ $out == nochg* ]] || [[ $out == good* ]]; then
  36.             lastaddr=$addr
  37.         elif [[ $out == 911 ]]; then
  38.             echo "911 response, waiting 30 minutes"
  39.             sleep 25m
  40.         else
  41.             echo "FINE"
  42.             #exit 1
  43.         fi
  44.     fi
  45. }
  46.  
  47. update_ip
  48. while sleep 5m; do
  49.     update_ip
  50. done
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement