Net-tools to iproute2: Difference between revisions
From Leo's Notes
This page was last edited on 11 March 2020, at 19:00.
mNo edit summary |
mNo edit summary |
||
| Line 6: | Line 6: | ||
! Old {{code|net-tools}} | ! Old {{code|net-tools}} | ||
! New {{code|iproute2}} | ! New {{code|iproute2}} | ||
! Description | ! width=20% | Description | ||
|- | |- | ||
| {{code|arp -n}} | | {{code|arp -n}} | ||
| Line 58: | Line 58: | ||
|- | |- | ||
| {{code|ifconfig $interface $ip [netmask $netmask]}} | | {{code|ifconfig $interface $ip [netmask $netmask]}} | ||
| {{code|ip '''a'''ddr del $ip/$mask dev $interface | | {{code|ip '''a'''ddr del $ip/$mask dev $interface <br /> ip '''a'''ddr add $ip/$mask dev $interface}} | ||
ip '''a'''ddr add $ip/$mask dev $interface}} | | Change an interface IP address. | ||
| Change an interface IP address | Requires remove/add in {{code|iproute2}}. | ||
Requires remove/add in iproute2 | |||
|- | |- | ||
| {{code|ifconfig $interface:X $ip [netmask $netmask]}} | | {{code|ifconfig $interface:X $ip [netmask $netmask]}} | ||
Revision as of 19:00, 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 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.
Old net-tools
|
New iproute2
|
Description | |
|---|---|---|---|
arp -n
|
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 | |
nameif eth1 xx:xx:xx:xx:xx:xx
|
ip link set dev eth0 name eth1
|
Renames eth0 to eth1, where xx:xx:xx:xx:xx:xx is eth0's MAC address
| |
ifconfig eth0 mtu 1500
|
ip link set dev eth0 mtu 1500
|
Sets the MTU for eth0 to 1500 | |
ifconfig $interface $ip [netmask $netmask]
|
ip addr del $ip/$mask dev $interface
|
Change an interface IP address.
Requires remove/add in | |
ifconfig $interface:X $ip [netmask $netmask]
|
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 0.0.0.0
|
ip addr del $ip/$mask dev $interface
|
Removes the IP address on an interface | |
route add default gw $gateway
|
ip route add default via $gateway
|
Adds a default gateway | |
route del default gw $gateway
|
ip route del default via $gateway
|
Removes 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 |
Some other commands: