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 ifconfig to set MAC address in Linux, Unix, FreeBSD etc.

This post was last updated on November 10th, 2020 at 08:11 pmLinux has a built-in command ifconfig that is used to configure wired network interfaces. In this article I am

Networking 0 Comments

How To Copy A File/Directory From Local To Remote Machine In Linux / FreeBSD?

This post was last updated on August 1st, 2020 at 04:20 pmThere are various ways to copy a file or directory from remote to local or local to the remote

System Admin 0 Comments

SAMBA in Linux – Administration Checklist

This post was last updated on May 27th, 2020 at 05:04 pm Contents1 Samba startup guide checklist:2 Getting SWAT to work in RH70 Samba startup guide checklist: This applies to


No Comments Yet!

You can be first to comment this post!

Leave a Reply