Answer the question
In order to leave comments, you need to log in
How to find free ip addresses in dhcpd.conf?
There is a rather long dhcpd.conf file with ip addresses from different subnets. Can you tell me how to find free addresses? Using grep, I tore out all the lines from the file with addresses from the subnet I needed, I want to find out the unoccupied addresses.
Answer the question
In order to leave comments, you need to log in
Understood, in general, I publish the solution:
for ip in 192.168.0.{254..1} ; do
grep -oE "$ip" dhcpd.conf > /dev/null 2>&1
if [ $? != 0 ] ; then
echo "$ip is free"
fi
done
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question