如何在tcpdump中仅转储传出的IP数据包?

时间:2012-06-05 13:36:19

标签: ip packet packet-capture tcpdump arp

我正在转发传出流量。我只希望TCP和UDP数据包发往我的局域网外,没有别的。我刚用tcpdump使用了以下过滤器:

ip and (tcp or udp) and (not icmp) and src host myIPAddr and not dst net myNet/myNetBits and not ip broadcast

但我抓住了以下数据包:

###[ Ethernet ]###
  dst       = ff:ff:ff:ff:ff:ff
  src       = 00:1e:4a:e0:9e:00
  type      = 0x806
###[ ARP ]###
     hwtype    = 0x1
     ptype     = 0x800
     hwlen     = 6
     plen      = 4
     op        = who-has
     hwsrc     = 00:1e:4a:e0:9e:00
     psrc      = X.X.X.X
     hwdst     = 00:00:00:00:00:00
     pdst      = Y.Y.Y.Y
###[ Padding ]###
        load      = '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

这里发生了什么?我以为我只是转发 IP数据包。

2 个答案:

答案 0 :(得分:1)

将主机上的过滤设置为源:

tcpdump src <YOUR_IP>

答案 1 :(得分:0)

通过查看您的转储,您收到了具有IP协议类型的 ARP 数据包(即 ptype = 0x800 )。您应该过滤掉ARP数据包and (not arp),这应该清理您的转储。我想如果你看看tcpdump代码,你会发现它为什么还保留这些特定的ARP数据包的原因(但是因为IP使用这些数据包进行网络解析,我猜这些ARP数据包被tcpdump视为IP的一部分)。

亲切的问候,

相关问题