In the world of networks or networking there are a series of basic terms that we must take into account since they will be necessary when we provide some type of support at the equipment level. The public or private IP are always harping on all network administrators..
The concept basics, but also one of the most important, is the IP address, remember that IP stands for Internet Protocol - Protocol Internet and which has been developed as a unique, numeric, ID which is assigned to a device connected to the network, both temporarily or permanently, that is, it is like our identity document.
Thanks to the IP address it is possible to identify a computer on the local or global network, or detect its location thanks to commands such as ping or similar..
IP addresses are classified into two types:
- IPv4 address: It is the one currently used and is made up of four octets (8-bit numbers).
- IPv6 address: It is the future of IP addresses and they are based on 128 bits.
These addresses can be assigned as static or private depending on the worst situation. Today we will focus on how to know the public IP address in Linux since locating the private one is simple.
To stay up to date, remember to subscribe to our YouTube channel! SUBSCRIBE
1. View public IP with commands using the dig utility in Linux
The dig (domain information groper) tool is a command tool created to test DNS name servers. If what you want is to be able to verify public IP addresses, we can make use of the resolution of opendns.com by executing the following command:
dig + short myip.opendns.com @ resolver1.opendns.com
2. View public IP with commands using the host utility in Linux
The host command is an easy-to-use command-line utility for performing DNS lookups. With the following command we can see the public IP address of the operating system:
host myip.opendns.com resolve1.opendns.com | grep "myip.opendns.com has" | awk '{print $ 4}'
3. View public IP with commands using wget Command Line Downloader on Linux
The wget command is a powerful command line downloader that supports various protocols such as HTTP, HTTPS, FTP, and many more. It can be used with third party websites to view the public IP address by executing one of the following commands:
wget -qO- http://ipecho.net/plain | xargs echo wget -qO - icanhazip.com
4. View public IP with commands using curl Command Line Downloader on Linux
The curl command is a popular command line tool for uploading or downloading files from a server using any of the supported protocols (HTTP, HTTPS, FILE, FTP, FTPS, and others). The following commands will display the system's public IP address:
curl ifconfig.co curl ifconfig.me curl icanhazip.com
Note
In case of not having curl in the system we can install it by executing the following command:
sudo apt install curl
With these simple options we can discover the public IP address of our network..