[Turn] Linux TCP/IP network small classroom: Net-tools and Iproute2 big comparison

Source: Internet
Author: User
Tags arch linux

Http://os.51cto.com/art/201409/450886.htm

Many system administrators today use command-line tools such as Ifconfig, Route, ARP, and Netstat (collectively referred to as Net-tools) to manage and troubleshoot various network configurations. This type of tool originally originated in the BSD TCP/IP toolkit and was designed to configure the network capabilities of older Linux kernels. Since 2001, it has stalled in the development of the Linux community. Some Linux distributions, such as Arch Linux and Centos/rhel 7, have been deprecated net-tools, and other distributions plan to discard Net-tools and use Iproute2 instead.

Iproute2 is another series of network configuration tools designed to replace the functionality of Net-tools. Net-tools can access and change the kernel network configuration through PROCFS (/PROC) and IOCTL system calls, and Iproute2 contacts the kernel via the network link socket interface. The/proc interface is more awkward than the network link interface. Aside from performance, Iproute2 's user interface is more intuitive than the Net-tools user interface. For example, network resources (such as links, IP addresses, routes, tunnels, etc.) are properly defined with "object" abstractions, and you can use consistent syntax to manage different objects. Most importantly, so far Iproute2 has been actively developing.

If you're still using Net-tools, it's time to switch to Iproute2, especially if you want to keep up with the latest and best network features of the Linux kernel. It is possible that there are many operations that can be implemented with IPROUTE2, but cannot be implemented with Net-tools, whether it is source-based routing, quality of service, virtual local area network (VLAN), binding, or what other actions the bridge is. It is also worth mentioning that more advanced network configuration tools such as network Manager rely on Iproute2.

For those who want to switch to Iproute2, the following is a comprehensive comparison of Net-tools and Iproute2.

Show all connected network interfaces

The following command shows all available network interfaces (whether they are active network interfaces).

Using Net-tools:

    1. $ ifconfig-a

Using Iproute2:

    1. $ IP Link Show

Activating or prohibiting a network interface

To activate/disable a network interface, you can use these commands.

Using Net-tools:

    1. $ sudo ifconfig eth1 up
    2. $ sudo ifconfig eth1 down

Using Iproute2:

    1. $ sudo IP link set down eth1
    2. $ sudo IP link set up eth1

Assigning one or more IPV4 addresses to a network interface

With these commands, you can configure the IPV4 address of the network interface.

Using Net-tools:

    1. $ sudo ifconfig eth1 10.0.0.1/24

Using Iproute2:

    1. $ sudo ip addr add 10.0.0.1/24 dev eth1

Note: If you use Iproute2, you can assign multiple IP addresses to an interface, and if you switch to Ifconfig, you won't be able to do that. As far as ifconfig is concerned, one workaround is to use IP aliases.

    1. $ sudo ip addr add 10.0.0.1/24 broadcast 10.0.0.255 Dev eth1
    2. $ sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 Dev eth1
    3. $ sudo ip addr add 10.0.0.3/24 broadcast 10.0.0.255 Dev eth1

Remove IPV4 address from network interface

In terms of removing an IP address, if you use Net-tools, there is no appropriate way to remove the IPV4 address from the network interface, except for allocating 0 to the interface. Iproute2 can deal with this problem rationally.

Using Net-tools:

    1. $ sudo ifconfig eth1 0

Using Iproute2:

    1. $ sudo ip addr del 10.0.0.1/24 dev eth1

Display one or more IPV4 addresses for a network interface

The IPV4 address of a network interface can be checked by the following methods.

Using Net-tools:

    1. $ ifconfig eth1

Using Iproute2:

    1. $ IP addr Show Dev eth1

Similarly, if multiple IP addresses are assigned to an interface, IPROUTE2 displays all IP addresses, and Net-tools only displays one IP address.

Assigning IPV6 addresses to network interfaces

With these commands, you can add one or more IPV6 addresses to a network interface. Both Net-tools and Iproute2 allow you to add multiple IPV6 addresses to an interface.

Using Net-tools:

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

Using Iproute2:

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

Display one or more IPV6 addresses for a network interface

You can display the IPV6 address of a network interface in the following ways. Both Net-tools and Iproute2 can display all assigned IPV6 addresses.

Using Net-tools:

    1. $ ifconfig eth1

Using Iproute2:

    1. $ ip-6 addr Show Dev eth1

Remove the IPV6 address of the network interface

Use these commands to remove any unnecessary IPV6 addresses for an interface.

Using Net-tools:

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

Using Iproute2:

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

Change the MAC address of the network interface

To spoof the MAC address of the network interface, use the following command. Note: Before changing the MAC address, you need to disable the interface first.

Using Net-tools:

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

Using Iproute2:

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

View IP routing Table

The Net-tools has two options for displaying the IP routing table for the kernel: route or netstat. If it is iproute2, just use the IP route command.

Using Net-tools:

    1. $ ROUTE-N $ netstat-rn

Using Iproute2:

    1. $ IP Route Show

Add or change a default route

The following commands can add or change the default route in the kernel IP routing table. Note: If you use Net-tools, you can change the default route by simply adding a new default route. If you use Iproute2, you only need to use the IP route replace command.

Using Net-tools:

    1. $ sudo route add default GW 192.168.1.2 eth0
    2. $ sudo route del default GW 192.168.1.1 eth0

Using Iproute2:

    1. $ sudo ip route add default via 192.168.1.2 dev eth0
    2. $ sudo IP route replace default via 192.168.1.2 Dev eth0

Add or remove static routes

You can use the following commands to add or remove static routes.

Using Net-tools:

    1. $ sudo route add-net 172.16.32.0/24 GW 192.168.1.1 Dev eth0
    2. $ sudo route del-net 172.16.32.0/24

Using Iproute2:

    1. $ sudo ip route add 172.16.32.0/24 via 192.168.1.1 Dev eth0
    2. $ sudo ip route del 172.16.32.0/24

Viewing socket statistics

The following commands allow you to view socket statistics (such as activate/listen TCP/UDP sockets).

Using Net-tools:

    1. $ netstat
    2. $ netstat-l

Using Iproute2:

    1. $ ss
    2. $ ss-l

viewing ARP Tables

You can use these commands to display the ARP table for the kernel.

Using Net-tools:

    1. $ arp-an

Using Iproute2:

    1. $ IP neigh

Add or remove static ARP entries

Adding or removing static ARP entries from a local ARP table can be done in the following ways.

Using Net-tools:

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

Using Iproute2:

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

Add, remove, or view a multicast address

To configure or view a multicast address on a network interface, you can use the following commands.

Using Net-tools:

    1. $ sudo ipmaddr add 33:44:00:00:00:01 dev eth0
    2. $ sudo ipmaddr del 33:44:00:00:00:01 dev eth0
    3. $ ipmaddr Show Dev eth0
    4. $ netstat-g

Using Iproute2:

    1. $ sudo ip maddr add 33:44:00:00:00:01 dev eth0
    2. $ sudo ip maddr del 33:44:00:00:00:01 dev eth0
    3. $ IP maddr List dev eth0

English Original: http://xmodulo.com/2014/09/linux-tcpip-networking-net-tools-iproute2.html

[Turn] Linux TCP/IP network small classroom: Net-tools and Iproute2 big comparison

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.