Unix Shell – Finding the Public IP Address in a Shell Script

shellunix

I can find my IP address using ifconfig or hostname -i command.

But how do I find my Public IP?

(I have a static public IP but I want to find it out using unix command)

Best Answer

curl ifconfig.me

curl ifconfig.me/ip (for just the ip)

curl ifconfig.me/all (for more info, takes time)

For more commands visit: http://ifconfig.me/#cli_wrap