addresses Command in Linux with Examples
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).

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

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

2. nmcli Command
It shows detailed network info, great for Wi-Fi/Ethernet management.
nmcli device show

3. Public IP Address
It reveals your network’s public IP address.
curl ifconfig.me

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.