LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Dhcpd.conf file - Best practices? (https://www.linuxquestions.org/questions/linux-server-73/dhcpd-conf-file-best-practices-665251/)

custangro 08-25-2008 10:43 AM

Dhcpd.conf file - Best practices?
 
Hello,

I have a dhcpd.conf file that looks like this

Code:

authoritative;
ddns-update-style interim;
default-lease-time 28800;
max-lease-time 28800;

        option routers                  192.168.2.1;
        option broadcast-address        192.168.2.255;
        option subnet-mask              255.255.255.0;
        option domain-name-servers      192.168.2.225, 192.168.2.223;
        option domain-name              "mydomain.org";

        subnet 192.168.2.0 netmask 255.255.255.0 {
            pool {
                range 192.168.2.205 192.168.2.212;
                host it-laptop {
                hardware ethernet 00:16:cb:99:50:e0;
                }
                host hr-laptop {
                hardware ethernet 00:16:cb:a9:0b:fc;
                }
                deny unknown-clients;
            }
}

Which works...(kinda...it sometimes has touble giving up the lease...); but I've read articles/man pages that leads me to believe that the conf file should look like this...

Code:



        subnet 192.168.2.0 netmask 255.255.255.0 {
            pool {
              authoritative;
              ddns-update-style interim;
              default-lease-time 28800;
              max-lease-time 28800;
              option routers                  192.168.2.1;
              option broadcast-address        192.168.2.255;
              option subnet-mask              255.255.255.0;
              option domain-name-servers      192.168.2.225, 192.168.2.223;
              option domain-name              "mydomain.org";

                range 192.168.2.205 192.168.2.212;
                host it-laptop {
                hardware ethernet 00:16:cb:99:50:e0;
                }
                host hr-laptop {
                hardware ethernet 00:16:cb:a9:0b:fc;
                }
                deny unknown-clients;
            }
}

What is the "best practice" with dhcpd.conf file?

Thanks,

-C

** I'm running this on CentOS 5.2

ajg 08-25-2008 01:36 PM

It all depends on what your're tring to achieve. TBQH I hate "best practice" stuff because it implies a prescriptive approach. Not everybody works the same way, so there are always exeptions.

The two examples you have a perfectly valid.

Your first example, the router, mask, lease time, etc. are global options and will be applied to any subnet listed. They work like a set of default settings so you don't have to worry about configuring them for each subnet requiring DHCP services. Some of these are fine to have as globals like the leas time and the ddns update style. The router and subnet mask could be a problem if you're DHCPing more than a single IP subnet however.

The second example has all the options attached to the DHCP pool, so there are no defaults and any additional subnets which need to be DHCPed all need to be configured independantly.

Reading between the lines a little, I suspect that you only have one subnet, so it doesn't really matter - either solution is good for your purposes.

If you were looking at expanding the network later, I would probably move the router, broadcast and mask into the pool, as these options are generally invalid for other pools.

custangro 08-25-2008 01:58 PM

Quote:

Originally Posted by ajg (Post 3259275)
It all depends on what your're tring to achieve. TBQH I hate "best practice" stuff because it implies a prescriptive approach. Not everybody works the same way, so there are always exeptions.

The two examples you have a perfectly valid.

Your first example, the router, mask, lease time, etc. are global options and will be applied to any subnet listed. They work like a set of default settings so you don't have to worry about configuring them for each subnet requiring DHCP services. Some of these are fine to have as globals like the leas time and the ddns update style. The router and subnet mask could be a problem if you're DHCPing more than a single IP subnet however.

The second example has all the options attached to the DHCP pool, so there are no defaults and any additional subnets which need to be DHCPed all need to be configured independantly.

Reading between the lines a little, I suspect that you only have one subnet, so it doesn't really matter - either solution is good for your purposes.

If you were looking at expanding the network later, I would probably move the router, broadcast and mask into the pool, as these options are generally invalid for other pools.

Thanks for the insightful answer :)

And your guess is right; I am only worrying about this one subnet (we have multiple subnets; but we are only running dhcp on this one subnet). So I guess it _really_ doesn't matter since we aren't running anything fancy in terms of dhcp. Just only this small range.

Thanks again!

-C


All times are GMT -5. The time now is 10:15 AM.