如何知道Linux中特定端口的流量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10536386/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 06:15:54  来源:igfitidea点击:

How to know traffic to a specific port in linux

linuxporttrafficnetwork-traffic

提问by uday kiran

I am looking to find the traffic through a specific port for a time frame. For example, traffic through 3306 port for 10 seconds. Is there a way to find this information?

我正在寻找通过特定端口的时间范围内的流量。例如,通过 3306 端口的流量持续 10 秒。有没有办法找到这些信息?

I see that "/sbin/ifconfig eth0 05" can be used to get information on total bytes but I am looking to find information about specific port's traffic.

我看到“/sbin/ifconfig eth0 05”可用于获取有关总字节数的信息,但我正在寻找有关特定端口流量的信息。

Thanks in advance,

提前致谢,

采纳答案by Rawkode

tcpdump -i eth0 -s 1500 port 3306

回答by Xypron

sudo iftop -P -n -N -m 10M -f 'port 3260'
  • -P display ports
  • -n no hostname lookup
  • -N display ports not service names
  • -m limit for bandwidth scale
  • -f filter rule
  • -P 显示端口
  • -n 不查找主机名
  • -N 显示端口而不是服务名称
  • -m 限制带宽规模
  • -f 过滤规则