Net-tools to iproute2: Difference between revisions

From Leo's Notes
This page was last edited on 28 October 2022, at 21:40.
mNo edit summary
mNo edit summary
 
(7 intermediate revisions by the same user not shown)
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 commands provided by {{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 common {{code|net-tools}} based commands to the new {{code|iproute2}} commands.  Note that most {{code|iproute2}} sub commands can be specified with the shortest unambiguous name (ie. {{code|a}} or {{code|addr}} for {{code|address}}). The unambiguous name is marked in bold.
{| class="wikitable"
{| class="wikitable"
|-
|-
! Old {{code|net-tools}}
! width="20%" |Description
! New {{code|iproute2}}
!Old {{code|net-tools}}
! Description
!New {{code|iproute2}}
|-
|-
| {{code|arp}}
|Show ARP table
| {{code|ip '''n'''eighbour}}
|{{code|arp -n}}
| Show ARP table
|{{code|ip '''n'''eighbour}}
|
|-
|-
| {{code|netstat -ln}}
|Show listening ports
| {{code|ss -ln}}
|{{code|netstat -ln}}
| Show listening ports
|{{code|ss -ln}}
|-
|-
| {{code|netstat -r}}
|Shows routing table
| {{code|ip '''r'''oute}}
|{{code|netstat -r}}
| Shows routing table
|{{code|ip '''r'''oute}}
|-
|-
| {{code|netstat -i }}
|shows network interface counters
| {{code|ip -s '''l'''ink}}
|{{code|netstat -i }}
| shows network interface counters
|{{code|ip -s '''l'''ink}}
|-
|-
| {{code|netstat -g}}
|Show interface group memberships
| {{code|ip maddr}}
|{{code|netstat -g}}
| Show interface group memberships
|{{code|ip maddr}}
|-
|-
| {{code|iwconfig}}
|Wireless config
| {{code|iw}}
|{{code|iwconfig}}
| Wireless config
|{{code|iw}}
|-
|-
| {{code|iptunnel}}
|IP Tunnel configuration
| {{code|ip '''t'''unnel}}
|{{code|iptunnel}}
| IP Tunnel configuration
|{{code|ip '''t'''unnel}}
|-
|-
| {{code|nameif}}
|Shows interfaces based on MAC address
| {{code|ip '''l'''ink}}
|{{code|nameif}}
| Shows interfaces based on MAC address
|{{code|ip '''l'''ink}}
|-
|-
| {{code|ifconfig}}
|Shows interface addresses
| {{code|ip '''a'''ddress}}
|{{code|ifconfig}}
| Shows interface addresses
|{{code|ip '''a'''ddress}}
|-
|-
| {{code|ifconfig $interface <nowiki>[up|down]</nowiki>}}
|Bring an interface up or down
| {{code|ip '''l'''ink set dev $interface <nowiki>[up|down]</nowiki>}}
|{{code|ifconfig $interface <nowiki>[up|down]</nowiki>}}
| Bring an interface up or down
|{{code|ip '''l'''ink set dev $interface <nowiki>[up|down]</nowiki>}}
|-
|-
| {{code|ifconfig $interface $ip netmask $netmask}}
|Renames eth0 to eth1, where {{code|xx:xx:xx:xx:xx:xx}} is eth0's MAC address
| {{code|ip '''a'''ddr add $ip/$mask dev $interface}}
|{{code|nameif eth1 xx:xx:xx:xx:xx:xx}}
| Adds a secondary IP to an interface
|{{code|ip link set dev eth0 name eth1}}
|-
|-
| {{code|ifconfig $interface del $ip netmask $netmask}}
|Changes interface MAC address
| {{code|ip '''a'''ddr del $ip/$mask dev $interface}}
|<code>ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx</code>
| Deletes a secondary IP to an interface
|<code>ip link set dev eth0 address xx:xx:xx:xx:xx:xx</code>
|-
|-
| {{code|route add default gw $gateway}}
|Sets the MTU for eth0 to 1500
| {{code|ip '''r'''oute add default via $gateway}}
|{{code|ifconfig eth0 mtu 1500}}
| Adds a default gateway
|{{code|ip link set dev eth0 mtu 1500}}
|-
|-
| {{code|route add -net $net netmask $netmask gw $gateway}}
|Change an interface IP address.
| {{code|ip '''r'''oute add $net/$mask via $gateway}}
Requires remove/add in {{code|iproute2}}.
| Adds a static route via a gateway
|{{code|ifconfig $interface $ip [netmask $netmask]}}
|{{code|ip '''a'''ddr del $ip/$mask dev $interface <br /> ip '''a'''ddr add $ip/$mask dev $interface}}
|-
|-
| {{code|route del -net $net gw $gateway netmask $netmask dev $device}}
|Adds a secondary IP to an interface. Old net-tools uses interface:X to denote secondary addresses (eg. {{code|eth0:0}}).
| {{code|ip '''r'''oute del $net/$mask via $gateway}}
|{{code|ifconfig $interface:X $ip [netmask $netmask]}}
| Deletes a static route
|{{code|ip '''a'''ddr add $ip/$mask dev $interface}}
|-
|-
| {{code|route -n}}
|Removes the IP address on an interface
| {{code|ip '''r'''oute}}
|{{code|ifconfig $interface 0.0.0.0}}
| Shows routing table
|{{code|ip '''a'''ddr del $ip/$mask dev $interface}}
|-
|Adds a default gateway
|{{code|route add default gw $gateway}}
|{{code|ip '''r'''oute add default via $gateway}}
|-
|Removes a default gateway
|{{code|route del default gw $gateway}}
|{{code|ip '''r'''oute del default via $gateway}}
|-
|Adds a static route via a gateway
|{{code|route add -net $net netmask $netmask gw $gateway}}
|{{code|ip '''r'''oute add $net/$mask via $gateway}}
|-
|Deletes a static route
|{{code|route del -net $net gw $gateway netmask $netmask dev $device}}
|{{code|ip '''r'''oute del $net/$mask via $gateway}}
|-
|Shows routing table
|{{code|route -n}}
|{{code|ip '''r'''oute}}
|}
|}


The {{code|iproute2}} sub commands can be specified with the shortest unambiguous name (ie. {{code|a}} or {{code|addr}} for {{code|address}}).
== See also ==
 
Some other commands:
* http://unix.stackexchange.com/questions/152331/how-can-i-create-a-virtual-ethernet-interface-on-a-machine-without-a-physical-ad


{{Navbox Linux}}[[Category:Linux]]
* Some other commands: http://unix.stackexchange.com/questions/152331/how-can-i-create-a-virtual-ethernet-interface-on-a-machine-without-a-physical-ad
{{Navbox Linux}}
[[Category:Linux]]
[[Category:Networking]]
[[Category:Networking]]

Latest revision as of 21:40, 28 October 2022

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