Files
Misc-Scripts/get-wanip.sh
2023-11-13 18:00:53 -06:00

19 lines
461 B
Bash
Executable File

wanip="$(dig +short myip.opendns.com @resolver1.opendns.com)" >/dev/null 2>&1
if [ "${wanip}" == "" ]; then
wanip="$(host myip.opendns.com resolver1.opendns.com)" >/dev/null 2>&1
if [ "${wanip}" == "" ]; then
wanip="$(curl https://ipinfo.io/ip)" >/dev/null 2>&1
if [ "${wanip}" == "" ]; then
wanip="$(wget -qO- https://ipecho.net/plain ; echo)" >/dev/null 2>&1
else
echo "WAN IP could not be found"
exit 1
fi
fi
fi
echo "${wanip}"
exit 0