Loading...
Networking Concepts

How to know Public IP Address

Displaying the public IP address
If you want to know the public IP address of a Linux server, you can send an HTTP request to one of the following web servers.

http://ifconfig.me
http://www.icanhazip.com
http://ipecho.net/plain
http://indent.me
http://bot.whatismyipaddress.com
https://diagnostic.opendns.com/myip
If the Linux system is connected directly to the internet, the public and private IP addresses will be the same. However, in most cases they differ. Here is an example using the curl command.

$ curl ifconfig.me
92.68.87.45
$ curl icanhazip.com
92.68.87.45
$ curl ipecho.net/plain
92.68.87.45
$ curl ident.me
92.68.87.45
$ curl bot.whatismyipaddress.com
92.68.87.45
$ curl https://diagnostic.opendns.com/myip
92.68.87.45
You can also achieve the same result with wget by enabling quiet mode with -q and sending the output to standard output (STDOUT) with -O-.

$ wget -qO- ifconfig.me
92.68.87.45
There’s yet another way to determine your public IP address. Perform a DNS lookup against myip.opendns.com. It’s a service provided by OpenDNS and it’s lightening fast!

$ dig +short myip.opendns.com @resolver1.opendns.com
92.68.87.45

Leave a Reply

Your email address will not be published. Required fields are marked *