我正在努力使用nmap
。我想 ping 范围内的 IP 地址,比如 192.168.178.110-192.168.178.130,但也想 ping 单个 IP 192.168.178.1。
因此我执行:
nmap -sn 192.168.178.110-130 192.168.178.1
给我:
Starting Nmap 7.80 ( https://nmap.org ) at 2024-04-19 10:16 CEST
Nmap scan report for 192.168.178.119
Host is up (0.00076s latency).
Nmap scan report for 192.168.178.120
Host is up (0.0021s latency).
Nmap scan report for 192.168.178.121
Host is up (0.0020s latency).
Nmap scan report for 192.168.178.125
Host is up (0.0019s latency).
Nmap scan report for 192.168.178.127
Host is up (0.0017s latency).
Nmap scan report for 192.168.178.129
Host is up (0.0015s latency).
Nmap done: 22 IP addresses (6 hosts up) scanned in 2.21 seconds
但是,执行:
nmap -sn 192.168.178.110-130 192.168.178.0 192.168.178.1
给我:
Starting Nmap 7.80 ( https://nmap.org ) at 2024-04-19 10:23 CEST
Nmap scan report for 192.168.178.119
Host is up (0.00080s latency).
Nmap scan report for 192.168.178.120
Host is up (0.0022s latency).
Nmap scan report for 192.168.178.121
Host is up (0.0021s latency).
Nmap scan report for 192.168.178.125
Host is up (0.0018s latency).
Nmap scan report for 192.168.178.127
Host is up (0.0016s latency).
Nmap scan report for 192.168.178.129
Host is up (0.0014s latency).
Nmap scan report for 192.168.178.1
Host is up (0.0015s latency).
Nmap done: 23 IP addresses (7 hosts up) scanned in 1.41 seconds
因此,在第一次尝试中,尽管 IP 192.168.178.1 包含在命令行中,但并未列出。
在第二次尝试中,我添加了多余的 IP 192.168.178.0,然后它列出了 IP 192.168.178.1。为什么会这样?我对 IP 192.168.178.0 不感兴趣。对我来说,ping 该 IP 似乎是一种绕道而行,以便获取有关 IP 192.168.178.1 的可达性的信息。
更新:使用nmap -vv ...
显示nmap
能够在两种情况下解析给定的命令行。但是,IP 的结果192.168.178.1
仍然不一致。
nmap -vv -sn 192.168.178.110-130 192.168.178.1:
[...]
Nmap scan report for 192.168.178.1 [host down, received no-response],
nmap -vv -sn 192.168.178.110-130 192.168.178.0 192.168.178.1:
[...]
Nmap scan report for 192.168.178.0 [host down, received net-unreach] Nmap scan report for 192.168.178.1 Host is up, received syn-ack (0.0012s latency).