1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#!/usr/bin/env bash # Detect an external IP address # Use random services for checking array=( ipinfo.io/ip ifconfig.me ipecho.net/plain icanhazip.com v4.ident.me checkip.amazonaws.com ) size=${#array[@]} index=$(($RANDOM % $size)) curl --silent ${array[$index]} | tr -d "[:space:]" && echo