3 Ways to Check IP address in Linux

Table of Contents

IP addresses are used in a system for communication. Knowing the IP address of our system can be useful in many situations.
It is a numerical label such as 192.0.2.1 that is connected to a computer network that uses the Internet Protocol for communication.

An IP address serves two main functions: network interface identification and location addressing.

In this article, we are going to show how to find the IP address in the Linux system.

Check Ip address with ip addr command

The “ip addr” command is the most common way for quickly finding the IP address of a system.

All we need is to open the Terminal then type ip addr in the prompt that appears.

  • ip addr – Show information for all addresses
  • ip addr show dev em1 – Display information only for device em1

The above commands will list the network interfaces along with their details which include interface status, IP address, MTU size, etc.

For the private IP address, look for the line that reads “inet”. The number in front of it is our IP address.

Get Ip address with ifconfig command

The “ifconfig” command is another most common command used to view IP related information.

To use this command to find the IP address, just type “ifconfig -a” in the shell prompt.

This command will list all the network interfaces along with their details which include interface status, IP address, MTU size, etc.

If we are only interested in certain interfaces, eth0, etc. then: ifconfig eth0

Find Ip address with ip route command

The “ip route” command can also be used to find the IP address of a system. In order to find the IP address of a system, use the command as follows:

$ ip route
This command will print out the IP address of our system along with other network details.

Once we execute the command we will see an output similar to the text below.

default via 203.0.113.1 dev eth0
203.0.113.0/24 dev eth0 proto kernel scope link src 203.0.113.86
198.51.0.0/16 dev eth0 scope link metric 1002

This information shows us the server’s IP routing table, which is essentially a set of rules used to determine where data will be directed.

When using this technique to find a server’s IP, we will want to notice the lines containing `src` followed by an IP address.

On these lines, the IP address following `src` are the IP(s) configured on the server.

Any device using IP addresses will have a routing table that is used to determine the behavior of the networking devices. In the example above, we can see the servers routing table, showing that the server has an IP address of `203.0.113.86`.

Table of Contents

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn

You might also like