In this guide, we will check out how to get public IP from a terminal on Ubuntu 22.04.
Get Public IP from Terminal on Ubuntu 22.04
There are lots of ways to get the IP address of a device which is connected to the Internet. Here we are finding the public IP from the terminal on Ubuntu.
So, let’s discuss several ways through which you can get public IP from the terminal on Ubuntu 22.04.
1: Use Dig command to get public IP address
Dig is an excellent utility that allows Linux users to get public IP from a terminal. The Dig along with the OpenDNS will help you in getting your public IP address on the terminal. The below-given command will be used for this purpose:
2: Use host command to get public IP address
You can also find the IP address using the host command that gives you a public IP address through DNS lookups. Run the following host command to get a public IP address:
3: Use wget command to get IP address
You can also get a public IP address using the wget piped with xarg command which is shown below:
Or use the following command incanzip service to get a public IP address:
There is another service as well that utilizes the wget command to provide you the public IP address:
You can also utilize wget command with ifconfig.me service to get the public IP address:
4: Use curl command to get IP address
Another way to get a public IP address from the terminal on Ubuntu is using the curl command. However, first you will need to install curl using the following command:
Once curl is installed, you can then use the following command with ifconfig.co to get a public IP address:
You can also use the curl command with ifconfig.me and it will give the public IP address on the terminal:
Or you can use the following curl command with icanhazip service to get public IP on your Ubuntu 2.04 terminal:
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.