Net-tools to iproute2: Difference between revisions
From Leo's Notes
This page was last edited on 11 March 2020, at 18:54.
mNo edit summary |
mNo edit summary |
||
| Line 57: | Line 57: | ||
| Sets the MTU for eth0 to 1500 | | Sets the MTU for eth0 to 1500 | ||
|- | |- | ||
| {{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 | ||
ip '''a'''ddr add $ip/$mask dev $interface}} | ip '''a'''ddr add $ip/$mask dev $interface}} | ||
| Line 63: | Line 63: | ||
Requires remove/add in iproute2 | Requires remove/add in iproute2 | ||
|- | |- | ||
| {{code|ifconfig $interface $ip netmask $netmask}} | | {{code|ifconfig $interface:X $ip [netmask $netmask]}} | ||
| {{code|ip '''a'''ddr add $ip/$mask dev $interface}} | | {{code|ip '''a'''ddr add $ip/$mask dev $interface}} | ||
| Adds a secondary IP to an interface | | Adds a secondary IP to an interface. Old net-tools uses interface:X to denote secondary addresses (eg. {{code|eth0:0}}). | ||
|- | |- | ||
| {{code|ifconfig $interface 0.0.0.0}} | | {{code|ifconfig $interface 0.0.0.0}} | ||
Revision as of 18:54, 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: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 |
The iproute2 sub commands can be specified with the shortest unambiguous name (ie. a or addr for address).
Some other commands: