Net-tools to iproute2: Difference between revisions

From Leo's Notes
This page was last edited on 11 March 2020, at 18:36.
m Text replacement - "Category:Linux{{Navbox Linux}}" to "{{Navbox Linux}}Category:Linux"
No edit summary
Line 1: Line 1:
The following maps the deprecated network tools (ifconfig, route, netstat, etc) to the new ip command.
The deprecated {{code|net-tools}} package contains all legacy network tools such as {{code|ipconfig}}, {{code|route}}, {{code|arp}}, etc.  Since tools from {{code|net-tools}} are now obsolete, it is best practice to move towards using the replacement package {{code|iproute2}}.
 
The following table maps the old {{code|net-tools}} commands to the new {{code|iproute2}} commands.  


{| class="wikitable"
{| class="wikitable"
|-
|-
! Old
! Old {{code|net-tools}}
! New
! New {{code|iproute2}}
|-
| arp
| ip '''n'''eighbour
|-
| netstat -ln
| ss -ln
|-
| netstat -r
| ip '''r'''oute
|-
| netstat -i
| ip -s '''l'''ink
|-
| ip maddr
| netstat -g
|-
| iwconfig
| iw
|-
| iptunnel
| ip '''t'''unnel
|-
| nameif
| ip '''l'''ink
|-
|-
| ifconfig
| ifconfig
| ip addr
| ip '''a'''ddress
|-
|-
| ifconfig $interface <nowiki>[up|down]</nowiki>
| ifconfig $interface <nowiki>[up|down]</nowiki>
| ip link set dev $interface <nowiki>[up|down]</nowiki>
| ip '''l'''ink set dev $interface <nowiki>[up|down]</nowiki>
|-
|-
| ifconfig $interface $ip netmask $netmask
| ifconfig $interface $ip netmask $netmask
| ip addr add $ip/$mask dev $interface
| ip '''a'''ddr add $ip/$mask dev $interface
|-
|-
| route add default gw $gateway
| route add default gw $gateway
| ip route add default via $gateway
| ip '''r'''oute add default via $gateway
|-
|-
| route add -net $net netmask $netmask gw $gateway
| route add -net $net netmask $netmask gw $gateway
| ip route add $net/$mask via $gateway
| ip '''r'''oute add $net/$mask via $gateway
|-
| route del -net $net gw $gateway netmask $netmask dev $device
| ip '''r'''oute del $net/$mask via $gateway
|-
|-
| route -n
| route -n
| ip route
| ip '''r'''oute
|-
|
| ip address add $ip/$mask dev $interface
|-
|
| ip address del $ip/$mask dev $interface
|}
|}


Like networking commands on switches and routers, you do not need to type the full command so long as what's entered can be uniquely identified. For example, {{code|ip address}} can be simplified to {{code|ip a}} and {{code|ip route}} can be simplified to {{code|ip r}}.
The {{code|iproute2}} sub commands can be specified with the shortest unambiguous name (ie. {{code|a}} or {{code|addr}} for {{code|address}}).


The {{code|ip address add $ip/$mask dev $interface}} will add additional IP addresses to the device. If it already has an existing IP address, you will need to use {{code|ip address del $ip/$mask dev $interface}} to remove it.
The {{code|ip address add $ip/$mask dev $interface}} will add additional IP addresses to the device. If it already has an existing IP address, you will need to use {{code|ip address del $ip/$mask dev $interface}} to remove it.

Revision as of 18:36, 11 March 2020

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 package iproute2.

The following table maps the old net-tools commands to the new iproute2 commands.

Old net-tools New iproute2
arp ip neighbour
netstat -ln ss -ln
netstat -r ip route
netstat -i ip -s link
ip maddr netstat -g
iwconfig iw
iptunnel ip tunnel
nameif ip link
ifconfig ip address
ifconfig $interface [up|down] ip link set dev $interface [up|down]
ifconfig $interface $ip netmask $netmask ip addr add $ip/$mask dev $interface
route add default gw $gateway ip route add default via $gateway
route add -net $net netmask $netmask gw $gateway ip route add $net/$mask via $gateway
route del -net $net gw $gateway netmask $netmask dev $device ip route del $net/$mask via $gateway
route -n ip route
ip address add $ip/$mask dev $interface
ip address del $ip/$mask dev $interface

The iproute2 sub commands can be specified with the shortest unambiguous name (ie. a or addr for address).

The ip address add $ip/$mask dev $interface will add additional IP addresses to the device. If it already has an existing IP address, you will need to use ip address del $ip/$mask dev $interface to remove it.

Some other commands: