Net-tools to iproute2

From Leo's Notes
Last edited on 28 October 2022, at 21:40.

The deprecated net-tools package contains all legacy network tools such as ipconfig, route, arp, etc. Since tools from net-tools are now obsolete, it is best practice to move towards using the replacement commands provided by iproute2.

The following table maps common net-tools based commands to the new iproute2 commands. Note that most iproute2 sub commands can be specified with the shortest unambiguous name (ie. a or addr for address). The unambiguous name is marked in bold.

Description Old net-tools New iproute2
Show ARP table arp -n ip neighbour
Show listening ports netstat -ln ss -ln
Shows routing table netstat -r ip route
shows network interface counters netstat -i ip -s link
Show interface group memberships netstat -g ip maddr
Wireless config iwconfig iw
IP Tunnel configuration iptunnel ip tunnel
Shows interfaces based on MAC address nameif ip link
Shows interface addresses ifconfig ip address
Bring an interface up or down ifconfig $interface [up|down] ip link set dev $interface [up|down]
Renames eth0 to eth1, where xx:xx:xx:xx:xx:xx is eth0's MAC address nameif eth1 xx:xx:xx:xx:xx:xx ip link set dev eth0 name eth1
Changes interface MAC address ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx ip link set dev eth0 address xx:xx:xx:xx:xx:xx
Sets the MTU for eth0 to 1500 ifconfig eth0 mtu 1500 ip link set dev eth0 mtu 1500
Change an interface IP address.

Requires remove/add in iproute2.

ifconfig $interface $ip [netmask $netmask] ip addr del $ip/$mask dev $interface
ip addr add $ip/$mask dev $interface
Adds a secondary IP to an interface. Old net-tools uses interface:X to denote secondary addresses (eg. eth0:0). ifconfig $interface:X $ip [netmask $netmask] ip addr add $ip/$mask dev $interface
Removes the IP address on an interface ifconfig $interface 0.0.0.0 ip addr del $ip/$mask dev $interface
Adds a default gateway route add default gw $gateway ip route add default via $gateway
Removes a default gateway route del default gw $gateway ip route del default via $gateway
Adds a static route via a gateway route add -net $net netmask $netmask gw $gateway ip route add $net/$mask via $gateway
Deletes a static route route del -net $net gw $gateway netmask $netmask dev $device ip route del $net/$mask via $gateway
Shows routing table route -n ip route

See also