Learn how to Discover the Public IP Deal with on a Linux System

Would you like to know the public IP address of your Linux system? Here are three ways you can find your public IP.

IP addresses are the backbone of how the Internet works. There are two basic types of IP addresses: public and private. Public IP addresses are used to connect to external networks, while private IP addresses are used to identify devices connected to your local network.

There are several methods you can use to get your public IP address on Linux. This article briefly explains how to use the host command, dig command, and some external services to find out your system's public IP address.

Get the public IP address with the host command

The host The utility provides access to DNS-related information, including the public IP address of your Linux computer. If you run this command with no options, it will display the name, address, and public IP of your DNS server.

host myip.opendns.com resolver1.opendns.com

You can search for the output line that contains the public IP and display it with the awk Command.

host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk & # 39; {print $ 4} & # 39;

Using the dig

The Dig utility on Linux is another useful tool for getting DNS data associated with your computer. You can get the public IP address on Linux with the following dig command.

dig + short myip.opendns.com @ resolver1.opendns.com

Related: What is a Static IP Address? Here's why you don't need one

Use external services

Many third party services can display your public IP address. You can access most of these services with the Curls or wget Usefulness. The following commands take advantage of some of these services.

Curl https://ipinfo.io/ip; echo
wget -qO- https://ipecho.net/plain; echo

The commands above will get the public IP address from the ipinfo.ip website.

Curl https://ipecho.net/plain; echo
wget -qO- https://ipecho.net/plain; echo

In these examples, your public IP address is obtained from the ipecho.net web service.

Curl https://ifconfig.me; echo
wget -qO- https://ifconfig.me; echo

The ifconfig.me website provides the IP information for the above commands. Many other websites are available on the internet that offer similar services.

Finding your public IP address on Linux

You can easily find out your public IP address using any of the methods above. The main advantage of these approaches is that they will display the correct IP address even if you are behind a NAT router. Anyone can use it to determine their public Internet address.

The network packets transmitted over the Internet follow a specific model that forms the basis for digital communication. The OSI model is responsible for data transmission and communication between two or more devices that are connected to either the same or different networks.

What is the OSI model? The Open Systems Interconnection Model explained

How does your computer actually communicate with the internet?

Continue reading

About the author

Rubaiat Hossain
(15 articles published)

Rubaiat is a CS graduate with a strong passion for open source. As well as being a Unix veteran, he's also been into network security, cryptography, and functional programming. He is an avid collector of used books and has an endless admiration for classic rock.

By Rubaiat Hossain

Subscribe to our newsletter

Sign up for our newsletter to receive tech tips, reviews, free e-books, and exclusive offers!

One more step …!

Please confirm your email address in the email we just sent you.

Leave a Reply

Your email address will not be published. Required fields are marked *