Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
ifconfig vs ip What\'s Difference and Comparing Network Configuration?
As network administrators or anyone working with network troubleshooting, you will often encounter the commands ifconfig and ip. Both these commands are used in Unix-based operating systems for network interface configuration, but they have significant differences in capabilities, syntax, and maintenance status.
Introduction to Ifconfig
Ifconfig (Interface Configuration) is a system administration utility in Unix and Unix-like operating systems to configure, control, and query TCP/IP network interface parameters. It is part of the net-tools package which has been present since the early days of Linux.
Let's examine a basic ifconfig command:
$ ifconfig
This produces output similar to:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::92e2:baff:fe14:5044 prefixlen 64 scopeid 0x20<link> ether 90:e2:ba:14:50:44 txqueuelen 1000 (Ethernet) RX packets 44675547 bytes 60719045480 (56.5 GiB) RX errors 0 dropped 2473 overruns 0 frame 0 TX packets 32862915 bytes 4461913156 (4.1 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
In this example, eth0 is the first ethernet interface. Details include IP address (IPv4/IPv6), netmask, broadcast address, MAC address, and packet statistics.
Introduction to ip Command
Since around 2009, the ip command started replacing the traditional ifconfig. The ip command is part of the iproute2 package, which is actively maintained, unlike the deprecated net-tools package.
The ip command provides significantly more features than ifconfig, including advanced routing, tunneling, and policy management. It offers more consistent syntax and structured output, making it ideal for scripting.
Here's an example using the ip command:
$ ip addr
This outputs:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 90:e2:ba:14:50:44 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.2/24 brd 192.168.1.255 scope global dynamic eth0
valid_lft 86374sec preferred_lft 75574sec
inet6 fe80::92e2:baff:fe14:5044/64 scope link
valid_lft forever preferred_lft forever
Key Differences
Syntax and Usage
The ip command features a more hierarchical and consistent syntax structure. For example, bringing a network interface up:
# Using ifconfig $ sudo ifconfig eth0 up # Using ip $ sudo ip link set eth0 up
IPv6 Support
The ifconfig command provides limited IPv6 support, making it less suitable for modern networks. The ip command offers complete IPv6 support, which is essential as networks transition to IPv6.
Advanced Features
While ifconfig primarily configures network interfaces, the ip command provides advanced capabilities like routing table management:
$ ip route show
default via 192.168.1.1 dev eth0 192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.2
Comparison Table
| Feature | ifconfig | ip |
|---|---|---|
| Package | net-tools (deprecated) | iproute2 (actively maintained) |
| IPv6 Support | Limited | Full support |
| Syntax | Simple, flat | Hierarchical, structured |
| Display interfaces | ifconfig |
ip addr |
| Add IP address | ifconfig eth0 192.168.1.2 netmask 255.255.255.0 |
ip addr add 192.168.1.2/24 dev eth0 |
| Remove IP address | Not straightforward | ip addr del 192.168.1.2/24 dev eth0 |
| Show routing table | route -n |
ip route show |
Conclusion
While ifconfig has historical significance and familiarity, the ip command is the modern, powerful successor for network configuration. The ip command offers comprehensive IPv6 support, advanced features, and active maintenance, making it the recommended choice for contemporary Linux systems.
