Managing network interfaces efficiently is a core responsibility for system administrators and developers working with Linux environments. The traditional ifconfig utility has been deprecated for years, replaced by the modern iproute2 suite. At the heart of this suite is the ip address command, which allows you to inspect network adapters, assign IP addresses, and control interface states with precision.
When you need to troubleshoot connectivity issues, configure static IP settings, or spin up virtual interfaces, knowing how to wield ip address properly saves time and eliminates guesswork. Unlike older tools that relied on parsing text output, ip address interacts directly with the kernel using netlink sockets, ensuring speed and reliability across different Linux distributions.
Let's dive into the core mechanics, practical operations, and troubleshooting scenarios that make this command indispensable.
Understanding the iproute2 Suite and the ip Command
Before diving into commands, you need to understand the architecture. The old net-tools package, which included ifconfig, route, and arp, was designed for older Linux kernels. Modern kernels handle network routing and addressing through the iproute2 package, where ip is the central Swiss Army knife.
The syntax follows a clear, logical pattern:
ip [OPTIONS] OBJECT COMMAND
The object you will interact with most frequently is address, which can be abbreviated as addr or even a. Understanding shorthand saves keystrokes during critical maintenance windows.
For example, typing ip a is functionally identical to ip address show. The kernel processes these requests instantly, returning the operational state of every network interface on your machine.
Inspecting Network Interfaces
To manage your network, you first need a clear view of your current setup. The ip address show command provides comprehensive details about all active and inactive interfaces.
Running a basic query lists everything:
ip address show
The output contains critical pieces of information for every adapter:
- Interface index and state: Labels like
<BROADCAST,MULTICAST,UP,LOWER_UP>indicate whether the link is active. - MAC address: Listed as the
link/etheraddress. - IP addresses: Both IPv4 (
inet) and IPv6 (inet6) addresses assigned to the interface. - Broadcast domains and scopes: Defining how traffic reaches local hosts.
If you have multiple interfaces, such as eth0, wlan0, or docker0, reading the full output can feel overwhelming. You can target a specific interface to filter the noise:
ip address show dev eth0
You can also check only IPv4 or IPv6 addresses by appending family specifiers:
ip -4 address show
ip -6 address show
Adding and Removing IP Addresses
Assigning a new IP address to an interface is a common task when configuring static networking or setting up virtual aliases. The ip address add command handles this operation dynamically without requiring a service restart.
To assign an IPv4 address with a specific subnet mask, use this syntax:
sudo ip address add 192.168.1.50/24 dev eth0
The /24 notation represents the subnet mask (equivalent to 255.255.255.0). If you miss the subnet specification, the command will fail or default incorrectly, so always include the prefix length.
To remove an IP address that is no longer needed, substitute add with del:
sudo ip address del 192.168.1.50/24 dev eth0
Keep in mind that changes made using the ip command take effect immediately in the running kernel, but they are transient. When you reboot the system, these manual configurations disappear unless you write them into your distribution's permanent network configuration files, such as Netplan on Ubuntu or NetworkManager configurations on RHEL.
Managing Interface States: Up and Down
Sometimes you need to bounce a network interface to reset its connection, clear stuck buffers, or apply low-level hardware changes. Instead of restarting the entire networking stack, you can toggle individual links using the ip link command.
To bring an interface offline:
sudo ip link set dev eth0 down
When an interface is down, it drops all active connections and stops transmitting or receiving packets. To bring it back online:
sudo ip link set dev eth0 up
Combining these commands allows you to cycle a flaky interface cleanly. You can also rename interfaces on the fly if they have predictable names you want to simplify, though the interface must be down first:
sudo ip link set dev enp3s0 name eth0
Working with Secondary IP Addresses and Aliases
Advanced network setups often require multiple IP addresses assigned to a single physical interface. This is common for hosting multiple SSL certificates on unique IPs or running segmented services.
You can add multiple addresses to the same device simply by running the add command again:
sudo ip address add 192.168.1.51/24 dev eth0
sudo ip address add 192.168.1.52/24 dev eth0
When you run ip address show dev eth0, you will see all three addresses listed under the same adapter. To remove a specific secondary address without disturbing the primary one, target it directly with ip address del.
For users transitioning from legacy systems, note that iproute2 eliminates the need for separate virtual interfaces like eth0:1. All addresses live natively on the parent interface as secondary addresses.
Troubleshooting Common Network Issues
When connectivity fails, ip address is your first line of defense. Here is how to diagnose common failure scenarios systematically.
First, check if the interface is actually running. If the output of ip a shows NO-CARRIER or lacks the UP flag, the physical cable might be unplugged, or the driver might be failing.
Second, verify that your IP address and subnet mask match your local network topology. A mismatched subnet mask will isolate your machine from the gateway, preventing local communication even if the physical link is green.
Third, look for flapping interfaces. If an interface repeatedly goes up and down, check system logs using journalctl for driver errors or hardware faults:
journalctl -u networking
For deep dives into official documentation and advanced netlink features, consult the Linux Kernel Documentation or the Netfilter Project for firewall interactions.
Frequently Asked Questions
Are changes made with the ip address command permanent?
No. Changes applied using the ip command modify the running Linux kernel's memory state directly. They vanish when you reboot the system. To make them permanent, configure your changes in your distribution's persistent network manager, such as Netplan, NetworkManager, or /etc/network/interfaces.
How do I check only my IPv4 addresses and hide IPv6?
You can filter the output by passing the family flag -4 before the command. For example, running ip -4 addr show displays only IPv4 interface details, keeping your terminal output clean and easy to read.
Why use ip address instead of ifconfig?
The ifconfig command comes from the deprecated net-tools package and cannot properly display or configure modern networking concepts like IPv6 attributes, multiple routing tables, or advanced traffic control features. The ip command interacts directly with the kernel via netlink sockets, offering superior speed and accuracy.
Can I assign multiple IP addresses to a single network interface?
Yes. You can add as many secondary IP addresses as your network allows to a single physical interface by running the ip address add command multiple times with different addresses. They will all operate concurrently on that single adapter.