Using the Linux arping command to ping local systems

该arping.command can ping local systems to find out whether they are responsive, and with the help of scripts, can ping specific IP-address ranges.

雷竞技电脑网站数据中心走廊与数字连接抽象叠加的服务器。
sdecoret / getty图像

arping.command is one of the lesser known commands that works much like thep命令。

名称代表“ARP ping”,它是一个允许您执行有限的工具p请求仅在其上收集有关本地系统的信息。其原因是它使用第2层网络协议,因此是不可用于的。该arping.command is used for discovering and probing hosts on your local network.

如果arping.未安装在系统上,您应该能够使用其中一个命令来处理:

$ sudo apt安装Arping -y $ sudo yum安装Arping -y

你可以像这样用p一个nd, as withp,您可以设置要使用的数据包的计数-c(e.g., arping -c 2 hostname) or allow it to keep sending requests until you type^c。在第一个示例中,我们向系统发送两个请求:

$ Arping-C 2 192.168.0.7 Arping 192.168.0.7从192.168.0.0.0.11 ENP0S25单播回复192.168.0.7 [20:EA:16:01:55:EB] 64.895ms单播回复192.168.0.7 [20:EA:16:01:55:EB] 5.423ms发送2个探针(1个播放)收到2次回复

请注意,响应显示接收回复和正在探测系统的MAC地址所需的时间。

如果you use the-f选择,你的arping.will stop as soon as it has confirmed that the system is responding. That might sound efficient, but it will never get to the stopping point if the system—possibly some non-existent or shut down system—fails to respond. Using a small value is generally a better approach. In this next example, the command tried 83 times to reach the remote system before I killed it with a^c那一个nd it then provided the count.

$ Arping -f 192.168.0.77 Arping 192.168.0.77起192.168.0.0.11 ENP0S25 ^ CSENT 83探针(83个播放)收到0响应

对于已启动并准备回复的系统,响应快速。

$ ARPing -F 192.168.0.7 ARPing 192.168.0.7从192.168.0.0.11 ENP0S25单播回复192.168.0.7 [20:EA:16:01:55:EB] 82.963Ms发送了1个探针(1个广播)收到1次响应(s)广播 - 发出所有人以接收

pcommand can reach remote systems easily wherearping.尝试但没有得到任何反应。比较下面的回复。

$ arping -c 2 world.std.com arping 192.74.137.5从192.168.0.0.0.0.0.11 enp0s25发送了2个探针(2个播放)收到0 response(s)$ ping -c 2 world.std.com ping world.std。COM(192.74.137.5)56(84)个字节的数据。来自world.std.com(192.74.137.5)的64个字节):ICMP_SEQ = 1 TTL = 48次= 321 MS 64字节来自World.std.com(192.74.137.5):ICMP_SEQ = 2 TTL = 48次= 331 ms  -world.std.com ping统计 -  2个报文传输,2个收到的,0%丢包,时间1002ms RTT MIN / AVG / MAX / MDEV = 321.451 / 326.068 / 330.685 / 4.617 MS

显然,arping.不能在远程服务器上收集信息。

如果you want to usearping.对于一系列系统,您可以使用如下的命令,这将是相当快的,因为它只尝试一次在提供的范围内达到每个主机。

$ for num in {1..100};做-C 1 192.168.0。$ num;192.168.0.1从192.168.0.0.11 enp0s25单播回复从192.168.0.1 [f8:8e:85:35:7f:b9] 5.530ms发送了1个探针(1次播放)1次响应192.168。0.2从192.168.0.0.0.11 enp0s25发送了1个探针(1次播放)0次响应从192.168.0.11 enp0s25单播回复192.168.0.3 [02:0f:b5:22:22:e5:90]76.856ms发送了1个探针(1个播放)收到的1次响应192.168.0.4从192.168.0.11 enp0s25单播回复192.168.0.4 [02:0f:b5:5b:d9:66] 83.000ms发送1探针(1次广播)收到1个回复......

请注意,我们看到一些响应显示了一个回复以及没有答复的其他人。

这是一个简单的脚本,它将提供网络范围中的哪个系统的列表,并且没有:

#!/bin/bash for num in {1..255}; do echo -n “192.168.0.$num “ arping -c 1 192.168.0.$num | grep “1 response” if [ $? != 0 ]; then echo “” fi done

Change the IP address range in the script to match your local network. The output should look something like this:

$ ./detectIPs 192.168.0.1 Received 1 response(s) 192.168.0.2 Received 1 response(s) 192.168.0.3 Received 1 response(s) 192.168.0.4 Received 1 response(s) 192.168.0.5 192.168.0.6 Received 1 response(s) 192.168.0.7 Received 1 response(s) 192.168.0.8 192.168.0.9 Received 1 response(s) 192.168.0.10 192.168.0.11 Received 1 response(s)

如果您只想看到响应系统,请简化这样的脚本:

#!/ / bin / bash for num in {1..30};DO ARPY-C 1 192.168.0。$ num |grep“1响应”> / dev / null如果[$?== 0];然后回声“192.168.0。$ num”fi完成

以下是输出与第二个脚本的样子。它仅列出响应系统。

$ ./detectIPs 192.168.0.1 192.168.0.2 192.168.0.3 192.168.0.4 192.168.0.6 192.168.0.7

arping.命令使网络在网络上快速且简单地检查一系列系统,并且当您想要创建网络的地图时可以有用。

加入网络世界社区有个足球雷竞技appFacebook.一个ndlinkedin.to comment on topics that are top of mind.
有关:

版权所有©2020.Raybet2

IT薪水调查:结果是