×

You can determine the IP address or addresses of your Linux system by using the hostname, ifconfig , or ip commands. 

To display the IP addresses using the hostname command, use the -I option.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform Ubuntu Server related queries.

As per our earlier posts, we dealt with some methods of finding your private IP address in Ubuntu 20.04

In this context, we shall look into the methods of finding your public IP address.


How to Find Your Public IP address in Ubuntu 20.04 LTS ?

Here, you will learn some methods to find Public IP Address in Ubuntu 20.04. You can also apply same on other Linux distributions. 


1. Using Google to Find Your Public IP address in Ubuntu ?

To implement this, Open your Google Chrome browser and search with the keyword "what is my ip". Google will show your public IP.


2. Querying the DNS providers to Find Your Public IP address in Ubuntu ?

Many DNS providers will let you access your public IP address information.


i. Using dig command

You can access your public IP address information from your DNS provider by using any of the following dig commands:

dig +short myip.opendns.com @resolver1.opendns.com
dig ANY +short @ns1-1.akamaitech.net ANY whoami.akamai.net

ii. Using host command

You can also query your public IP address information from your DNS provider by using the following host command.

host myip.opendns.com resolver1.opendns.com

Also,  You can further narrow the answer by using grep and awk in your command:

host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}'


3. Using Online Services to to Find Your Public IP address in Ubuntu ?

Several online services provide your public IP address information. 

For example, you can access this information by downloading files from these service providers.

a. IP Echo Service: ipecho.net

b. icanhazip.com

c. ifconfig.co

d. Ifconfig.me

e. ipinfo.io


i. Using wget command

First, install wget using the following command and enter your password if prompted:

sudo apt update && sudo apt install wget -y

Then, you can use any following wget command to find your public IP from the mentioned service providers:

wget -qO- http://ipecho.net/plain | xargs echo
wget -qO- ifconfig.co
wget -qO- ifconfig.me | xargs echo
wget -qO- https://ipinfo.io/ip

ii. Using CURL command

First, install cURL using the following command and enter your password if prompted:

sudo apt update && sudo apt install curl -y

You can then use these CURL commands to find your public IP from service providers:

curl ifconfig.co
curl ifconfig.me && echo
curl icanhazip.com && echo
curl https://ipinfo.io/ip


[Need urgent assistance to perform Linux based Installation tasks? We are available. ]


Conclusion