如何监控Linux中特定进程的所有网络流量?

问题描述 投票:0回答:2

我想监控并记录特定进程产生的所有流量。

我知道

tcpdump
,但它似乎不支持按进程(pid/路径,或至少用户)过滤。

还有其他方法可以记录进程中的所有流量吗?理想情况下,我也应该能够过滤端口。

谢谢!

linux bash shell networking strace
2个回答
1
投票

您应该使用

strace
命令:

strace -o /tmp/network.out -e trace=network -fp <PID>

0
投票

strace -f -s10000 -yy -xx -ttt -T -p pid | py_strace2pcap.py pcap.文件

使用https://github.com/comboshreddies/py-strace2pcap

的工具
© www.soinside.com 2019 - 2024. All rights reserved.