Net::DHCP::Config::Utilities::Generator::ISC_DHCPD - Generates a config for ISC DHCPD from the supplied subnets.
Version 0.0.1
use Net::DHCP::Config::Utilities::Generator::ISC_DHCPD; my $options={ output=>'./dhcp/dhcpd.conf', header=>'./dhcp/header.tt', footer=>'./dhcp/footer.tt', args=>{}, }; my $generator = Net::DHCP::Config::Utilities::Subnet->new( $options ); eval{ $generator->generate( $dhcp_util ); }; if ( $@ ){ # do something upon error die ( $@ ); } # just return it and don't write it output my $config; eval{ $config=$generator->generate( $dhcp_util ); }; if ( $@ ){ # do something upon error die ( $@ ); } print $config;
This initiates the object.
my $options={ output=>'./dhcp/dhcpd.conf', header=>'./dhcp/header.tt', footer=>'./dhcp/footer.tt', vars=>{}, }; my $generator = Net::DHCP::Config::Utilities::Generator::ISC_DHCPD->new( $options );
This is the file to write the output too.
This is the header template to use.
This is the footer teomplate to use.
This is a hash containing values to pass to Template as the \%vars value for when calling Template->process.
This gnerates the config for ISC DHCPD.
There are two options taken.
The first and mandatory is a Net::DHCP::Config::Utilities object that contains the subnets that we want to generate a config for.
The second is we want to write the output to the file or not. This is optional and if set to true no output will be writen.
This will return a string with the generated config.
If it is being outputed to a file, then ISC DHCPD will be called as 'dhcpd -t -cf $output' to lint it. It will die if it exits with a non-zero value.
eval{ $generator->generate( $dhcp_util ); }; if ( $@ ){ # do something upon error die ( $@ ); } # just return it and don't write it output my $config; eval{ $config=$generator->generate( $dhcp_util ); }; if ( $@ ){ # do something upon error die ( $@ ); } print $config;
A good base header template is as below.
default-lease-time 600; max-lease-time 7200; ddns-update-style none; authoritative; option web-proxy code 252 = text; log-facility local7;
In general the footer will be left empty. It is largely for use if you have like static hosts.
Zane C. Bowers-Hadley, <vvelox at vvelox.net>
<vvelox at vvelox.net>
Please report any bugs or feature requests to bug-net-dhcp-config-utilities at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-DHCP-Config-Utilities. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-net-dhcp-config-utilities at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Net::DHCP::Config::Utilities
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-DHCP-Config-Utilities
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Net-DHCP-Config-Utilities
CPAN Ratings
https://cpanratings.perl.org/d/Net-DHCP-Config-Utilities
Search CPAN
https://metacpan.org/release/Net-DHCP-Config-Utilities
This software is Copyright (c) 2019 by Zane C. Bowers-Hadley.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Net::DHCP::Config::Utilities, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::DHCP::Config::Utilities
CPAN shell
perl -MCPAN -e shell install Net::DHCP::Config::Utilities
For more information on module installation, please visit the detailed CPAN module installation guide.