Checking your Public IP address (Linux/Mac)

The script below allows you to check your public IP. This is handy when say you work on a VPN and want to quickly check that you’re still connected (by seeing that your IP is in your organizations VPN IP address range), or like many folks behind a NAT router.

Note, use this script responsibly, or else the website might go down. I.e. call it not more than once per ten minutes or something.

Note: currently the script does not check for a blank i.e. no text reply, this would be straightforward to do..

#gets public IP address and displays in Terminal
# Michael Hirsch

url=('' '' '')

for u in ${url[@]}; do
if curl -m 4 $u; then echo; break