You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.1 KiB

  1. #!/bin/sh
  2. #
  3. # sample script for detecting local IP
  4. # 2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
  5. #
  6. # activated inside /etc/config/ddns by setting
  7. #
  8. # option ip_source 'script'
  9. # option ip_script '/usr/lib/ddns/getlocalip_sample.sh -6' !!! parameters ALLOWED
  10. #
  11. # the script is executed (not parsed) inside get_local_ip() function
  12. # of /usr/lib/ddns/dynamic_dns_functions.sh
  13. #
  14. # useful when this box is the only DDNS client in the network
  15. # IP adresses of "internal" boxes could be detected with this script
  16. # so no need to install ddns client on every "internal" box
  17. # On IPv6 every internal box normally has it's own external IP
  18. #
  19. # This script should
  20. # - return the IP address via stdout echo -n "...." !!! without line feed
  21. # - report errors via stderr echo "...." >&2
  22. # - return an error code ('0' for success) exit 123
  23. case $1 in
  24. -4) echo -n "8.8.8.8" # never append linefeed or simular
  25. exit 0
  26. ;; # IP's of Googles public DNS
  27. -6) echo -n "2001:4860:4860::8888"
  28. exit 0
  29. ;;
  30. *) echo "$0 - Invalid or missing parameter" >&2
  31. exit 1
  32. esac
  33. echo "Should never come here" >&2
  34. exit 2