tcpdump -i 任意和混杂模式

del*_*ray 3 linux networking tcpdump

来自 tcpdump 4.1.1 的手册页(是的,我知道它是旧的)

   -i     Listen  on interface.  If unspecified, tcpdump searches the 
          system interface list for the lowest numbered, configured up 
          interface (excluding loopback).  Ties are broken by choosing >               the earliest match.

          On Linux systems with 2.2 or later kernels, an interface 
          argument of ``any'' can be used to capture packets from all
          interfaces.
          Note  that captures on the ``any'' device will not be done in
          promiscuous mode.
Run Code Online (Sandbox Code Playgroud)

任何人都可以阐明最后一句话的确切含义。我正在使用具有许多接口的 IDS 服务器,当我使用 tcpdump -i any 时,它清楚地显示流量不是源自/目的地为 IDS 服务器。然而,还有另一种服务已经将所有接口置于混杂模式。他们是否可能只是意味着如果您使用 -i any tcpdump 不会将接口置于 PROMISC 模式?

小智 6

他们是否可能只是意味着如果您使用 -i any tcpdump 不会将接口置于 PROMISC 模式?

是的,这就是我的意思。“任何”设备不能通过独立打开所有设备并在它们上捕获来工作,它通过打开“数据包套接字”来工作,而不是将其绑定到特定设备(这就是您在 Linux 上在该设备上捕获的方式) ,让它不受约束,所以它会监听所有的套接字。

设置混杂模式的调用会在未绑定的套接字上失败(我刚刚在一个相当新的内核上测试了它),因此 libpcap 不会为“任何”设备打开混杂模式。