문제

I have a quite huge dhcpd.conf file on my CentOS gateway with ip addresses from a few networks. With grep I find out all strings, which contains ip's from needed network. How can I find all free ip's (my network is 192.168.77.0/24).

도움이 되었습니까?

해결책

Not bullet-proof but should work:

grep -oE '192\.168\.77\.[0-9]+' dhcpd.conf

Not bullet-proof as it will find also 192.168.77.999 which is not an IP.


Update:

If you are just searching for those which are free (you told that in comments) then use:

for ip in 192.168.77.{254..1} ; do
    grep -oE "$ip" dhcpd.conf > /dev/null 2>&1
    if [ $? != 0 ] ; then
        echo "$ip is free"
    fi
done
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top