How the ip Command Replaces ifconfig in Linux
For decades, ifconfig was the standard tool for network
interface management in Linux, but it has now been deprecated in favor
of the modern ip command from the iproute2
suite. This article explains why modern distributions phased out
ifconfig, the architectural advantages of the
ip command, and how to translate legacy network tasks—such
as viewing interfaces, managing IP addresses, controlling links, and
handling routing tables—into the modern ip syntax.
Why ifconfig Was
Deprecated
The ifconfig utility belongs to the legacy
net-tools package, which has not seen active development
for many years. It relies on the older ioctl system call
interface to communicate with the Linux kernel network stack. This
legacy approach has distinct limitations:
- Limited Feature Support:
ifconfigcannot handle modern Linux networking capabilities, such as network namespaces, policy-based routing, Virtual Extensible LAN (VXLAN), and advanced traffic control. - Secondary IP Aliasing: When assigning multiple IP
addresses to a single interface,
ifconfigrequires artificial alias names (likeeth0:1). The modern kernel allows multiple addresses natively on a single interface without aliasing, a conceptifconfigcannot properly represent. - Inefficient Kernel Communication: The
ioctlinterface is less efficient and flexible than Netlink, the socket-based interface used by modern networking tools.
The Architecture of the
ip Command
The ip command interacts with the Linux kernel using
Netlink sockets, allowing for bidirectional, asynchronous, and
event-driven communication. This architecture allows administrators to
query and modify almost any aspect of the networking subsystem through a
unified, object-oriented syntax:
ip [OPTIONS] OBJECT COMMAND
Common objects include:
link: Physical or virtual network devices.addr(oraddress): Protocol (IPv4/IPv6) addresses on devices.route: Routing table entries.neigh(orneighbor): ARP and Neighbor Discovery cache entries.
Key Command Comparisons
1. Displaying Network Interfaces and Addresses
- Legacy:
ifconfigorifconfig -a - Modern:
ip address show(abbreviated asip a)
To inspect layer 2 (link state, MAC addresses) without layer 3 IP details:
- Modern:
ip link show(abbreviated asip l)
2. Bringing Interfaces Up or Down
- Legacy:
ifconfig eth0 up
ifconfig eth0 down - Modern:
ip link set eth0 up
ip link set eth0 down
3. Assigning and Removing IP Addresses
Under ifconfig, adding a second IP address required
creating an alias. The ip tool assigns addresses directly
to the device:
- Legacy (Single IP):
ifconfig eth0 192.168.1.50 netmask 255.255.255.0 - Modern (Add IP):
ip addr add 192.168.1.50/24 dev eth0 - Modern (Delete IP):
ip addr del 192.168.1.50/24 dev eth0
4. Managing Routes
Previously, routing required a separate command (route).
The iproute2 package consolidates routing directly into the
ip utility:
- Legacy (View Routes):
route -nornetstat -rn - Modern (View Routes):
ip route show(abbreviated asip r) - Legacy (Add Default Gateway):
route add default gw 192.168.1.1 eth0 - Modern (Add Default Gateway):
ip route add default via 192.168.1.1 dev eth0
5. Managing the ARP / Neighbor Table
Handling address resolution mappings also previously required a
standalone tool (arp):
- Legacy:
arp -n - Modern:
ip neigh show(abbreviated asip n)
Conclusion
The transition from ifconfig to ip replaces
fragmented, outdated utilities with a single, high-performance tool
designed for modern networking stacks. While legacy scripts may still
rely on ifconfig, mastering the ip command is
essential for working with current Linux environments, containerization,
and advanced routing topologies.