I. Introduction
- Before the business goes online, scan the ip address, and those addresses are not occupied.
- Through the for loop, keep pinging to test the IP address, assuming that our class C network segment has 254 public addresses, traversing from 1 to 254
Second, the script
#!/bin/bash
ip=192.168.10.
for((a=1;a<=254;a++))
do
b=${ip}${a}
ping -c 3 -i 0.2 -w 3 $b &>> /dev/null
if [ $? -eq 0 ]
then
echo "host $a is up" &>>up.txt
else
echo "host $a is down" &>>down.txt
fi
done