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.
In this tutorial, i am going to show you how to get public ip from terminal or command line on linux ubuntu 22.04.
How to Get Public IP from Terminal on Linux Ubuntu 22.04
Just use the same 4 methods to find or get public ip from command line or terminal on linux ubuntu 22.04:
- Use Dig command to get public IP address
- Use host command to get public IP address
- Use wget command to get IP address
- Use curl command to get IP address
Use Dig command to get public IP address
Run 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
Run 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
Run 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
Run the following command on the command line to install curl ; is as follows:
$ sudo apt install curl
Once curl is installed, run the following command with ifconfig.co to get a public IP address:
$ curl ifconfig.co
Also i can use the curl command with ifconfig.me and it will give the public IP address on the terminal:
$ curl ifconfig.me && echo
Or i can use the following curl command with icanhazip service to get public IP on your Ubuntu 22.04 terminal:
$ curl icanhazip.com && echo
Conclusion
In this tutorial, i have shown you how to get public ip from command line linux ubuntu 22.04.
Be First to Comment