3 Easy Ways to Find IP Addresses in Linux - howtouselinux (2023)

An IP address is a unique identifier assigned to a computer or device connected to the internet.

In this blog post, we will discuss three methods to find the IP address of a Linux system: using theifconfigcommand with theIPcommand and with theIP-RouteCommand.

Let's begin!

Procedure to find IP address in Linux

  • Open the terminal application.
  • Enter the command ifconfig -a or ip addr or ip route
  • Press Enter to run the command.
  • The output shows the IP address for all network interfaces.

3 Easy Ways to Find IP Addresses in Linux - howtouselinux (1)

Related:Step-by-step guide on how to fix a network problem on Linux

Find the IP address using the ip addr command in Linux

The most convenient way to find IP addresses in Linux is to useIP-AdrCommand. All we need is to open the terminal, then type ip addr in the command prompt and hit enter.

The number next to inet is the IP address. This command lists the IP addressMAC-Address,person sizeand other information about a network interface.

I find this command very useful as it gives me more detailed information about my system's IP address and network interface status.

We can also enter ip address or ip a for short.

  • ip addr - Display IP address for all interfaces
  • ip addr show dev em1 - Display information for device em1 only
  • ip addr show up - Show IP address for the running interfaces

By default,Dieip addr befehldisplays IP information of all network interfaces on the Linux system.

This is the command output on my system.

# IP-Adr
1:please refer: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
Link/Loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet127.0.0.1/8 range host lo
valid_lft forever preferred_lft forever

2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP Gruppenvorgabe qlen 1000
link/ether 02:3f:4d:eb:52:e7 brd ff:ff:ff:ff:ff:ff
inet10.1.0.143/24 brd scope global dynamic noprefixroute eth0
valid_lft 3198 sec. Preferred_lft 3198 sec

(Video) How to Find Your IP Address in Linux Terminal

3:eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP-Gruppenstandardwert qlen 1000
link/ether fa:16:3e:18:3a:76 brd ff:ff:ff:ff:ff:ff
inet10.254.222.37/23 brd scope global dynamic eth0
valid_lft 70000 sec preferred_lft 70000 sec

From the example above we can see that there are three network interfaces l0, eth0 and eth1.

The IP address for eth0 is and the IP address for eth1 is

3 Easy Ways to Find IP Addresses in Linux - howtouselinux (2)

This output is easy to understand.

  • The internet entry shows the IP address for the interface.
  • UP means the interface is operational;
  • Brd indicates that the interface is connected to a network that supports broadcast messaging (Ethernet).
  • LOOPBACK indicates which device (lo) is the loopback address.
  • Themaximum transmission unit(PERSON) oneth0 is 1500 bytes. This determines the size of the largest packet that can be transmitted over that interface (and is sometimes "tuned" to other values ​​to improve performance).

If you have more than one network interface on your system, you can useShow IP address devcommand toView the IP address of the specific interface.

The syntax for this command is:

ip addr show dev Schnittstellenname

Let's say if I want to find the IP address of interface eth1 I use the following command:

$ ip addr show dev eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP-Gruppenstandardwert qlen 1000
link/ether fa:16:3e:18:3a:76 brd ff:ff:ff:ff:ff:ff
inet10.254.222.37/23 brd scope global dynamic eth0
valid_lft 69786 sec. Preferred_lft 69786 sec

In addition, I would like to share another commandIP address is displayed.

The "ip addr show up" command is used to display the network interfaces that are currently in an "up" state, meaning they are enabled and active.

There are a number of other options you can use with the ip addr command. You can type command for more informationIP addr help.

To learn more about ip command I would recommend the following article.

3 Useful Linux Commands You Must Know About Networking

(Video) Kali Linux - How to discover the IP & MAC addresses of all devices on a network

Get the IP address using the ifconfig command in Linux

TheifconfigThe command is a general command used to display IP related information in Linux. The command output includes the interface name, assigned IP address, netmask, broadcast address, and other network-related information.

If no argument is given, this command displays the configuration details of all active network interfaces on the system.

Also, if you are only interested in a specific interface eth0, use: ifconfig eth0

To use this command, simply type ifconfig in the shell prompt and press Enter.

# ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9001
inet10.1.0.143Netmask Broadcast
ether 02:3f:4d:eb:52:e7 txqueuelen 1000 (Ethernet)
RX-Pakete 1142453 Bytes 77488923 (73,8 MiB)
RX-Fehler 0 Dropped 0 Overruns 0 Frame 0
TX-Pakete 5835535 Byte 8505814381 (7,9 GiB)
TX errors 0 dropped 0 overruns 0 carriers 0 collisions 0

The ifconfig command is a powerful network configuration utility that can be used to view or configure a network interface.

In addition, it should be noted that the ifconfig command is considered a deprecated command and is replaced by the iproute2 package in many distributions.

This means that it may not be supported in newer versions of the operating system and may not be compatible with some distributions.

If you need to install it, you can follow this guide.

3 ways to fix ifconfig command not found in Linux

Related:10 Linux Networking Interview Questions You Must Know

Get the IP address using the ip route command in Linux

TheIP-RouteThe command can be used to find the IP address of a Linux system.

This command will print our system's IP address along with other network details. Once we run the command we will see an output similar to the following text.

$ ip-Route
Default above dev eth0 proto dhcp metric 100 dev eth0 proto kernel space link source10.1.0.143metric 100

The information shows us the IP routing table of the server andnetwork gateway.

(Video) chage command in Linux with examples | How to Use Linux Chage Command

In these lines, the IP addresses following "src" are the IP addresses configured on the server.

In the example above, we can see that the server has an IP address of ``.

Check IP address with bash script in Linux

We can get a list of network interfaces and IPv4 addresses on our server by running the following command:

ip -4 -o on | cut -d '' -f 2.7 | cut -d '/' -f 1

The output lists the interface names on the left and the corresponding IP addresses on the right.


Let's break down the command:

ip -4 -o a : print each record on a single line, replacing newlines with the‘\’Character. This is handy when you want to get the IP address in the bash script.

The Cut command is used to extract a subset of rows from a command output or to extract a subset of columns.

The -d parameter specifies the delimiter used to separate the fields.

The -f parameter specifies the field number(s) you want to extract.

Here's an example: cut -d',' -f1,3 filename.txt This command extracts the first and third columns from the lines in the filename.txt file, using commas as separators.

Related:Bash shell script to lookup IP address

Find public IP address in Linux

The way to get your public IP address is Google it. Type in "What is my IP address" or "How do I find my IP address" and Google will tell you.

Your IP address is public on the internet. We can get it from many online tools. It can be easily followed by others.

(Video) How To Use Linux LUKS Full Disk Encryption For Internal / External / Boot Drives

Alternatively, you can try using curl to access an external service that recognizes your public IP address. There are quite a few out there - I just went with the first search result I found:

curl ifconfig.me/all

IP Address:
remote_host: not available
user_agent: curl/7.84.0
Port: 35116
stay alive:
Method: GET
Pantomime: */*
character set:
via: 1.1 google

There is another way to find out your public IP address. Perform a DNS lookup for myip.opendns.com. It's a service provided by OpenDNS, and it's lightning fast!

dig +short myip.opendns.com @resolver1.opendns.com

What is an IP address?

From Wikipedia, the free encyclopediaIP Addressused in a system for communication. It's a numeric designation like An IP address serves two main functions: network interface identification and location addressing.

An IP address is the identifier that allows our device to send or receive packets of data over the internet. It contains information about our location and therefore makes devices availableTwo way communication.

Most internet service providers still use IPv4.It is based on 32 binary bits, consists of four numbers from 0 to 255 and is separated by dots. Example:

A Linux server can have more than one network interfacee. This is often the case with web servers and other devices that need to connect to different networks. For example, a web server may need to be able to connect to both the internet and a local area network.

A network interface can have more than one IP address. The first address is called the primary address while the others are called secondary addresses or aliases. The use of secondary IP addresses is common for web servers.

For example, a web server may have a primary IP address that is used to connect to the internet and a secondary IP address that is used to connect to a local area network. This means that the server can be reached from both networks.

In the example below, there are two IP addresses10.252.10.51 and the physical interface eth0.

eth0 Link encap:Ethernet HWaddr 00:50:56:8F:44:C7
inet address: Mask:
eth0:0 Link encap:Ethernet HWaddr 00:50:56:8F:44:C7
inet address: Mask:

3 ways to find MAC addresses in Linux


1. Create a Linux Mint proxy server using Squid, SquidGuard, and a Blacklist - Part 1
2. hostname command in Linux with examples | How to Use Linux hostname Command
3. Network Namespaces Basics Explained in 15 Minutes
4. Learn How To Use Linux Mint Easily! | Complete Video Tutorial
(Linux TV)
5. TryHackMe Linux Fundamentals 3 Walkthrough
(Mr Ash)
6. Find Information from a Phone Number Using OSINT Tools [Tutorial]
(Null Byte)
Top Articles
Latest Posts
Article information

Author: Maia Crooks Jr

Last Updated: 02/23/2023

Views: 6494

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Maia Crooks Jr

Birthday: 1997-09-21

Address: 93119 Joseph Street, Peggyfurt, NC 11582

Phone: +2983088926881

Job: Principal Design Liaison

Hobby: Web surfing, Skiing, role-playing games, Sketching, Polo, Sewing, Genealogy

Introduction: My name is Maia Crooks Jr, I am a homely, joyous, shiny, successful, hilarious, thoughtful, joyous person who loves writing and wants to share my knowledge and understanding with you.