net-tools vs iproute2

Examples of using net-tools vs using iproute2

The tools are not equivalent and even though many times they appear to achieve the same result do not always arrive there the same way.

2 - Link Layer

Show ARP cache
# arp -an


# ip n


Add a permanent entry in the ARP cache
# arp -s 192.168.167.2 -i eth0 -D eth0 pub


# ip n add 192.168.167.2 lladdr 00:ab:cd:12:34:56 dev eth0 nud permanent


Delete an ARP entry
# arp -i eth0 -d 192.168.167.2


# ip n del 192.168.167.2 dev eth0


Show MAC addresses
# ip m


Add VLAN
# vconfig add eth0 3
# ifconfig eth0.3 192.0.2.8/25


# ip link add link eth0 name eth0.3 type vlan id 
# ip a add 192.0.2.8/25 dev eth0.3


Delete VLAN
# vconfig rem eth0.3


# ip link del eth0.3




3 - IP

Show Information up to Layer 3
# ifconfig


# ip a


Set an IP address
# ifconfig eth0:8 192.0.2.8/25


# ip a add 192.0.2.8/25 dev eth0 label eth0:8


Show default routing table
# route -n


# ip r


Add a default route
# route add default gw 192.0.2.10


# ip route add default via 192.0.2.10


Remove the default gateway
# route del -net 0/0 gw 192.0.2.10


# ip route del default via 192.0.2.10


Add and Remove a route
# route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.21.241.67
# route del -net 10.0.0.0 netmask 255.0.0.0 gw 10.21.241.67


# ip route add 10/8 via 10.21.241.67
# ip route del 10/8 via 10.21.241.67


Take down an interface
# ifdown eth0:1


# ip link set eth0:1 down


Bring up an interface
# ifup eth0:1


# ip link set eth0:1 up


If statistics
# netstat -i eth0


# ip -s link


Sockets
# netstat -putano


# ss -patu


Watch for netlink messages.
# ip monitor all




net-tools and iproute2