How To Find IP Address In Linux Using Terminal?

How To Find IP Address In Linux Using Terminal?


An IP address is a unique identifier that is assigned to each device connected to a computer network and uses Internet protocol for communication.

A computer uses this address to send data to a specific computer. IPv4 and IPv6 are two versions of IP addresses available nowadays. Every computer with an IP address has an IPv4 address and many of them are starting to use IPv6.

While troubleshooting network issues, setting up a new connection, configuring the firewall, etc you need to know the IP address of your system. So this article describes different methods for finding the IP address on a Linux system.

Classification of IP address

Generally, the IP addresses both IPv4  and IPv6 can be classified into two categories –

  • Public IP
  • Private IP

Public IP address –

The public IP address can be used anywhere on the internet for example every website that is accessible to everyone on the internet, has a unique IP address which is considered as public IP.

Private IP address

Private IP addresses are commonly used for local area networks such as home networks, offices, etc. Each device connected to a private network is assigned with unique IP addresses known as private IP.

Finding public IP address

You can find the public IP in your terminal by using tools such as curl, dig, wget, etc. There are many online services that provide public IP addresses. Now to find the IP address of your system use one of the given commands in your terminal –

dig ANY +short
curl -4/-6
wget -O - -q

OR if you are working on a system that has GUI then type ‘what is my ip’ in your browser to see your public IP address.

The IP address displayed here is an IPv4 public IP address.

Finding private IP address

To find the private IP address of a system you can use one of the commands that are given below –

hostname -I | awk '{print $1}'
ifconfig -a

This command will display the information of all the network interfaces that are currently up including the loopback interface. The highlighted part in the image is the private IP of the system which is a version 4 IP address.

nmcli -p device show

This command also displays information of different network interfaces on a system. The IP address highlighted in the image is the private IP which is also a version 4 of the IP addresses. You can also find the private IP version 6 in this information –

ip addr
ip route get | awk '{print $7}'


By using the above commands you can find the public and private IP addresses of a system. If you want to say anything on this topic then write us in the comments below.

Previous How To Use apt-mark Command In Linux?
Next How to enable desktop sharing through terminal

About author

You might also like

Networking 0 Comments

How To Use SCP to Copy From Local to Remote or vice-a-versa In Linux?

This post was last updated on May 6th, 2021 at 03:36 pmThere are various ways to copy a file or directory from remote to local or local to the remote

Networking 0 Comments

Setting Routes in Linux

This post was last updated on November 3rd, 2020 at 06:03 pm(Static Routes Page: static-routes.html) These methods of changing the route table don’t last accross reboots. Listed below are methods

Networking 0 Comments

DHCPD Quick Setup Instructions

This post was last updated on May 27th, 2020 at 04:44 pmSample of how to set up DHCPD server on Red Hat 7.0 Copy over the sample dhcpd.conf file cp


No Comments Yet!

You can be first to comment this post!

Leave a Reply