Thanks to Guillermo Garron .
Lots of times you need to determine your public IP address, if you are using Linux operating system to power your PC, you may use some good console commands to guess your public IP address.
Most of these methods will return you the local IP and not the public IP of your proxy if you are behind one.
wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
That will return your local IP
curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
That one is going to give your current IP, being it public or private. Something like running
That is going to return you the public IP you are using to access internet. If you are behind a NAT or proxy, it will the IP of that proxy.
lynx -dump ifconfig.me | grep 'IP Address'
That is also going to return your public IP.
As you can see, there are a lot of ways to check your Public IP address using console commands in Linux. Of course you can always open a browser and enter any of those URIs and check there.
Thanks to Chris Ergatides
Last year I wrote about a little script I use to query checkip.dyndns.org for my current IP address from the Linux CLI. dyn’s checker has served me well over the years and has been rock solid stable, which is why I chose it.
A problem has come about however whereby it is returning a private IP address (192.168.xxx.xxx) which it is taking from the X-Forwarded-For value, rather than ignoring it purely because of the fact that it is a private (internal) IP.
So here is my new script, in its entirety:
If you visit ifconfig.me, on the bottom half of the page you will find a handful of other information you could extract. Now let’s hope that ifconfig.me sticks around for a while