ipconfig vs. ifconfig

One of the most popular networking command in Linux is the ifconfig command. It lets you see (and configure) IP address for network interface. It also shows the MAC address for each interface. The MAC address and the IP address viewing is probably the most common reason for using the ifconfig command. In addition the ifconfig command works with physical network interface (like eth0..) and virtual network interface (like Tap interface etc).

The ip Command – replacement for ifconfig

The ifconfig command is now being deprecated and the new kid on the block is the ip command.The ip command is part of the iproute2util package. The ip command consolidates many different networking commands into one. It is organized based on the networking stack – ip link (Layer 2), ip addr (Layer 3). The most promising capability of the ip command is the support for Namespace. The ip netns command let us run commands inside the Network Namespace (netns).

Here is a quick comparison of commonly used ifconfig commands and how you can achieve the same with ip command.

Viewing details of all network interfaces

To view both MAC address and IP address of all network interfaces use “ip addr” command. The same is achieved using “ifconfig” command also. However there is one key difference, the “ifconfig” command only shows the interfaces that are currently enabled. Note the missing eth2 in the ifconfig output below. The “ip addr” command shows interfaces that are disabled also. To do the same with ifconfig, use the ifconfig with “-a” switch.

Viewing information for a specific network interface

With both “ip addr” and “ifconfig” commands it is possible to view the details of a specific interface as shown below.

Enable or Disable a specific network interface

The “ip link” command can be used to enable or disable a specific network interface. The same can also be accomplished using “ifconfig <interfacename> up” or “ifconfig <interfacename> down” command.

The screenshot below shows an interface whose status is DOWN. Then the interface is enabled using the “ip link” command.

Viewing neighbor interface information

Viewing the information of neighbouring interfaces is possible using the “ip neigh” command. This is not supported by the ifconfig command. Instead users will have to use commands related to ARP or utilities such as ethtool and lldpctl.