Home > How To

How to Check IP Address in Linux

Reviewed By: Kevin Pocock

Last Updated on July 15, 2024
How to Check IP Address in Linux Using Different Methods
You can trust PC Guide: Our team of experts use a combination of independent consumer research, in-depth testing where appropriate - which will be flagged as such, and market analysis when recommending products, software and services. Find out how we test here.

There are different methods to check IP addresses in your Linux OS. There are various commands that you can use for this purpose. You must open your Linux terminal. Type in some specific commands to find your IP address. Upon pressing enter, the screen will display the IP addresses of all network interfaces you use. This guide will show you which commands will help you check your IP address in Linux OS, so carry on reading. 

What is an IP Address? 

Before we get to those commands, let’s find out what’s an IP address? This is especially the case, if you are not sure about it already. IP addresses are used within a system developed to establish communication between devices. 

It is a numerical label that looks something like in format. It serves two main objectives; location addressing and identification of network interface.

It has all the information regarding the user’s location. Therefore, the devices are available for 2-way communication. However, most ISPs or service providers still go with IPv4, which is 32-bit. Hence, four numbers range from 0 – 255, with dots separating them. 

Different Methods to Check IP Address in Linux

There are various commands that you can use to check your IP address on Linux OS. Here are some of them that you can use:

  • ip addr
  • ip route show dev eth0
  • ip route
  • ifconfig eth0
  • ip addr show eth0
  • ifconfig -a

Finding IP address in Linux using “ip addr”

By far, this method is among the best for finding IP addresses on Linux. 




Open Terminal

All you have to do is to open your terminal on Linux and type in the command. The number that you will get in front of the inet is your IP address.



Using the command

Using the command, you can also find out about your IP address, MTU size, MAC address, and other info regarding your network interface. You can also change IP address in the prompt.

The following are some commands you can use with this command on Linux. 

  • ip addr” will display an IP address, including all interfaces.
  • ip addr show dev em1” will display info only for the em1 device.
  • ip addr show up” will display the IP for all your running interfaces.

The ip addr command shows info for all interfaces on Linux by default. Consider this example below that shows three network interfaces ens3, and l0. The ens3 IP address →


Finding IP address using “ip addr show dev”

This command comes in handy to view IP addresses for a particular network. It goes,

ip addr show dev interface_name

It will display your IP for a particular interface. Therefore, if you’re looking for info on one specific device, such as eth1, then you can choose this command. 

This command is used to list the info about your running interface. So, you will get all the info about all IP addresses running on your system.

You can also use the ip addr command for adding or deleting IPs for a particular network interface.

Various other options can also be used with this command. For instance, if you are looking for more info, just type in “ip addr help”.


Finding IP address using the “ifconfig” command

This is another option you can use to find out your IP address on Linux OS. You will only have to type in ifconfig -a in the prompt. However, if you only want the info about specific interfaces, such as ens3, you must type ifconfig ens3.


Finding IP address using “ip route”

You can use this command for finding an IP address on Linux OS. It will display the IP of your system with all other details about the network. Once you have executed the command from the prompt, the following result will be displayed on your screen. 

This information shows the routing table of your server’s IP. These are the some rules that are used to find out where the data should be directed to. 

When you are using the ip route method to find the IP address, you need to notice those lines that contain “src” following the IP address. In the same lines, your IP addresses showing are the ones that are configured on that server. 


Using the Bash script to check the IP address on Linux

You can find the list of network interfaces along with IPv4 addresses your server has, if you use this. 

ip -4 -o a | cut -d ‘ ‘ -f 2,7 | cut -d ‘/’ -f 1

What you will get as a result will contain interface names in the left-hand panel and IP addresses in the right-hand panel. 

Let us assess this particular command in detail: 

  • ip -4 -o a” section will display each record within a line. The line fields are replaced by “\.” This will come in handy when you need your IP in bash script. 
  • cut” section extracts a specific subset of lines or columns from the file you are targeting. 
  • -d” option focuses the delimiter in separate fields. 
  • -f” option is for the field numbers to be extracted. 

For instance, cut -d’,’ -f1,3 xyz.txt will extract 1st and 3rd columns from all the lines within the xyz.txt with the help of commas as a delimiter. 


Finding public IP on Linux

If you want to get a public IP, you can conveniently use Google for it. Just type in “what’s my IP” or “how can I find my IP” or something along these lines. 

Google will provide you with your IP. As your IP is public, you can find it using many tools. This is because anyone can trace it pretty easily. An ISP or ISP or service provider can legally track all the online activity of its users and maintain a record of that. 

If any law enforcement agency needs to check what a user has been doing online, they will get all user data from the internet service provider. 

Therefore, using a quality VPN service is highly recommendable here. It will enable you to hide the IP and prevent mishandling your info. With a VPN service, you don’t have to connect to the internet directly. 

First, you will connect with your VPN service provider. All your personal and financial info remains safe if you use a quality VPN service. 

Understanding IP Address & Network Interface

The question here is can Linux have more than one network interface? And the answer to this question is yes. It can have more than one network interface. It is common with web servers and other portable devices connecting with different networks. 

But can more than one IP address be associated with a network interface? Well, if a system utilizes different network interfaces and IP protocols, each interface will have its IP address. 

Several IP addresses can be assigned on a single network interface. There will be a primary address, the first address, while all others are secondary addresses, called aliases. These aliases are pretty common with web servers. 

Difference between IP Address & MAC Address

The primary difference between these two addresses within Linux OS is that IP addresses are the address of networks. Whereas MAC addresses are the address of system hardware. 

With the help of an IP, you can identify any computer connected to a network. On the other hand, with a MAC, you can place the specific network interface of a specific computer. Moreover, IP addresses can be altered, but MAC addresses can’t. 

Changing IP in Linux OS

You can change the IP address in the Linux environment. And to do that, you will need to open the terminal. Type in sudo ifconfig eth0 in the command prompt. 

It will alter the IP address of your interface on eth0 to the IP address you have just typed in the command. You can assign a speech to a network interface within Linux OS. 

When you alter your IP address in the Linux environment, your system will have a new IP address. This is associated with the network interface specified in the command. 

Troubleshooting Any Issues with Your IP on Linux OS

Facing some IP address related issues while on Linux? Well, there are some ways to troubleshoot these issues. 

First, you will have to check the current status of network interfaces using the “ip” or “ifconfig” commands. If some of your interfaces are inactive, you can restart your interface using the “ifdown” or “ifup” commands. 

If issues remain even after you have used these commands, you can use the “ping” or “netstat” commands to troubleshoot your specific network problem. 

With the help of “netstat”, you will get all the info about your network connections. While “ping” helps test the connectivity flow between two systems. 


There are multiple ways to check your IP address on Linux. You can use a few commands, and Google can help you find your IP address. 

You can alter your IP address in Linux using a specific command. These commands will help you get additional information about your network interfaces and IP address.

Si Yan contributed to PC Guide in 2022 and supported with content creation. Previously working at a major electronics company, she brought her knowledge of consumer tech to the site.