Linux 侦听网络端口并将数据保存到文本文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8934697/
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 04:08:26  来源:igfitidea点击:

Listen on a network port and save data to a text file

linuxnetworkinglistenerport

提问by Martin Petercak

Is there some easy way in linux to listen for data on network and save them to a text file?

在 linux 中是否有一些简单的方法来侦听网络上的数据并将它们保存到文本文件中?

Thank you.

谢谢你。

采纳答案by TomT the Weatherman

Netcat is your friend here.

Netcat 是您的朋友。

nc -l localhost 10000 > log.txt

Netcat will listen for a connection on port 10000, redirect anything received to log.txt.

Netcat 将侦听端口 10000 上的连接,将收到的任何内容重定向到 log.txt。

回答by Jayan

Other tools are Ethereal(man page) or Wiresharkand it's console variant tshark.

其他工具是 Ethereal手册页)或Wireshark以及它的控制台变体tshark

In any case please be aware that you are following local and company rules.

在任何情况下,请注意您遵守当地和公司的规定。

回答by Mike Mackintosh

Also available is TCPDump.

还可以使用 TCPDump。

sudo tcpdump -i eth0 -vvvvtttAXns 1500 'port 10000'