Jun 6, 2017, 1:35 AM
Post #1 of 2
i'm trying to solve some problem thinking how to start..
receiving free ip from giving subnet
my task is to give as argument subnet ip in CIDR notation (for example: 192.168.1.0\24)
and hostname as FQDN format (for example: host01.domain.com)
and to get, first, 1 free ip from the subnet, meaning that it is not online/ping-able and not have any PTR record.
second, for the fqdn i want to make sure it is not registered in DNS.
is any one have some subroutine in-hand?
my ($free_ip, $valid_fqdn) = query_ip_dns('192.168.1.0\24','host01.domain.com');
$free_ip should return free ip from within the given subnet range or return undef in case all hosts in subnet are in use.
$valid_fqdn can return true/false - registered in DNS already or not.
the idea is that if all checks will pass,
later on the script will register 'A record' in DNS with the provided FQDN and the retuerned IP.
Thanks in advance,