ifconfig vs ip: Difference and Comparing Network Configuration

Linux is a buffet for different tools and utilities, some last longer, and others are deprecated with better alternatives.

Debian/Ubuntu: Configure knockd on Server for Port Knocking

ifconfig

ifconfig is one of them, introduced in UNIX-based operating system as administration utility for the networking in 1983, then inherited by Linux in 1991.

It is part of the net-tools package, which bundles essential tools for the network subsystem of the Linux kernel. This includes tools like ifconfig, arp, route, netstat, rarp, nameif.

It is a traditional command used to display information about network interfaces. Still, due to frequent updates in the Linux kernel, it cannot sustain and deprecate with another advanced tool like IP.

Drawbacks

  • tun and tap devices can’t be created.
  • Do not display peer binding address.
  • Do not support nor use CIDR notation.
  • Do not display disabled devices on the network.
  • Do not support non-labeled secondary addresses.
  • ipipsitgrel2tp, etc. Can’t be configured in-kernel static tunnels.
  • Misunderstood some devices due to the advancement in Hardware and Kernel.

Besides patch mass updates provided manually by some distributions, there have been no significant updates in net-tools since 2001 after net-tools v1.60.

Personal thoughts for ifconfig

To be honest, sometimes I still use ifconfig; you heard it right. The reason is the output is pretty easy to digest and feels like a pretty handy tool for just taking a sneak peek of the network interfaces.

It does not mean that I am totally into it, but a little old habit. Now let’s see what IP has to offer us, which ifconfig cannot fulfill.

IP – Alternative for ifconfig

IP is a powerful networking configuration tool that every Linux administrator should know. It is a successor of ifconfig from the iproute2 package with features like up or down, assigning and removing addresses and routes, managing ARP cache, configuring and modifying static routing, etc.

It provides all the functionality to manage Layer 2 (Link Layer) and Layer 3 (IP layer) from the OSI model. Easily can handle all the tasks, where ifconfig lacks, and provide more and more functionality for Linux administrator.

Key Features

  • Setup tunnel over the IP.
  • Easily manupulate default and static routing.
  • Display IP address and modify its properties.
  • Assigning, modifying, and deleting the IP address and routes.
  • Modify ARP caches along with creating new static ARP entry for a host.

The key difference between ifconfig and IP is that ifconfig still utilizes the old method known as ioctl (Input/Output control), which the people criticize. At the same time, the successor uses the Netlink socket mechanism.

The NetLink socket mechanism is a more convenient and flexible way to communicate between processes and kernel using rtnetlink (Which allows the kernel’s routing tables to be read and altered) than the predecessor ioctl.

ip vs ifconfig Commands

Below is the table of the commands. You can take a sneak peek differences between ip and ifconfig commands.

ifconfig (net-tools)ip (iproute2)
ifconfigip a, ip link
routeip route
arpip neigh
netstatss
netstat -Mconntrack -L
netstat -gip maddr
netstat -iip -s link
netstat -rip route
iptunnelip tunnel
tunctlip tuntap
brctlbridge
ifconfig and IP commands differences

Let put major commands into action and see how they work.

1. Output all Network Interfaces

Proxychains – Run Commands and Applications using Proxy Tunnels

ifconfig command

$ ifconfig
ifconfig
ifconfig

ip command

$ ip a #Brief overview of network interfaces
$ ip link #Summary of network interfaces
ip addr/link
ip addr/link

2. Adding/Removing an IP address

ifconfig

$ ifconfig eth0 add 192.168.50.156 #Add 192.168.50.156 to the network
$ ifconfig eth0 del 192.168.50.156 #Remove 192.168.50.156 from the network

IP

$ ip a add 192.168.50.156 dev eth0 #Add 192.168.50.156 to the network
$ ip a del 192.168.50.156 dev eth0 #Remove 192.168.50.156 from the network

3. Enable or Disable Network Interface

ifconfig command

To monitor the changes, use ifconfig.

$ ifconfig eth0 down #Disable eth0
$ ifconfig eth0 up #Re-enable eth0 

ip command

To monitor the changes, use ip a/link.

$ ip link set eth0 down #Disable eth0
$ ip link set eth0 ip #Re-enable eth0

4. Eable or Disable the use of ARP protocol

ifconfig command

$ ifconfig eth0 arp #Enable arp for eth0
$ ifconfig eth0 -arp #Disable arp for eth0

ip command

$ ip link set dev eth0 arp on #Enable arp for eth0
$ ip link set dev eth0 arp off #Disable arp for eth0

5. Attach MAC Address to Network Interface

The current mac address will be replaced with the mentioned address from the below command. You can spot the differences using the ifconfig and ip commands.

How to Change MAC Address in Linux

ifconfig command

$ ifconfig eth0 hw ether C3-F8-66-D7-6B-31

ip command

$ ip link set dev eth0 address C3-F8-66-D7-6B-31

To revert, reboot your system, and all the changes will be restored.

Final Thought

IP command is way better to use, and many distributions like openSUSE are known to exclusively use iproute2 for setting up networking during system boot and installation.

Many distributions removed the support for the net-tools package, which one time came preinstalled. Besides, this ip command is more convenient while networking instead of ifconfig.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments