M
M
Mendax2014-03-12 15:01:27
linux
Mendax, 2014-03-12 15:01:27

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

2 answer(s)
M
Mendax, 2014-03-12
@Mendax

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

S
sonik_spb, 2014-03-12
@sonik_spb

Look for the line in the config:
range 192.168.0.20 192.168.0.260
This will be all the IP addresses reserved by the dhcp server, subtracting the free ones is not at all difficult.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question