Net::ISC::DHCPd::OMAPI - Talk to a dhcp server
my $omapi = Net::ISC::DHCPd::OMAPI->new( key => "dhcpd secret", ); # connect is lazy $omapi->connect my $lease = $omapi->new_object(lease => ( ip_address => "10.19.83.200", )); if($lease->read) { printf("Got hardware_address=%s from ip_address=%s\n", $lease->hardware_address, $lease->ip_address, ); }
This module provides an API to query and possible change the ISC DHCPd server. The module use OMAPI (Object Management API) which does not require the server to be restarted for changes to apply. It does unfortunately support the protocol natively, but instead fork omshell(1) which this module read and write commands to.
omshell(1)
OMAPI is simply a communications mechanism that allows you to manipulate objects, which is stored in the dhcpd.leases file.
See subclasses for more information about the different objects you can manipulate: Net::ISC::DHCPd::OMAPI::Failover, Net::ISC::DHCPd::OMAPI::Group, Net::ISC::DHCPd::OMAPI::Host, and Net::ISC::DHCPd::OMAPI::Lease.
DHCP_OMAPI_DEBUG=1
This variable will enable debug output.
This attribute is read-only and holds a string describing the remote dhcpd server address. Default value is "127.0.0.1".
This attribute is read-only and holds an integer representing the remote dhcpd server port. Default value is "7911".
This attribute is read-only and holds a string representing the server secret key. It is in the format $name $secret and the default value is an empty string. An empty string is used for servers without a secret to log in.
$name $secret
Holds the last know error as a plain string.
$bool = $self->connect;
Will open a connection to the dhcp server. Check "errstr" on failure. A connection means starting the program omshell(1) and trying to log in, if the dhcpd "key" is set.
$bool = $self->disconnect;
Will disconnect from the server. This means killing the omshell(1) program, which then actually will make sure the connection is shut down.
$object = $self->new_object($type => %constructor_args);
This method will create a new OMAPI object, which can be used to query and/or manipulate the running dhcpd server.
$type can be "group", "host", or "lease". Will return a new config object.
$type
Example, with $type='host':
$type='host'
Net::ISC::DHCPd::Config::Host->new(%constructor_args);
See Net::ISC::DHCPd.
To install Net::ISC::DHCPd, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::ISC::DHCPd
CPAN shell
perl -MCPAN -e shell install Net::ISC::DHCPd
For more information on module installation, please visit the detailed CPAN module installation guide.