Methods to detect public IP address in bash
If on an AWS EC2 you can use:
curl checkip.amazonaws.com
NOTE: this service can be used from any web client.
curl ipinfo.io/ip
Or
wget -q -O - ipinfo.io/ip
Or
lynx -source ipinfo.io/ip
get public ip address
curl ifconfig.me
would be the best choice, in case you don't have curl:
wget -qO- ifconfig.me/ip