Comparison of New and Old TCP/IP Tools in Linux

Nowadays, many system administrators still use command- line tools such as ifconfig, route, arp and netstat (collectively called net-tools) to configure network functions and solve network failures. Net-tools originated from the BSD TCP/IP toolbox. 

Later it became a tool for configuring network functions in the old version of the Linux kernel. But since 2001, the Linux community has stopped maintaining it, and even some Linux distributions such as Arch Linux and CentOS /RHEL 7 have completely abandoned net-tools and only support iproute2. 

For network configuration tools, iproute2 appears. Aims to replace net-tools functionally.

What is the difference between the old and new TCP tool?

net-tools uses procfs (/proc) and ioctl system calls to access and change the kernel network configuration, while iproute2 communicates with the kernel through the netlink socket interface.

Regarding performance, the user interface of iproute2 is more intuitive than net-tools. So far, iproute2 is still under continuous development. If you are still using net-tools, you especially need to keep up with the latest in the new Linux kernel.

For the most important network features, then it is time to switch to the iproute2 camp, because using iproute2 can do a lot of things that net-tools can’t do.

Here are a few examples:

1. Display all connected network interfaces

The following command displays a list of all available network interfaces (regardless of whether the interface is activated).

Use net-tools:

$ ifconfig -a

Use iproute2:

$ ip link show

2. Activate or deactivate a network interface

Use these commands to activate or deactivate a specified network interface.

Use net-tools:

$ sudo ifconfig eth1 up
$ sudo ifconfig eth1 down

Use iproute2:

$ sudo ip link set down eth1
$ sudo ip link set up eth1

3. Assign an IPv4 address to the network interface

Use these commands to configure the IPv4 address of the network interface.

Use net-tools:

$ sudo ifconfig eth1 10.0.0.1/24

Use iproute2:

$ sudo ip addr add 10.0.0.1/24 dev eth1

It is worth noting that you can use iproute2 to assign multiple IP addresses to the same interface, but ifconfig cannot. The workaround for using ifconfig is to use IP aliases.

$ sudo ip addr add 10.0.0.1/24 broadcast 10.0.0.255 dev eth1
$ sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev eth1
$ sudo ip addr add 10.0.0.3/24 broadcast 10.0.0.255 dev eth1

4. Remove the IPv4 address of the network interface

As far as the removal of the IP address is concerned, in addition to assigning all 0 addresses to the interface, net-tools does not provide any suitable method to remove the IPv4 address of the network interface. On the contrary, iproute2 It can be completed well.

Use net-tools:

$ sudo ifconfig eth1 0

Use iproute2:

$ sudo ip addr del 10.0.0.1/24 dev eth1

5. Display the IPv4 address of the network interface

Follow the steps below to view the IPv4 address of a specified network interface.

Use net-tools:

$ ifconfig eth1

Use iproute2:

$ ip addr show dev eth1

Similarly, if the interface is assigned multiple IP addresses, iproute2 will display all addresses, while net-tools can only display one IP address.

6. Assign an IPv6 address to the network interface

Use these commands to add an IPv6 address to the network interface. Both net-tools and iproute2 allow users to add multiple IPv6 addresses to an interface.

Use net-tools:

$ sudo ifconfig eth1 inet6 add 2002:0db5:0:f102::1/64
$ sudo ifconfig eth1 inet6 add 2003:0db5:0:f102::1/64

Use iproute2:

$ sudo ip -6 addr add 2002:0db5:0:f102::1/64 dev eth1
$ sudo ip -6 addr add 2003:0db5:0:f102::1/64 dev eth1

7. Display the IPv6 address of the network interface

Follow the steps below to display the IPv6 address of a specified network interface. Both net-tools and iproute2 can display all assigned IPv6 addresses.

Use net-tools:

$ ifconfig eth1

Use iproute2:

$ ip -6 addr show dev eth1

8. Remove the IPv6 address of the network device

Use these commands to remove unnecessary IPv6 addresses from the interface.

Use net-tools:

$ sudo ifconfig eth1 inet6 del 2002:0db5:0:f102::1/64

Use iproute2:

$ sudo ip -6 addr del 2002:0db5:0:f102::1/64 dev eth1

9. Change the MAC address of the network interface

Use the following command to tamper with the MAC address of the network interface. Please note that you need to disable the interface before changing the MAC address.

Use net-tools:

$ sudo ifconfig eth1 hw ether 08:00:27:75:2a:66

Use iproute2:

$ sudo ip link set dev eth1 address 08:00:27:75:2a:67

10. View the IP routing table

To display the kernel’s IP routing table: route and netstat. In iproute2, use the command ip route.

Use net-tools:

$ route -n
$ netstat -rn

Use iproute2:

$ ip route show

11. Add and modify default routing

The commands here are used to add or modify the default routing rules in the core IP routing table. Please note that you can modify the default route by adding a new default route and deleting the old default route in net-tools. Use the ip route command in iproute2 instead.

Use net-tools:

$ sudo route add default gw 192.168.1.2 eth0
$ sudo route del default gw 192.168.1.1 eth0

Use iproute2:

$ sudo ip route add default via 192.168.1.2 dev eth0
$ sudo ip route replace default via 192.168.1.2 dev eth0

12. Add and remove static routes

Use the following commands to add or remove a static route.

Use net-tools:

Use iproute2:

13. View socket statistics

The command here is used to view socket statistics (such as active or listening TCP/UDP sockets).

Use net-tools:

$ netstat
$ netstat -l

Use iproute2:

$ ss
$ ss -l

14. View the ARP table

Use these commands to display the kernel’s ARP table.

Use net-tools:

$ arp -an

Use iproute2:

$ ip neigh

15. Add or delete a static ARP entry

Follow the following operations to add or delete a static ARP entry in the local ARP table.

Use net-tools:

$ sudo arp -s 192.168.1.100 00:0c:29:c0:5a:ef
$ sudo arp -d 192.168.1.100

Use iproute2:

$ sudo ip neigh add 192.168.1.100 lladdr 00:0c:29:c0:5a:ef dev eth0
$ sudo ip neigh del 192.168.1.100 dev eth0

16. Add, delete or view the multicast address

Use the following command to configure or view the multicast address on the network interface.

Use net-tools:

$ sudo ipmaddr add 33:44:00:00:00:01 dev eth0
$ sudo ipmaddr del 33:44:00:00:00:01 dev eth0
$ ipmaddr show dev eth0
$ netstat -g

Use iproute2:

$ sudo ip maddr add 33:44:00:00:00:01 dev eth0
$ sudo ip maddr del 33:44:00:00:00:01 dev eth0
$ ip maddr list dev eth0

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

3 × five =

Related Articles