How to Get Public IP from Terminal on Linux Ubuntu 22.04

How to Get Public IP from Terminal on Linux Ubuntu 22.04

Get public ip from terminal or command line on linux ubuntu 22.04; Through this tutorial, we will learn how to get public ip from terminal or command line on linux ubuntu 22.04.

The public IP address is an address that you received from the internet service provider. It is always known to the IPS. There are numerous methods to find the public IP address, all are discussed in this guide. Try all those commands as they need a third-party service to provide your public IP address.

How to Get Public IP from Terminal on Linux Ubuntu 22.04

Use the following 4 ways to find or get public ip from command line or terminal on linux ubuntu 22.04:

  1. Use Dig command to get public IP address
  2. Use host command to get public IP address
  3. Use wget command to get IP address
  4. Use curl command to get IP address

Use Dig command to get public IP address

Execute the following dig command on the command line to get public IP address on the terminal; is as follows:

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

Use host command to get public IP address

Execute the following command with host on the command line to get public IP address on the terminal; is as follows:

$ host myip.opendns.com resolver1.opendns.com

Use wget command to get IP address

Execute the following command on the command line to get public IP address on the terminal using wget command; is as follows:

$ wget -qO- http://ipecho.net/plain | xargs echo

Use curl command to get IP address

Execute the following command on the command line to install curl ; is as follows:

$ sudo apt install curl

Once curl is installed, execute the following command with ifconfig.co to get a public IP address:

$ curl ifconfig.co

Also we can use the curl command with ifconfig.me and it will give the public IP address on the terminal:

curl ifconfig.me && echo

Or we can use the following curl command with icanhazip service to get public IP on your Ubuntu 22.04 terminal:

curl icanhazip.com && echo

Conclusion

Get public ip from command line linux ubuntu 22.04; Through this tutorial, we have learned how to get public ip from command line linux ubuntu 22.04.

Recommended Linux Ubuntu Tutorials

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

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