🌐 Command: ip addr (Network Interface Addresses)
The ip addr command (short for ip address) is the modern standard for managing and viewing the network interfaces on your Linux system. It has replaced the older ifconfig command.
1. The "Why"
when you are configuring your Linux installation, troubleshooting a, or setting up a static IP for your pc or server, you need to know exactly how your machine is identified on the network.
- Find Your Local IP: Determine your computer's internal address (e.g.,
192.168.1.15) so other devices can connect to it. - Verify Interface Status: Check if your Ethernet (
enp...) or Wi-Fi (wlan...) is actually "UP" and active. - Check MAC Addresses: Get the physical hardware address of your network card for router filtering.
2. Basic Syntax
ip addr
You can also use the shorthand:
ip a
3. Understanding the Output
When you run ip a, you will see several numbered entries. Each represents a network interface.
Key Components:
lo(Loopback): This is the internal "virtual" interface used by the computer to talk to itself (usually127.0.0.1).enp...oreth0: Your physical Ethernet connection.wlan0: Your Wi-Fi connection.state UP/DOWN: Tells you if the hardware is currently active.inet: This is your IPv4 address. (The number after the/is the subnet mask).inet6: This is your IPv6 address.link/ether: This is your MAC Address (the hardware's unique physical ID).
4. Practical Examples
A. Show Only One Interface
If you have a lot of interfaces (like Docker or virtual bridges) and only want to see your Wi-Fi:
ip addr show wlan0
B. Brief/Clean Output
If the default output is too messy, you can show just the basic details:
ip -brief addr
C. Checking Only IPv4
To hide the long IPv6 strings and just see your standard IP addresses:
ip -4 addr
5. Pro-Tips
- Public vs. Local IP:
ip addronly shows your Local IP (inside your house). To find your Public IP (the one the rest of the world sees, which is important for your Algeria-based banking/e-commerce work), use:curl ifconfig.me - Up and Down: You can use the
ipcommand to turn an interface off or on:sudo ip link set wlan0 down/sudo ip link set wlan0 up - Arch Linux Context: On Arch, network interfaces often have long names like
enp3s0instead ofeth0. This is because of "Predictable Network Interface Names," which ensures the name doesn't change if you add a new network card.
6. Summary Reference
| Goal | Command |
|---|---|
| View all IP info | ip a |
| View IPv4 only | ip -4 a |
| View brief status | ip -br a |
| View specific interface | ip a show [name] |