3 # sample script for detecting local IP
4 # 2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
6 # activated inside /etc/config/ddns by setting
8 # option ip_source 'script'
9 # option ip_script '/usr/lib/ddns/getlocalip_sample.sh -6' !!! parameters ALLOWED
11 # the script is executed (not parsed) inside get_local_ip() function
12 # of /usr/lib/ddns/dynamic_dns_functions.sh
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
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
25 -4) echo -n "8.8.8.8" # never append linefeed or simular
27 ;; # IP's of Googles public DNS
28 -6) echo -n "2001:4860:4860::8888"
31 *) echo "$0 - Invalid or missing parameter" >&2
34 echo "Should never come here" >&2