首页 > 解决方案 > Python3.6 Scapy 甚至从死主机接收 ICMP 响应

问题描述

得到了奇怪的东西。设置:VirtualBox + CentOs7 + python3.6 + scapy2.4.0

只有 4-5 个主机处于活动状态的网络:网关、VirtualBos 中的 CentO、运行 VirtualBox 的 PC 和其他东西。

试图做:

ans, unans = sr(IP(dst='10.10.10.1-100')/ICMP(), iface = 'enp0s3', retry=0, timeout=1)
Begin emission: ...

Received 1822 packets, got 99 answers, remaining 1 packets

ans
Results: TCP:0 UDP:0 ICMP:99 Other:0

unans
Unanswered: TCP:0 UDP:0 ICMP:1 Other:0

ans[x] - 是合法的 ICMP 回复数据包。

unans[0] - 没有来自 CentOs 虚拟机本身的 ICMP 回复

所以看起来一切都还活着,而不是实际上还活着的 4-5 个主机

可能的原因是什么?

标签: python-3.xvirtualboxcentos7pingscapy

解决方案


你想知道可能的原因,但 scapy 没有给你足够的细节。所以使用 tcpdump:

$ sudo tcpdump -e -c 200 icmp

在 tcpdump 运行时发送探测数据包,以查看地址和时间详细信息。您可能会看到许多完全正常的 ICMP,例如端口不可达或网络不可达。Tcpdump 将准确地告诉您通过网络接口发生了什么。


推荐阅读