27.7 C
Jaipur
Wednesday, September 22, 2021

How to Find the IP Address in Linux

Must read

An IP address is a unique address that identifies a device on the internet or a local private network. Every computer in the network requires its own unique IP address to get identified. There are two different IP addresses: private and public. A computer can be assigned private IPs or public IP or both.

A public IP is an address that is exposed to the internet. Devices that are assigned public IP can be accessed from the internet. Whereas private IP is accessible to a local internal network.

In this tutorial, we learn the different ways to find the IP Address of a Linux system.

Find Your IP address Using CLI

Private IP is assigned to devices such as laptops, printers, phones for internal communication. If this machine needs to communicate outside the world then needs to use a router.

Address ranges used by private networks are the following:

  • 10.0. 0.0 to 10.255. 255.255.
  • 172.16. 0.0 to 172.31. 255.255.
  • 192.168. 0.0 to 192.168. 255.255.

There are few commands available in Linux to find the IP address. The popular command is ip.

To display all the network interfaces and their assigned IP address, type:

$ ip addr
show IP address using ip command

There are few more commands which can display the private IP address of your system.

$ ifconfig
$ hostname - I
$ nmcli
$ ip route get 1.2.3.4 | awk '{print $7}'

Find Your IP Address Using GUI

If you are running Linux in a graphical environment, you can easily navigate to the Network settings to find the IP address. Here I am using the Ubuntu GNOME interface.

In the Gnome desktop, top-right click on the ‘Network’ icon.

network icon on gnome desktop

.

From the drop-down menu click on ‘Wired Connected’.

Wired Connected

 Next, click on the ‘Wired Settings’ option that appears below

Wired Settings

This displays the ‘Network Settings’ window. Click on the gear icon, in the new windows the first tab ‘Details’ shows the IP address of the system.

Wired - Details tab

Find Your Public IP Address

A public IP address is an IP address that can be accessible from the internet. Normally public IP is assigned to the network router by ISP (for example your home router), servers that host websites, VPN, FTP, etc.

Address range used by public networks is 0.0.0.0 to 255.255.255.255 (excluding private IP addresses, few unusable and reserved IPs).

As public IP is globally routable, we can use the help external website, HTTP/HTTPS services, dig or curl command to display public IP.

The simplest way to find the public IP address is to open the following website on any browser.

https://www.whatismyip.com

You may also use the following commands to find the public IP address:

$ curl ipinfo.io/ip
$ curl ifconfig.me
$ curl checkip.dyndns.org
$ curl ipecho.net/plain
$ curl -s https://checkip.amazonaws.com
$ dig ANY +short @ns1-1.akamaitech.net ANY whoami.akamai.net

Conclusion

In this tutorial, we learn the different ways to find the IP Address of a Linux system. Those include finding both private and public IP address using commands and other services.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -

Latest article