Ric*_*son 4 ip packet-capture tcpdump arp packet
我正在转储传出流量。我只想要发往局域网外的 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
Run Code Online (Sandbox Code Playgroud)
但我捕获了以下数据包:
###[ 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'
Run Code Online (Sandbox Code Playgroud)
这里发生了什么?我以为我只转储IP 数据包。
通过查看转储,您收到了具有 IP 协议类型的ARP数据包(即ptype = 0x800)。您还应该过滤掉 ARP 数据包and (not arp),这样就会清理您的转储。我想,如果你查看 tcpdump 代码,你会发现它还保留这些特定 ARP 数据包的原因(但由于 IP 使用这些数据包进行网络解析,我猜这些 ARP 数据包被 tcpdump 视为 IP 的一部分)。
亲切的问候,
博