Net-tools to iproute2: Difference between revisions

From Leo's Notes
This page was last edited on 29 December 2021, at 21:16.
mNo edit summary
mNo edit summary
Line 4: Line 4:
{| class="wikitable"
{| class="wikitable"
|-
|-
! Old {{code|net-tools}}
! width="20%" |Description
! New {{code|iproute2}}
!Old {{code|net-tools}}
! width=20% | Description
!New {{code|iproute2}}
|-
|-
| {{code|arp -n}}
|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|nameif eth1 xx:xx:xx:xx:xx:xx}}
|Renames eth0 to eth1, where {{code|xx:xx:xx:xx:xx:xx}} is eth0's MAC address
| {{code|ip link set dev eth0 name eth1}}
|{{code|nameif eth1 xx:xx:xx:xx:xx:xx}}
| Renames eth0 to eth1, where {{code|xx:xx:xx:xx:xx:xx}} is eth0's MAC address
|{{code|ip link set dev eth0 name eth1}}
|-
|-
| {{code|ifconfig eth0 mtu 1500}}
|Sets the MTU for eth0 to 1500
| {{code|ip link set dev eth0 mtu 1500}}
|{{code|ifconfig eth0 mtu 1500}}
| Sets the MTU for eth0 to 1500
|{{code|ip link set dev eth0 mtu 1500}}
|-
|-
| {{code|ifconfig $interface $ip [netmask $netmask]}}
|Change an interface IP address.
| {{code|ip '''a'''ddr del $ip/$mask dev $interface <br /> ip '''a'''ddr add $ip/$mask dev $interface}}
| Change an interface IP address.
Requires remove/add in {{code|iproute2}}.
Requires remove/add in {{code|iproute2}}.
|{{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|ifconfig $interface:X $ip [netmask $netmask]}}
|Adds a secondary IP to an interface. Old net-tools uses interface:X to denote secondary addresses (eg. {{code|eth0:0}}).
| {{code|ip '''a'''ddr add $ip/$mask dev $interface}}
|{{code|ifconfig $interface:X $ip [netmask $netmask]}}
| Adds a secondary IP to an interface. Old net-tools uses interface:X to denote secondary addresses (eg. {{code|eth0:0}}).
|{{code|ip '''a'''ddr add $ip/$mask dev $interface}}
|-
|-
| {{code|ifconfig $interface 0.0.0.0}}
|Removes the IP address on an interface
| {{code|ip '''a'''ddr del $ip/$mask dev $interface}}
|{{code|ifconfig $interface 0.0.0.0}}
| Removes the IP address on an interface
|{{code|ip '''a'''ddr del $ip/$mask dev $interface}}
|-
|-
| {{code|route add default gw $gateway}}
|Adds a default gateway
| {{code|ip '''r'''oute add default via $gateway}}
|{{code|route add default gw $gateway}}
| Adds a default gateway
|{{code|ip '''r'''oute add default via $gateway}}
|-
|-
| {{code|route del default gw $gateway}}
|Removes a default gateway
| {{code|ip '''r'''oute del default via $gateway}}
|{{code|route del default gw $gateway}}
| Removes a default gateway
|{{code|ip '''r'''oute del default via $gateway}}
|-
|-
| {{code|route add -net $net netmask $netmask gw $gateway}}
|Adds a static route via a gateway
| {{code|ip '''r'''oute add $net/$mask via $gateway}}
|{{code|route add -net $net netmask $netmask gw $gateway}}
| Adds a static route via a gateway
|{{code|ip '''r'''oute add $net/$mask via $gateway}}
|-
|-
| {{code|route del -net $net gw $gateway netmask $netmask dev $device}}
|Deletes a static route
| {{code|ip '''r'''oute del $net/$mask via $gateway}}
|{{code|route del -net $net gw $gateway netmask $netmask dev $device}}
| Deletes a static route
|{{code|ip '''r'''oute del $net/$mask via $gateway}}
|-
|-
| {{code|route -n}}
|Shows routing table
| {{code|ip '''r'''oute}}
|{{code|route -n}}
| Shows routing table
|{{code|ip '''r'''oute}}
|}
|}


== See also ==


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

Revision as of 21:16, 29 December 2021

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
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