Ubuntu

How to Find Your Public IP address in Ubuntu 20.04 LTS

Find Public IP Address Ubuntu 20.4

In one of my earlier posts, I have shown you the methods of finding your private IP address in Ubuntu 20.04. This post is dedicated to all the methods of finding your public IP address.

We have used Ubuntu 20.04. However, some of the below methods may also be used in other Linux distributions.  Here we go.

Finding Public IP Address in Ubuntu 20.04

Method 1: Using Google

Open your Google Chrome browser and search with the keyword “what is my ip’. Google will show your public IP.

Method 2: Querying the DNS providers

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

Method 1: 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

Method 2: 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

Or 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}'

Method 3: Using Online Services

Several online services provide your public IP address information. For example, you can access this information by downloading files from these service providers.

  1. IP Echo Service: ipecho.net
  2. icanhazip.com
  3. ifconfig.co
  4. Ifconfig.me
  5. ipinfo.io

Method 1: 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

Method 2: 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

I hope you have learned from this article. Comment below for any problem or suggestion, thank you and have a good day.

Similar Posts