Net-tools to iproute2: Difference between revisions

From Leo's Notes
This page was last edited on 11 March 2020, at 18:44.
No edit summary
mNo edit summary
Line 1: Line 1:
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 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 commands provided by {{code|iproute2}}.


The following table maps the old {{code|net-tools}} commands to the new {{code|iproute2}} commands.  
The following table maps the old {{code|net-tools}} commands to the new {{code|iproute2}} commands.  
{| class="wikitable"
{| class="wikitable"
|-
|-
! Old {{code|net-tools}}
! Old {{code|net-tools}}
! New {{code|iproute2}}
! New {{code|iproute2}}
! Description
|-
|-
| arp
| {{code|arp}}
| ip '''n'''eighbour
| {{code|ip '''n'''eighbour}}
| Show ARP table
|
|-
|-
| netstat -ln
| {{code|netstat -ln}}
| ss -ln
| {{code|ss -ln}}
| Show listening ports
|-
|-
| netstat -r  
| {{code|netstat -r}}
| ip '''r'''oute  
| {{code|ip '''r'''oute}}
| Shows routing table
|-
|-
| netstat -i  
| {{code|netstat -i }}
| ip -s '''l'''ink
| {{code|ip -s '''l'''ink}}
| shows network interface counters
|-
|-
| ip maddr
| {{code|netstat -g}}
| netstat -g
| {{code|ip maddr}}
| Show interface group memberships
|-
|-
| iwconfig
| {{code|iwconfig}}
| iw
| {{code|iw}}
| Wireless config
|-
|-
| iptunnel
| {{code|iptunnel}}
| ip '''t'''unnel
| {{code|ip '''t'''unnel}}
| IP Tunnel configuration
|-
|-
| nameif
| {{code|nameif}}
| ip '''l'''ink
| {{code|ip '''l'''ink}}
| Shows interfaces based on MAC address
|-
|-
| ifconfig
| {{code|ifconfig}}
| ip '''a'''ddress
| {{code|ip '''a'''ddress}}
| Shows interface addresses
|-
|-
| ifconfig $interface <nowiki>[up|down]</nowiki>
| {{code|ifconfig $interface <nowiki>[up|down]</nowiki>}}
| ip '''l'''ink set dev $interface <nowiki>[up|down]</nowiki>
| {{code|ip '''l'''ink set dev $interface <nowiki>[up|down]</nowiki>}}
| Bring an interface up or down
|-
|-
| ifconfig $interface $ip netmask $netmask
| {{code|ifconfig $interface $ip netmask $netmask}}
| ip '''a'''ddr add $ip/$mask dev $interface
| {{code|ip '''a'''ddr add $ip/$mask dev $interface}}
| Adds a secondary IP to an interface
|-
|-
| route add default gw $gateway
| {{code|ifconfig $interface del $ip netmask $netmask}}
| ip '''r'''oute add default via $gateway
| {{code|ip '''a'''ddr del $ip/$mask dev $interface}}
| Deletes a secondary IP to an interface
|-
|-
| route add -net $net netmask $netmask gw $gateway
| {{code|route add default gw $gateway}}
| ip '''r'''oute add $net/$mask via $gateway
| {{code|ip '''r'''oute add default via $gateway}}
| Adds a default gateway
|-
|-
| route del -net $net gw $gateway netmask $netmask dev $device
| {{code|route add -net $net netmask $netmask gw $gateway}}
| ip '''r'''oute del $net/$mask via $gateway
| {{code|ip '''r'''oute add $net/$mask via $gateway}}
| Adds a static route via a gateway
|-
|-
| route -n
| {{code|route del -net $net gw $gateway netmask $netmask dev $device}}
| ip '''r'''oute
| {{code|ip '''r'''oute del $net/$mask via $gateway}}
| Deletes a static route
|-
|-
|  
| {{code|route -n}}
| ip address add $ip/$mask dev $interface
| {{code|ip '''r'''oute}}
|-
| Shows routing table
|  
| ip address del $ip/$mask dev $interface
|}
|}


The {{code|iproute2}} sub commands can be specified with the shortest unambiguous name (ie. {{code|a}} or {{code|addr}} for {{code|address}}).
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.


Some other commands:
Some other commands:

Revision as of 18:44, 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 commands provided by iproute2.

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

Old net-tools New iproute2 Description
arp ip neighbour Show ARP table
netstat -ln ss -ln Show listening ports
netstat -r ip route Shows routing table
netstat -i ip -s link shows network interface counters
netstat -g ip maddr Show interface group memberships
iwconfig iw Wireless config
iptunnel ip tunnel IP Tunnel configuration
nameif ip link Shows interfaces based on MAC address
ifconfig ip address Shows interface addresses
ifconfig $interface [up|down] ip link set dev $interface [up|down] Bring an interface up or down
ifconfig $interface $ip netmask $netmask ip addr add $ip/$mask dev $interface Adds a secondary IP to an interface
ifconfig $interface del $ip netmask $netmask ip addr del $ip/$mask dev $interface Deletes a secondary IP to an interface
route add default gw $gateway ip route add default via $gateway Adds a default gateway
route add -net $net netmask $netmask gw $gateway ip route add $net/$mask via $gateway Adds a static route via a gateway
route del -net $net gw $gateway netmask $netmask dev $device ip route del $net/$mask via $gateway Deletes a static route
route -n ip route Shows routing table

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

Some other commands: