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 |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 4: | Line 4: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! Old {{code|net-tools}} | ! width="20%" |Description | ||
! New {{code|iproute2}} | !Old {{code|net-tools}} | ||
!New {{code|iproute2}} | |||
|- | |- | ||
| {{code|arp -n}} | |Show ARP table | ||
| {{code|ip '''n'''eighbour}} | |{{code|arp -n}} | ||
|{{code|ip '''n'''eighbour}} | |||
|- | |- | ||
| {{code|netstat -ln}} | |Show listening ports | ||
| {{code|ss -ln}} | |{{code|netstat -ln}} | ||
|{{code|ss -ln}} | |||
|- | |- | ||
| {{code|netstat -r}} | |Shows routing table | ||
| {{code|ip '''r'''oute}} | |{{code|netstat -r}} | ||
|{{code|ip '''r'''oute}} | |||
|- | |- | ||
| {{code|netstat -i }} | |shows network interface counters | ||
| {{code|ip -s '''l'''ink}} | |{{code|netstat -i }} | ||
|{{code|ip -s '''l'''ink}} | |||
|- | |- | ||
| {{code|netstat -g}} | |Show interface group memberships | ||
| {{code|ip maddr}} | |{{code|netstat -g}} | ||
|{{code|ip maddr}} | |||
|- | |- | ||
| {{code|iwconfig}} | |Wireless config | ||
| {{code|iw}} | |{{code|iwconfig}} | ||
|{{code|iw}} | |||
|- | |- | ||
| {{code|iptunnel}} | |IP Tunnel configuration | ||
| {{code|ip '''t'''unnel}} | |{{code|iptunnel}} | ||
|{{code|ip '''t'''unnel}} | |||
|- | |- | ||
| {{code|nameif}} | |Shows interfaces based on MAC address | ||
| {{code|ip '''l'''ink}} | |{{code|nameif}} | ||
|{{code|ip '''l'''ink}} | |||
|- | |- | ||
| {{code|ifconfig}} | |Shows interface addresses | ||
| {{code|ip '''a'''ddress}} | |{{code|ifconfig}} | ||
|{{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>}} | ||
|{{code|ip '''l'''ink set dev $interface <nowiki>[up|down]</nowiki>}} | |||
|- | |- | ||
| {{code| | |Renames eth0 to eth1, where {{code|xx:xx:xx:xx:xx:xx}} is eth0's MAC address | ||
| {{code| | |{{code|nameif eth1 xx:xx:xx:xx:xx:xx}} | ||
|{{code|ip link set dev eth0 name eth1}} | |||
|- | |- | ||
| | |Changes interface MAC address | ||
| | |<code>ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx</code> | ||
|<code>ip link set dev eth0 address xx:xx:xx:xx:xx:xx</code> | |||
|- | |- | ||
| {{code|ifconfig | |Sets the MTU for eth0 to 1500 | ||
| {{code|ip | |{{code|ifconfig eth0 mtu 1500}} | ||
|{{code|ip link set dev eth0 mtu 1500}} | |||
|- | |- | ||
| {{code|ifconfig $interface | |Change an interface IP address. | ||
| {{code|ip '''a'''ddr | 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 | |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 | |{{code|ifconfig $interface:X $ip [netmask $netmask]}} | ||
|{{code|ip '''a'''ddr add $ip/$mask dev $interface}} | |||
|- | |- | ||
| {{code| | |Removes the IP address on an interface | ||
| {{code|ip ''' | |{{code|ifconfig $interface 0.0.0.0}} | ||
|{{code|ip '''a'''ddr del $ip/$mask dev $interface}} | |||
|- | |- | ||
| {{code|route | |Adds a default gateway | ||
| {{code|ip '''r'''oute | |{{code|route add default gw $gateway}} | ||
|{{code|ip '''r'''oute add default via $gateway}} | |||
|- | |- | ||
| {{code|route | |Removes a default gateway | ||
| {{code|ip '''r'''oute | |{{code|route del default gw $gateway}} | ||
|{{code|ip '''r'''oute del default via $gateway}} | |||
|- | |- | ||
| {{code|route | |Adds a static route via a gateway | ||
| {{code|ip '''r'''oute | |{{code|route add -net $net netmask $netmask gw $gateway}} | ||
|{{code|ip '''r'''oute add $net/$mask via $gateway}} | |||
|- | |- | ||
| {{code|route - | |Deletes a static route | ||
| {{code|ip '''r'''oute}} | |{{code|route del -net $net gw $gateway netmask $netmask dev $device}} | ||
| Shows routing table | |{{code|ip '''r'''oute del $net/$mask via $gateway}} | ||
|- | |||
|Shows routing table | |||
|{{code|route -n}} | |||
|{{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 | ||
{{Navbox Linux}} | |||
[[Category:Linux]] | |||
{{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 |
ifconfig $interface $ip [netmask $netmask]
|
ip addr del $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
- Some other commands: http://unix.stackexchange.com/questions/152331/how-can-i-create-a-virtual-ethernet-interface-on-a-machine-without-a-physical-ad