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:
- 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
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.