in

LinuxLinux

How to Find IP Address in Linux?

Different ways to find the IP Address of your system or any server in Linux!

F

ind IP Address in Linux: IP Address is an unique address which represents the address of the physical hardware. Each and every hardware contains its own IP address & Mac Address. The IP address helps to point the certain hardware and to access the data and information.

IP Address plays a vital role in networking. Knowing the IP Address will help a lot in networking, pointing the server and more. An IP address can be classified into two types and they are Public and Private IP Address. An IP address that can be accessed through the internet is called Public IP & the IP address accessed only on the private network is called Private IP Address. There are two types of IP address versions and they are IPv4 & IPv6 version. In this tutorial, we explained the different ways to find the IP address of your pc and external server in Linux.

Jump To:

Find your Public IP Address in Linux:

As we told above, Public IP Address is a unique IP Address that every hardware have and it can be accessed globally through the internet. They are assigned to the device by its ISP (Internet Service Provider) and each device has a unique IP address. These IP addresses are used by Mail Server, Host provider, and Internet providers.

Finding the Public IP address involves contacting remote server in any location through the HTTP or HTTPS or DNS protocol and obtain the public IP Address from the remote server response. To find the IP Address, you can use the ping command, traceroute, curl & dig command.

Check this too  Whereis Command in Linux: Syntax, Commands & Examples.

Some external DNS provider helps us to find the public IP address, you can use the below commands to find the public IP address, Mac address.

$dig ANY +short @resolver2.opendns.com myip.opendns.com

The output of the above command will show you the public IP address in your Linux PC.

Public IP Address
Public IP Address
$dig ANY +short @ns1-1.akamaitech.net ANY whoami.akamai.net

The output of the above command is,

Find IP Address
Find IP Address

You can use the curl command to find the IP address in Linux terminal, use the below command:

$curl -s https://checkip.amazonaws.com

The output of the above command is,

Find IP Address using CURL
Find IP Address using CURL

The above image shows the public IP address of your device.

Alternatively, you can use the below commands to find the public IP address through the Linux Terminal.

$curl -s api.infoip.io/ip
$wget -O - -q https://icanhazip.com/

This is the easiest way to find the public IP address from the Linux Terminal.

Find Private IP Address in Linux:

As we said earlier, Private IP address is an address that cannot be accessed through the internet. The devices which are connected in a network which follows NAT (Network Address Translation) protocol is called Private network. The IP address assigned to the private network is called private IP address.

The IPv4 address ranges: 10.0.0.0/8172.16.0.0/12192.168.0.0/16 are reserved for private IP address.

You can find the private IP address in Linux using the following commands,

$hostname -I
The output of the above command is,

[email protected]:~$ hostname -I
192.168.1.102 2409:4072:916:f651:9914:e8bd:ba85:75da 2409:4072:916:f651:84c1:5643:1076:8465 
[email protected]:~$ 

You can find the below commands as the alternating ways to find the Private IP Address through the Linux Terminal.

$ip addr
$ifconfig

Verdict:

That’s it. This is the easiest way to find the public and private IP address in Linux PC. If you have any queries and then comment us below.

Check this too  25+ VI Command in Linux: Essential VI Editor Command Tutorials
Article Review
  • Article Explanation
  • Images Explanation
  • Commands Provided
  • Alternate commands
4.9

Summary

For more articles, kindly visit our HomePage

Leave a Reply

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

Written by Rachel

I'm Rachel, From Arizona. Am playing the "Content Management" Role in Tec Robust. I started working in TR from Jan 2019. Big Marvel Fan.

Contact me:
tecrobust [@] gmail.com
Sub: Message to Rachel

Traceroute Command For Linux

Traceroute Command For Linux: Syntax & Examples

Install PIP on Debian 10

How to Install PIP for Python 2, Python 3 on Debian 10?