Sometimes we need to ping some addresses on Linux to determine if the address is occupied
First, write the shell script
The script is as follows:
#!/bin/bashfor i in 192.168.16. {1..255} do (ping $i-C 2 >/dev/null 2>&1 [$?-eq 0] && echo "$i is Alive" ) &done
The effect is as follows
Second, the use of fping
Fping needs to be installed separately, it can ping a group of addresses,-G to specify a set of addresses, such as
Fping-g 192.168.16.1 192.168.16.200
Represents all the addresses between these two addresses.
-A option indicates that the alive is printed out of the host
[Email protected]:/tmp$fping-a-G 192.168.16.0/24 2>/dev/null
192.168.16.1
192.168.16.2
192.168.16.128
192.168.16.129
-u option to print out the unreachable host
[Email protected]:/tmp$Fping-u-G 192.168.16.0/24 2>/dev/null
192.168.16.3
192.168.16.4
192.168.16.5
...< ...
192.168.16.254
The effect is as follows:
Iii. Use of Nmap
NMAP-SP 192.168.99.0/24
The effect is as follows:
Iv. Automatic discovery using Zabbix
Because the ping host may not be allowed, because there is a terminal server on the firewall on Ping,zabbix can configure the Autodiscover rule, you can find the state of the host through PING,SSH, to determine the host address
Whether it is occupied
The effect is as follows:
Ping script on Linux and Auto-discovery on zabbix3.xx