我使用的是freebsd 10.4,我可以在tcpdump中使用什么参数来匹配特定的UDP端口?
是用-i参数吗?
该选项 -i
是为来自 人页:
-i interface
--interface=interface
Listen on interface. If unspecified, tcpdump searches the sys-
tem interface list for the lowest numbered, configured up inter-
face (excluding loopback), which may turn out to be, for exam-
ple, ``eth0''.
在同一页中,你有一些例子,如。
To print all IPv4 HTTP packets to and from port 80, i.e. print only
packets that contain data, not, for example, SYN and FIN packets and
ACK-only packets. (IPv6 is left as an exercise for the reader.)
tcpdump 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
也许这不是最简单的例子,但可以给你一个想法来实现你正在寻找的东西。
比方说,你想捕获DNS请求。UDP
埠 53
在您的主界面上 em0
这可以作为一个起点。
tcpdump -i em0 'udp port 53'
现在,如果你想更进一步,你可以用... ... Wireshark 在...上 ssh
试试吧。
wireshark -k -i <(ssh user@host sudo tcpdump -i em0 -U -w - not tcp port 22)
或以其他方式(在本例中使用PF接口)。pflog):
ssh use@server sudo tcpdump -i pflog0 -U -w -| wireshark -k -i -