How to Find Out Public IP Address via Command Line in Unix/Linux Machine

If you have more than 100 servers in your network; behind a firewall; lazy to access to documentation. Here is the alternative option to find out your machine’s public IP Address via command line

$ wget -q -O - |  grep -o -E '(^|[[:space:]])[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*([[:space:]]|$)'
# By default, FreeBSD doesn't have wget, you can use fetch instead
$ fetch -q -o - | grep -o -E '(^|[[:space:]])[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*([[:space:]]|$)'

You need port 80 external/WAN access to perform the task.