Essential Linux Networking Tool Skills

The use of networking configuration tools in Linux systems is a fundamental skill. The main networking configuration tools (commands) are ip, ifconfig, route, and arp. This article mainly shares these tools from the perspectives of historical background, functionality, scenarios, and usage methods.

Introduction to Linux Networking Software Packages

ifconfig and route are traditional tools (originating from the old BSD system, part of the net-tools package), while ip is the modern Linux kernel’s recommended next-generation tool (part of the iproute2 package). Currently, ifconfig/route have gradually been replaced by ip (and do not support IPv6).

net-tools package (ifconfig/route/arp commands): Based on the BSD toolset from the 1980s, it interacts with the kernel through the ioctl system call. net-tools mainly handles the basic aspects of network configuration: IP addresses, routing tables, ARP caches, etc. It does not provide any native traffic control capabilities, only supports IPv4, does not support modern network features (such as network namespaces, VLANs, advanced IPv6 configurations, etc.), and cannot meet the needs of complex network scenarios. Currently, mainstream Linux distributions (such as CentOS 7+, Ubuntu 18.04+) do not come pre-installed with it.

iproute2 package (ip command): iproute2 is a complete, unified software suite developed since the late 1990s, based on the Linux 2.6+ kernel, which interacts with the kernel through a more efficient Netlink interface, aimed at managing and controlling all network functions of the Linux kernel. It not only replaces the basic functions of net-tools (ifconfig, route, arp) but also provides many advanced features, such as tc (Traffic Control, implementing network traffic control, shaping, scheduling, and policies), supports IPv4/IPv6, network namespaces, VLANs, and is the recommended networking tool for modern Linux versions.

Tool

Package

Design Era

Kernel Dependency

Maintenance Status

Functionality

ip

iproute2

Modern (2.6 + kernel)

Depends on new features of the Linux kernel Netlink

Continuously maintained

Full-featured network configuration tool (replacesifconfig/route/arp)

Ifconfig/route/arp

net-tools

Traditional (BSD style)

Depends on outdatedioctl system calls

Stopped maintenance after 2001

Only manages network interfaces (IPMAC、status)

How to Use Linux Networking Tools

The following will introduce the main configuration command usage methods of net-tools and iproute2 Linux networking tool packages from four core scenarios: network interface management, IP configuration, routing management, and ARP management.

1. Network Interface Management (Status Viewing, Renaming, Starting and Stopping)

Function

ip Command

ifconfig Command

Difference

View status of all interfaces

ip link show

ifconfig -a

ip displays more detailed information (such as MTUQdisc)

View details of a single interface

ip link show ens1

ifconfig ens1

ip includes link layer information (MAC、broadcast address)

Start interface

ip link set ens1 up

ifconfig ens1 up

Functionally equivalent

Stop interface

ip link set ens1 down

ifconfig ens1 down

Functionally equivalent

Rename interface

ip link set ens1 name ens33

No direct command (requires modifying configuration files)

ip supports dynamic renaming, whileifconfig does not support

Set interface MTU

ip link set ens1 mtu 1500

ifconfig ens1 mtu 1500

Functionally equivalent, butip supports a larger MTU range

2. IP Address Configuration

Function

ip Command

ifconfig Command

Difference

Configure interface IPv4 (with mask)

ip addr add 1.1.1.1/24 dev ens1

ifconfig ens1 1.1.1.1 netmask 255.255.255.0

ip usesVLSM instead of the mask, which is more concise; ifconfig requires manually specifying the full subnet mask

Configure interface IPv6

ip addr add 2001::1/64 dev ens1

No (does not support IPv6)

ifconfig completely does not support IPv6

Add secondary IP (multiple IP)

ip addr add 2.2.2.2/24 dev ens1 label ens1:1 or no need forlabel, configure directlyip addr add 2.2.2.2/24 dev ens1

ifconfig ens1:1 2.2.2.2 netmask 255.255.255.0 (requires specifying sub-interface)

Functionally equivalent, but ifconfig requires specifying the sub-interface name; ip can be arbitrary, and supports more secondary IP addresses

Delete IP address

ip addr del 1.1.1.1/24 dev ens1

ip addr flush dev ens1 (clear all addresses)

ifconfig ens1 0.0.0.0 (clear all addresses)

ip can precisely delete a single IP; ifconfig can only clear

View interface IP configuration

ip addr show ens1

or view all

ip addr show all

ifconfig ens1 or view all

ifconfig -a

ip displays both IPv4/IPv6;

ifconfig only IPv4

Modify network cardMAC address

ip link set dev ens1

address 00:00:00:11:11:11

ifconfig ens1 hw ether 00:00:00:11:11:11

Functionally equivalent (note that the network card interface needs to be restarted)

3. Routing Configuration (Static Routes, Default Gateway)

Function

ip Command

route Command

Difference

View all routing tables

ip route show (IPv4)

ip -6 route show (IPv6)

route -n (IPv4)

No (does not support IPv6)

ip distinguishes between IPv4/IPv6,route only supports IPv4

Add default gateway

ip route add default via 1.1.1.1 dev ens1

route add

default gw 1.1.1.1 ens1

Functionally equivalent,ip has a more unified syntax

Add static route (target subnet)

ip route add 10.0.0.0/8 via 192.168.1.2 dev ens1

route add -net 10.0.0.0 netmask 255.0.0.0 gw 192.168.1.2 dev ens1

ip simplifies the mask with VLSM, no need for-net parameter

Delete static route

ip route del 10.0.0.0/8

route del -net 10.0.0.0 netmask 255.0.0.0

ip does not require repeating the gateway/interface, which is more concise

Match route by source IP

ip route add 172.18.0.0/16 from 192.168.1.0/24 via 192.168.1.2

No (does not support source IP filtering)

ip supports advanced routing policies,route does not have this feature

4. ARP Management

ifconfig does not directly manage ARP, but thearp command (also part of thenet-tools package) can manage the ARP cache; the ip command achieves all functions ofarp through theip+neigh subcommand and supports more operations.

Function

ip Command

arp Command

Difference

View ARP cache

ip neigh show

arp -a or arp -n

ip outputs a more standardized format (IP+MAC + interface)

Add static ARP entry

ip neigh add 1.1.1.1 lladdr 00:00:00:11:11:11 dev eth0

arp -s 1.1.1.1 00:00:00:11:11:11

Functionally equivalent

Delete ARP entry

ip neigh del 1.1.1.1 dev eth0

arp -d 1.1.1.1

Functionally equivalent

Flush ARP cache

ip neigh flush dev eth0

No direct command (must manually delete all entries)

ip supports batch flushing, whilearp requires deleting one by one

In addition to the above four scenarios illustrating the differences between the net-tools and iproute2 tool packages, there are other differences:

Network Namespaces:ip netns can create/manage namespaces to achieve network isolation (such as Docker container networks),ifconfig/route cannot operate across namespaces.

VLAN and Bridging::ip link add link ens1 name ens1.10 type vlan id 10 can create VLAN sub-interfaces;ip link add name br0 type bridge can create bridging devices. However,ifconfig/route do not have this functionality.

Quality of Service (QoS)::ip can configure bandwidth limits and queue scheduling throughtc subcommands (also part ofiproute2);ifconfig/route do not support.

Advanced IPv6 Configuration::ip supports IPv6 neighbor discovery (ND), stateless address configuration (SLAAC);ifconfig/route do not support IPv6.

Core Points

  • (Key Point) Whether using traditional commands like ifconfig/route/arp or the modern ip command, the configured network parameters are temporary by default and will be lost after restarting the network service or system. To make them permanent, you need to modify the corresponding configuration files based on the Linux distribution (such as Ubuntu’s /etc/netplan/, CentOS’s /etc/sysconfig/network-scripts/) or use startup scripts, systemd services, etc. for persistent configuration.
  • The ip command and its subcommands (link/addr/route/neigh), have a more concise, unified, and extensible syntax, unlike traditional ifconfig, route, arp which require multiple commands to achieve corresponding configuration functions. The ip command is the future trend of Linux network configuration.

  • Modern mainstream Linux distributions (CentOS 7+, Ubuntu 18.04+, Debian 10+) come pre-installed with the iproute2 package (ip command), but do not come pre-installed with net-tools (ifconfig/route), which need to be installed separately. Older versions of systems (CentOS 6, Ubuntu 14.04, etc.) come pre-installed with the net-tools package, but do not come pre-installed with iproute2.

Proficient use of networking configuration tools will help you more efficiently with system deployment, management, troubleshooting, and other tasks.

Leave a Comment