Detailed explanation of iftop command under Linux

iftop is a powerful network traffic monitoring tool that can display the traffic of network interfaces in real time. This article will explain in detail the past, present, functions and usage of the iftop instruction, and provide examples and reference links to help better understand and apply the instruction.

1. The past and present life of iftop

iftop is a terminal-based real-time traffic monitoring tool, first developed by Paul Warren. It can display the real-time traffic situation of the network interface, including the source IP address, destination IP address, transmission rate, etc. of each connection. iftop is very useful in network management and troubleshooting. It can help us monitor network traffic in real time and understand the status of network connections.

2. Functions and usage of iftop

The iftop directive can be used for the following functions and purposes:

1. Monitor network traffic in real time

We can use the iftop command to monitor the traffic of the network interface in real time. It will display the source IP address, destination IP address, transmission rate and other information of each connection, and display the distribution of network traffic in the form of a chart. This is very helpful for understanding network load and troubleshooting network problems.

Example:

iftop -i eth0

2. Sort by traffic

iftop can sort connections according to traffic size, thereby helping us quickly identify connections that occupy more bandwidth. By sorting by traffic, we can discover bottlenecks and anomalies in the network.

Example:

iftop -i eth0 -o 3s -s 2

3. Filter display connections

We can use the filtering function of the iftop directive to only display connections from a specific source IP address or destination IP address. This is very useful for locating the traffic situation of a specific host, helping us to quickly filter and analyze specific connections.

Example:

iftop -i eth0 -f "src host 192.168.0.1"

4. Display connection details

By specifying the option to show details, we can get more information about the connection, such as the connection's port number, protocol, etc. This helps us get a more complete picture of the network connection.

Example:

iftop -i eth0 -nN

5. Other functions

iftop also provides some other functions, such as setting display units, printing statistical information, etc. You can check the reference link for more detailed information.

3. The functions and differences of iftop parameters

The iftop command supports a variety of parameters and options, each parameter has

Different functions and differences. The following are some commonly used iftop parameters and their functions:

  • -i interface : Specify the network interface to monitor.
  • -B Display unit : Set the display unit, such as b, Kb, Mb, etc.
  • -F filtering rules : Set filtering rules and only display connections that meet the rules.
  • -n Do not resolve the host name : Disable host name resolution and only display the IP address.
  • -N Do not parse port numbers : disable port number parsing and only display port numbers.
  • -o Sorting interval : Set the sorting interval in seconds.
  • -s Sorting field : Set the sorting field, such as 2 means sorting by traffic.

For the specific functions and differences of each parameter, please refer to iftop’s official documentation or the resources in the reference link.

4. Example

Here are some examples of using the iftop directive to help us better understand its usage and functionality:

  1. Monitor the traffic on the eth0 interface:
iftop -i eth0
  1. Display connections sorted by traffic, refreshed every 3 seconds, and only display the first 2 records:
iftop -i eth0 -o 3s -s 2
  1. Only connections with source IP address 192.168.0.1 are displayed:
iftop -i eth0 -f "src host 192.168.0.1"
  1. Display connection details, including port number and protocol:
iftop -i eth0 -nN

The above examples are for reference only. Please set and adjust parameters according to actual needs and scenarios.

5. Reference links

When learning and using the iftop instruction, the following reference links will be helpful to us:

The above reference link provides more detailed explanations and examples to help us better understand and use the iftop directive.

By mastering the functions and usage of iftop, we can better monitor and analyze network traffic, troubleshoot network problems, and improve system performance.

Guess you like

Origin blog.csdn.net/AnChenliang_1002/article/details/131466949