The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::DHCP::Config::Utilities::Generator::ISC_DHCPD - Generates a config for ISC DHCPD from the supplied subnets.

VERSION

Version 0.1.0

SYNOPSIS

    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;

METHODS

new

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 );

args

output

This is the file to write the output too.

This is the header template to use.

This is the footer teomplate to use.

vars

This is a hash containing values to pass to Template as the \%vars value for when calling Template->process.

generate

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;

TEMPLATES

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.

AUTHOR

Zane C. Bowers-Hadley, <vvelox at vvelox.net>

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Net::DHCP::Config::Utilities

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2019 by Zane C. Bowers-Hadley.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)