How to Get Public IP in Linux Ubuntu 22.04 Terminal

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 in Linux Ubuntu 22.04 Terminal

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

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including 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. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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