问题描述
我关注了the official documentation。
我的远程服务器是CentOS 7.9,我已经在其中安装了Wireshark。
我使用以下命令打开本地wireshark软件以捕获远程服务器的接口数据包:
ssh root@remote-server-name 'dumpcap -w - -f "not port 22"' | wireshark -k -i -
但是我得到了错误信息:
Capturing on 'nflog'
dumpcap: Invalid capture filter "not port 22" for interface nflog!
That string isn't a valid capture filter (NFLOG link-layer type filtering not implemented).
See the User's Guide for a description of the capture filter syntax.
EDIT-01
我使用以下命令对界面进行特殊处理:
ssh root@remote-server-name -i .ssh/id_rsa 'dumpcap -w - -f "not port 22"' | wireshark -k -i em1
我的服务器中确实存在em1
。
[root@att ~]# ip a | grep em1
2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
inet remote-ip/29 brd remote-ip scope global noprefixroute em1
解决方法
错误消息说明了无法捕获的原因:
在“ nflog” dumpcap上捕获:无效的捕获过滤器“不是端口22” 界面nflog!
在远程服务器上执行的dumpcap命令没有参数-i <interface>
,这意味着dumpcap将选择finds中的第一个接口。在这种情况下,界面为nflog
。
所有捕获过滤器都是根据接口的链路层类型进行编译的,因为某些过滤器元素仅在特定链路层类型的接口上可用。
在这种情况下,捕获过滤器not port 22
对于接口nflog的链路层类型不是有效的捕获过滤器。
我假设您打算在远程主机的以太网接口上进行捕获。您可以使用命令dumpcap -D
列出远程主机上的接口。选择要捕获的接口,然后将参数-i <interface>
添加到远程捕获命令中的dumpcap命令中。
将-f "not port 22"'
更改为-f 'not tcp port 22'"
可能只是拼写错误。