+5 votes
346 views
Find and view public web IP address with Linux commands

in Linux / Unix by (552k points)
reopened | 346 views

1 Answer

+3 votes
Best answer

1. View public IP with commands using the dig utility in Linux
2. View public IP with commands using the host utility in Linux
3. View public IP with commands using wget Command Line Downloader on Linux
4. View public IP with commands using curl Command Line Downloader on Linux

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 

image

 

 

 


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}' 
image

 

 

 


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 
image

 

 

 


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 

 

 

image

 

With these simple options we can discover the public IP address of our network..

 


by (3.5m points)

Related questions

+5 votes
1 answer
asked Nov 14, 2019 in Linux / Unix by backtothefuture (552k points) | 278 views
+5 votes
1 answer
+3 votes
1 answer
asked Nov 18, 2019 in Linux / Unix by backtothefuture (552k points) | 461 views
+5 votes
1 answer
asked Jun 5, 2020 in Linux / Unix by backtothefuture (552k points) | 355 views
+3 votes
1 answer
asked Aug 9, 2019 in Guides by backtothefuture (552k points) | 351 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users