The ifconfig
and ip
commands in Linux are used for network interface configuration, but they operate differently and serve distinct purposes. The ifconfig
command is part of the net-tools package, which is deprecated in many Linux distributions. It is primarily used for configuring network interfaces, viewing their statuses, and setting IP addresses. On the other hand, the ip
command is part of the iproute2 package and provides a more comprehensive and modern set of tools for networking tasks, including managing routing, devices, policy routing, and tunneling.
Internally, ifconfig
interacts with the kernel through system calls to retrieve and modify network interface configurations. It uses ioctl (input/output control) system calls, which directly interface with the kernel's networking subsystem. The ip
command communicates with the kernel using the netlink socket interface, which is more efficient and versatile, allowing for better handling of advanced networking features.
As a result, while both commands can be used to display and configure network interfaces, the ip
command is recommended for use in modern systems due to its extensibility and continued updates. Here are some examples of how both commands work:
# Using ifconfig to view network interfaces
ifconfig
# Using ip to view network interfaces
ip addr show
# Using ifconfig to assign an IP address
ifconfig eth0 192.168.1.10
# Using ip to assign an IP address
ip addr add 192.168.1.10/24 dev eth0
How do I avoid rehashing overhead with std::set in multithreaded code?
How do I find elements with custom comparators with std::set for embedded targets?
How do I erase elements while iterating with std::set for embedded targets?
How do I provide stable iteration order with std::unordered_map for large datasets?
How do I reserve capacity ahead of time with std::unordered_map for large datasets?
How do I erase elements while iterating with std::unordered_map in multithreaded code?
How do I provide stable iteration order with std::map for embedded targets?
How do I provide stable iteration order with std::map in multithreaded code?
How do I avoid rehashing overhead with std::map in performance-sensitive code?
How do I merge two containers efficiently with std::map for embedded targets?