getlocalip_sample.sh (1130B)
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 24 case $1 in 25 -4) echo -n "8.8.8.8" # never append linefeed or simular 26 exit 0 27 ;; # IP's of Googles public DNS 28 -6) echo -n "2001:4860:4860::8888" 29 exit 0 30 ;; 31 *) echo "$0 - Invalid or missing parameter" >&2 32 exit 1 33 esac 34 echo "Should never come here" >&2 35 exit 2