Net-tools to iproute2: Difference between revisions
From Leo's Notes
This page was last edited on 11 March 2020, at 18:51.
mNo edit summary |
mNo edit summary |
||
| Line 8: | Line 8: | ||
! Description | ! Description | ||
|- | |- | ||
| {{code|arp}} | | {{code|arp -n}} | ||
| {{code|ip '''n'''eighbour}} | | {{code|ip '''n'''eighbour}} | ||
| Show ARP table | | Show ARP table | ||
| Line 48: | Line 48: | ||
| {{code|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 | | Bring an interface up or down | ||
|- | |||
| {{code|nameif eth1 xx:xx:xx:xx:xx:xx}} | |||
| {{code|ip link set dev eth0 name eth1}} | |||
| Renames eth0 to eth1, where {{code|xx:xx:xx:xx:xx:xx}} is eth0's MAC address | |||
|- | |||
| {{code|ifconfig eth0 mtu 1500}} | |||
| {{code|ip link set dev eth0 mtu 1500}} | |||
| Sets the MTU for eth0 to 1500 | |||
|- | |||
| {{code|ifconfig $interface $ip netmask $netmask}} | |||
| {{code|ip '''a'''ddr del $ip/$mask dev $interface | |||
ip '''a'''ddr add $ip/$mask dev $interface}} | |||
| Change an interface IP address | |||
Requires remove/add in iproute2 | |||
|- | |- | ||
| {{code|ifconfig $interface $ip netmask $netmask}} | | {{code|ifconfig $interface $ip netmask $netmask}} | ||
| Line 53: | Line 67: | ||
| Adds a secondary IP to an interface | | Adds a secondary IP to an interface | ||
|- | |- | ||
| {{code|ifconfig $interface | | {{code|ifconfig $interface 0.0.0.0}} | ||
| {{code|ip '''a'''ddr del $ip/$mask dev $interface}} | | {{code|ip '''a'''ddr del $ip/$mask dev $interface}} | ||
| | | Removes the IP address on an interface | ||
|- | |- | ||
| {{code|route add default gw $gateway}} | | {{code|route add default gw $gateway}} | ||
| {{code|ip '''r'''oute add default via $gateway}} | | {{code|ip '''r'''oute add default via $gateway}} | ||
| Adds a default gateway | | Adds a default gateway | ||
|- | |||
| {{code|route del default gw $gateway}} | |||
| {{code|ip '''r'''oute del default via $gateway}} | |||
| Removes a default gateway | |||
|- | |- | ||
| {{code|route add -net $net netmask $netmask gw $gateway}} | | {{code|route add -net $net netmask $netmask gw $gateway}} | ||
Revision as of 18:51, 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 -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 iproute2 | |
ifconfig $interface $ip netmask $netmask
|
ip addr add $ip/$mask dev $interface
|
Adds a secondary IP to an interface | |
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 |
The iproute2 sub commands can be specified with the shortest unambiguous name (ie. a or addr for address).
Some other commands: