Open In App

addresses Command in Linux with Examples

Last Updated : 28 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Finding a way of finding IP addresses is very important in the Linux system administration and the management of networks. Certainly, you will find a need for using it when troubleshooting problems you have with your network connectivity, or if you're configuring services on a network. The chapter goes over various ways by which an IP address could be found within Linux for you to have a broad toolkit of network management.

Some Common Methods to Find IP Address in Linux

An IP (Internet Protocol) address is a unique number assigned to your device on a network. It’s like a phone number for your computer, router, or phone.

1. Using the `ifconfig` command

It shows the network interfaces (like Wi-Fi or Ethernet) and their details.

Syntax

ifconfig [interface]

Simple Example

ifconfig
  • It look for inet under your active interface (e.g., eth0 for Ethernet, wlan0 for Wi-Fi).
2024-10-27_15-09
ifconfig command listing network interfaces and their IP addresses

Key Options for ifconfig Command

Option

Explanation

-a

Show all interfaces even if they are down

-s

Short list, like netstat -i

[interface]

Information for specified interface

2. Using the `ip` command

It scroll to your active interface. IPv4 addresses start with inet, IPv6 with inet6.

Syntax

ip [options] [object] [command]

Simple Example

ip addr
2024-10-27_15-13
Output of ip addr command with detailed network interface information

Key Options for the ip Command

Option

Description

Example

-4

Show only IPv4 addresses

ip -4 addr

-6

Show only IPv6 addresses

ip -6 addr

show dev [interface]

Show information of a specific interface

ip addr show dev eth0

Other Commands

1. hostname Command

It instantly shows your private IP address.

hostname -I
2024-10-27_15-32
Output of hostname -I command showing the IP addresses of the system

2. nmcli Command

It shows detailed network info, great for Wi-Fi/Ethernet management.

nmcli device show
2024-10-27_15-25
Output of the nmcli device show command showing network device information

3. Public IP Address

It reveals your network’s public IP address.

curl ifconfig.me
2024-10-27_15-27
Output of curl ifconfig.me command which is showing the public IP address

Case Study: Network Troubleshooting

Assume you need to troubleshoot network connection. It is the script that depends on quite a number of methods for gathering total network summary:

#!/bin/bash

echo "Network Troubleshooting Report"
echo "==============================="

echo "1. IP Addresses (ip command):"
ip -4 addr | grep inet

echo "\n2. Default Gateway:"
ip route | grep default

echo "\n3. DNS Servers:"
cat /etc/resolv.conf | grep nameserver

echo "\n4. Public IP Address:"
curl -s ifconfig.me

echo "\n5. Ping Test to Google DNS:"
ping -c 4 8.8.8.8

This script gives an excellent view of the network setup of the system, which can be very helpful in trying to troubleshoot connectivity problems.

Conclusion

Knowing how to find the IP addresses in Linux is a very basic, elementary skill for system administrators and network professionals. We have discussed different methods-from the old ifconfig command to the new ones like ip and nmcli. Each of these methods has its strength, and knowing when to use it will make you just that little bit more efficient in managing your Linux systems and troubleshooting problems about networks.


Next Article

Similar Reads