Are global directives needed in additional dhcpd conf files?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Are global directives needed in additional dhcpd conf files?

project722
Hi guys!

We are about to start using multiple config files for our dhcp markets.

I've created a folder called "include.d". The path is:

/etc/dhcp/include.d/

In my main dhcpd conf I've added the "include" directive:

include "/etc/dhcp/include.d/another-config.conf";

Inside the "anotherconfig" file I have started off the file with the "subnet" directive.

subnet 192.168.100.0 netmask 255.255.255.0 {

etc..,etc..

I have no global config. Things such as:

authoritative;
ddns-update-style none;
option domain-name-servers x.x.x.x x.x.x.x;
default-lease-time 604800;

Do I need to define these in my "anotherconfig" conf file? Or will it inherit the global directives by design?

TIA!






_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Are global directives needed in additional dhcpd conf files?

dave c
I've been leveraging include files for what seems like forever.

Think of an include file as if you dropped whatever was pointed to it into your config at that
exact point.

So, to answer your question, if you have a "global" type directive above that point in your
config file "stream", then it's still active until it is overwritten with a later directive.

You can even set an include into the middle of a config construct, for example, you can open a
shared-network configuration, then include individual files for different aspects of the
configuration, then close the shared-network and continue your config stream. I heavily leverage
this so that I can have tools like dhcpd-pools run against a filtered version of my "master
dhcp" config that removes the private subnets that are included in a shared network (for our
internal devices). Otherwise those massive private subs would mask a public pool from showing
it's empty of IPs or about to run out.

The privates are used for things like video set top boxes etc and need to co-exist in the same
shared network, but don't need to have external public IPs.

Hope this helps... includes simply insert a big set of text into the stream at their location.
Period.

Dave

On 8/20/18 09:25, project722 wrote:

> Hi guys!
>
> We are about to start using multiple config files for our dhcp markets.
>
> I've created a folder called "include.d". The path is:
>
> /etc/dhcp/include.d/
>
> In my main dhcpd conf I've added the "include" directive:
>
> include "/etc/dhcp/include.d/another-config.conf";
>
> Inside the "anotherconfig" file I have started off the file with the "subnet" directive.
>
> subnet 192.168.100.0 netmask 255.255.255.0 {
>
> etc..,etc..
>
> I have no global config. Things such as:
>
> authoritative;
> ddns-update-style none;
> option domain-name-servers x.x.x.x x.x.x.x;
> default-lease-time 604800;
>
> Do I need to define these in my "anotherconfig" conf file? Or will it inherit the global
> directives by design?
>
> TIA!
>
>
>
>
>
>
>
> _______________________________________________
> dhcp-users mailing list
> [hidden email]
> https://lists.isc.org/mailman/listinfo/dhcp-users
>
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Are global directives needed in additional dhcpd conf files?

Bob Harold

On Mon, Aug 20, 2018 at 11:43 AM Dave C <[hidden email]> wrote:
I've been leveraging include files for what seems like forever.

Think of an include file as if you dropped whatever was pointed to it into your config at that
exact point.

So, to answer your question, if you have a "global" type directive above that point in your
config file "stream", then it's still active until it is overwritten with a later directive.

You can even set an include into the middle of a config construct, for example, you can open a
shared-network configuration, then include individual files for different aspects of the
configuration, then close the shared-network and continue your config stream. I heavily leverage
this so that I can have tools like dhcpd-pools run against a filtered version of my "master
dhcp" config that removes the private subnets that are included in a shared network (for our
internal devices). Otherwise those massive private subs would mask a public pool from showing
it's empty of IPs or about to run out.

The privates are used for things like video set top boxes etc and need to co-exist in the same
shared network, but don't need to have external public IPs.

Hope this helps... includes simply insert a big set of text into the stream at their location.
Period.

Dave

That brings to mind a question - for DNS (BIND) I can use "named-checkconf -p" to print out a 'named.conf' file that has all the 'includes' processed, and comes out as one big file, so I can verify that it is actually getting what I expected.

Is there an equivalent of "named-checkconf -p" for dhcpd ?

-- 
Bob Harold

On 8/20/18 09:25, project722 wrote:
> Hi guys!
>
> We are about to start using multiple config files for our dhcp markets.
>
> I've created a folder called "include.d". The path is:
>
> /etc/dhcp/include.d/
>
> In my main dhcpd conf I've added the "include" directive:
>
> include "/etc/dhcp/include.d/another-config.conf";
>
> Inside the "anotherconfig" file I have started off the file with the "subnet" directive.
>
> subnet 192.168.100.0 netmask 255.255.255.0 {
>
> etc..,etc..
>
> I have no global config. Things such as:
>
> authoritative;
> ddns-update-style none;
> option domain-name-servers x.x.x.x x.x.x.x;
> default-lease-time 604800;
>
> Do I need to define these in my "anotherconfig" conf file? Or will it inherit the global
> directives by design?
>
> TIA!


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Are global directives needed in additional dhcpd conf files?

Peter Rathlev
On Mon, 2018-08-20 at 14:31 -0400, Bob Harold wrote:
> That brings to mind a question - for DNS (BIND) I can use "named-
> checkconf -p" to print out a 'named.conf' file that has all the
> 'includes' processed, and comes out as one big file, so I can verify
> that it is actually getting what I expected.
>
> Is there an equivalent of "named-checkconf -p" for dhcpd ?

I'm not aware of any built in, but we wrote a small shell script that
recursively parses the configuration and dumps with line numbers in the
order things are included.

  https://kelvin.rathlev.dk/dhcpd-dump-config

It's probably not the most efficient but for our current ~10000 line
configuration it's good enough, about half a second on our servers.

If you need the configuration without file names and line numbers then
just replace "-n" with "-h" in the grep command.

--
Peter

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Are global directives needed in additional dhcpd conf files?

Thomas Markwalder
You may test parse a dhcpd config file by using the command line options:

        -t     Test the configuration file.  The server tests the
configuration
               file  for  correct  syntax,  but will not attempt to
perform any
               network operations.  This can be used to test a new 
configura‐
               tion file automatically before installing it.

        -T     Test  the  lease file.  The server tests the lease file
for cor‐
               rect syntax, but will not attempt to perform any network 
opera‐
               tions.  In addition to reading the lease file it will
also write
               the leases to a temporary lease file.  The  current
lease  file
               will  not  be  modified  and  the  temporary  lease file
will be
               removed upon completion of the test. This can be used to
test  a
               new lease file automatically before installing it.

In either case dhcpd will attempt to parse the file(s) and then exit. 
Any errors
will be logged.

Regards,

Thomas Markwalder
ISC Software Engineering

On 09/10/2018 10:07 AM, Peter Rathlev wrote:

> On Mon, 2018-08-20 at 14:31 -0400, Bob Harold wrote:
>> That brings to mind a question - for DNS (BIND) I can use "named-
>> checkconf -p" to print out a 'named.conf' file that has all the
>> 'includes' processed, and comes out as one big file, so I can verify
>> that it is actually getting what I expected.
>>
>> Is there an equivalent of "named-checkconf -p" for dhcpd ?
> I'm not aware of any built in, but we wrote a small shell script that
> recursively parses the configuration and dumps with line numbers in the
> order things are included.
>
>    https://kelvin.rathlev.dk/dhcpd-dump-config
>
> It's probably not the most efficient but for our current ~10000 line
> configuration it's good enough, about half a second on our servers.
>
> If you need the configuration without file names and line numbers then
> just replace "-n" with "-h" in the grep command.
>

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users