Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between the old and new TCP/IP tools in Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how old TCP/IP tools differ from new ones in Linux. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

Many system administrators still configure network functionality and troubleshoot network problems by using a combination of command-line tools such as ifconfig, route, arp, and netstat (collectively known as net-tools), which originated in BSD's TCP/IP toolkit and later became tools for configuring network functionality in older versions of the Linux kernel. However, 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 iroute 2, which was introduced to replace net-tools in terms of network configuration tools.

What is the difference between the two? ** Net-tools uses procfs(/proc) and ioctl system calls to access and change kernel network configurations, while iroute 2 communicates with the kernel via the netlink socket interface. Performance aside, iroute 2's user interface is more intuitive than net-tools, and so far, iroute 2 is still in continuous development, so if you're still using net-tools and especially need to keep up with the latest and most important networking features in the new Linux kernel, it's time to move to iroute 2, because there's a lot you can do with iroute 2 that net-tools can't.

Here are a few examples:

Show all connected network interfaces ##The command below shows a list of all available network interfaces (whether active or not).

Using net-tools:

$ ifconfig -a

Using iproute2:

$ ip link show

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

Using net-tools:

$ sudo ifconfig eth2 up$ sudo ifconfig eth2 down

Using iproute2:

$ sudo ip link set down eth2$ sudo ip link set up eth2

Assign IPv4 addresses to network interfaces ##Use these commands to configure IPv4 addresses for network interfaces.

Using net-tools:

$ sudo ifconfig eth2 10.0.0.1/24

Using iproute2:

$ sudo ip addr add 10.0.0.1/24 dev eth2

It is worth noting that you can assign multiple IP addresses to the same interface using iroute 2, which ifconfig cannot. A workaround to using ifconfig is to use IP aliases.

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

##In terms of IP address removal, net-tools does not provide any suitable way to remove IPv4 addresses from network interfaces other than assigning all zeroes to the interfaces.

Using net-tools:

$ sudo ifconfig eth2 0

Using iproute2:

$ sudo ip addr del 10.0.0.1/24 dev eth2

5. Display the IPv4 address of a network interface ##Follow these steps to view the IPv4 address of a specified network interface.

Using net-tools:

$ ifconfig eth2

Using iproute2:

$ ip addr show dev eth2

Similarly, if an interface has multiple IP addresses assigned to it, iroute 2 displays all addresses, whereas net-tools displays only one IP address.

Assign IPv6 addresses to network interfaces ##Use these commands to add IPv6 addresses to network interfaces. Both net-tools and iroute 2 allow users to add multiple IPv6 addresses to an interface.

Using net-tools:

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

Using iproute2:

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

7. Display the IPv6 address of a network interface ##Follow these steps to display the IPv6 address of a specified network interface. Both net-tools and iroute 2 show all assigned IPv6 addresses.

Using net-tools:

$ ifconfig eth2

Using iproute2:

$ ip -6 addr show dev eth2

Remove IPv6 addresses from network devices ##Use these commands to remove unnecessary IPv6 addresses from interfaces.

Using net-tools:

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

Using iproute2:

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

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 the interface needs to be disabled before changing the MAC address.

Using net-tools:

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

Using iproute2:

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

10. View IP routing table ##Show kernel IP routing table: route and netstat. In iproute2, use the command ip route.

Using net-tools:

$ route -n$ netstat -rn

Using iproute2:

$ ip route show

**11. Add and Modify Default Routes ##The commands here are used to add or modify default routing rules in the kernel IP routing table. Note that in net-tools you can modify default routes by adding new default routes and deleting old ones. In iproute2, use ip route instead.

**

Using net-tools:

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

Use iroute 2:

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

Add and Remove Static Routes ##Add or remove a static route using the following command:

Using net-tools:

$ sudo route add -net 172.16.32.0/24 gw 192.168.1.1 dev eth0$ sudo route del -net 172.16.32.0/24

Using iproute2:

$ sudo ip route add 172.16.32.0/24 via 192.168.1.1 dev eth0$ sudo ip route del 172.16.32.0/24

##This command is used to view socket statistics (such as TCP/UDP sockets that are active or listening).

Using net-tools:

$ netstat$ netstat -l

Using iproute2:

$ ss$ ss -l

##Use these commands to display the ARP table of the kernel.

Using net-tools:

$ arp -an

Use iroute 2:

$ ip neigh

Add or delete a static ARP entry ##Add or delete a static ARP entry in the local ARP table as follows.

Using net-tools:

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

Using 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

Add, Remove, or View Multicast Addresses ##Configure or view multicast addresses on network interfaces using the following command.

Using 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

Using iproute2:

$ sudo ip maddr add 33:44:00:00:01 dev eth0$ sudo ip maddr del 33:44:00:00:01 dev eth0$ ip maddr list dev eth0 Thank you for reading! About "Linux old TCP/IP tools what is different" this article is shared here, I hope the above content can have some help for everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report