How to get Public IP in Linux Ubuntu Terminal?

By Hardik Savani May 1, 2024 Category : Ubuntu

Hi,

This is a short guide on how to get public ip address in ubuntu terminal. let’s discuss about how to get public ip address in linux terminal. We will look at an example of ubuntu get public ip command line. In this article, we will implement a ubuntu get public ip address command line.

To obtain your public IP address in a Linux Ubuntu 22.04 terminal, you can use various methods. One common approach is to use external services like `curl` or `wget` to fetch your IP address from the internet. Here are two methods you can use:

Method 1: Using `curl` with ifconfig.me:

Open your terminal and run the following command:

curl ifconfig.me

This command will make a request to the ifconfig.me service and display your public IP address in the terminal.

Method 2: Using `curl` with icanhazip.com:

You can also use the icanhazip.com service with `curl`:

curl icanhazip.com

This will provide your public IP address as a response.

Both methods will give you your public IP address. Choose the one that works best for you, as both services should provide similar results.

I hope it can help you...

Tags :
Shares