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

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 - http://ipchicken.com |  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 - http://www.ipchicken.com | grep -o -E '(^|[[:space:]])[0-9]*.[0-9]*.[0-9]*.[0-9]*([[:space:]]|$)'

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


(Source : http://systems.takizo.com)