LLI Wiki — My Digital Knowledge Base

Linux: replacing net-tools with iproute2

Mapping from the deprecated net-tools commands (ifconfig, route, arp, netstat) to their iproute2 equivalents (ip, ss) on Linux.

The iproute2 package replaces the deprecated net-tools package (ifconfig, route, arp, netstat). The tables below map the common commands. Changes made with ip are runtime only and are lost at reboot; make them persistent with NetworkManager or the distribution's network configuration.

Command mapping

Task net-tools (deprecated) iproute2
List all interfaces ifconfig -a ip link show
Enable an interface ifconfig eth1 up ip link set dev eth1 up
Disable an interface ifconfig eth1 down ip link set dev eth1 down
Add an IP address ifconfig eth1 192.0.2.10 netmask 255.255.255.0 ip addr add 192.0.2.10/24 dev eth1
Remove an IP address (no direct equivalent) ip addr del 192.0.2.10/24 dev eth1
Show one interface ifconfig eth1 ip addr show dev eth1
Change the MAC address ifconfig eth1 hw ether 00:11:22:33:44:55 ip link set dev eth1 address 00:11:22:33:44:55
Show the routing table route -n or netstat -rn ip route show
Add a default route route add default gw 192.0.2.10 ip route add default via 192.0.2.10
Add a static route route add -net 192.0.2.0/24 dev eth1 ip route add 192.0.2.0/24 dev eth1
Link state and speed mii-tool ethtool
Wireless information iwconfig iw

Legacy tools and their replacements

Legacy command Replacement Purpose
arp ip neigh Neighbour (ARP) table
iptunnel ip tunnel Tunnels
nameif ip link set dev OLD name NEW Rename interfaces
ipmaddr ip maddr Multicast addresses
netstat ss, ip -s link, ip route Sockets, statistics and routes

Enable and disable an interface

ip link show
sudo ip link set dev ens192 down
sudo ip link set dev ens192 up

Manage an interface with NetworkManager

nmcli device
sudo nmcli device disconnect ens192
sudo nmcli device connect ens192
sudo nmcli device set ens192 managed no
sudo nmcli device set ens192 managed yes

Statistics and sockets

ip -s link
ss -s
netstat -s | head -11
cat /sys/class/net/eth0/speed

The last command prints the link speed in Mb/s; it only works while the link is up.

Wi-Fi with nmcli

nmcli device wifi list
nmcli device wifi connect "SSID" password "PASSWORD"
nmcli device wifi connect "SSID" password "PASSWORD" hidden yes
nmcli radio wifi off

Restart the networking service

Distribution family Command
RHEL / CentOS (legacy network service) sudo service network restart
Debian / Ubuntu (legacy networking service) sudo service networking restart
NetworkManager based systems sudo systemctl restart NetworkManager
Mastodon LLIMastodon SocialFosstodon