Wed, 19 May 2004

dhcpd configuration gotchas!

I’ve spent most of the day fighting with the ISC dhcpd, and I’ve finally figured out why things weren’t working, and it’s kinda funny/wierd, so I’m sharing.

For those who don’t remember/never knew, the config file looks sort of like this:

default options and stuff;

subnet 10.0.0.0 netmask 255.255.255.0
{
    range 10.0.0.10 10.0.0.20;
    option routers 10.0.0.1;

    host foo
    {
        hardware ethernet de:ad:be:ef:00:00;
        fixed-address foo.example.com;
    }   

    group
    {
        filename "/pxelinux.0";
        next-server 10.0.0.2;
        host netbooter
        {
            ...
        }
    }
}

Looks fine, right? It even works, parses, dhcpd doesn’t complain at all.

However, it’s wrong.

Let’s say you want to have your group of netbooters use a different router. No problem, you think. I’ll just put an “option routers” statement in the group, and call it a day.

If you try to do this, dhcpd will return the router specified in the subnet that the client is on, regardless of any other options that may be in closer scope. It does this, of course, to spite you. “Foolish network admin, you thought DHCP would save time”.

After about an hour, I suddenly realized that nowhere in the dhcpd.conf manpage does it suggest that you can nest a group inside of a subnet stanza. And lo, if you move the group to the top level, it all Works As It Should (tm).

In other words, the above should look like this:

default options and stuff;

subnet 10.0.0.0 netmask 255.255.255.0
{   
    range 10.0.0.10 10.0.0.20;
    option routers 10.0.0.1;

    host foo
    {   
        hardware ethernet de:ad:be:ef:00:00;
        fixed-address foo.example.com;
    }
}
group
{   
    filename "/pxelinux.0";
    next-server 10.0.0.2;
    host netbooter
    {   
        ...
    }
}

Now, I can appreciate that I read the manpage wrong, and wrote the config file wrong, and I accept that as my fault. But why does dhcpd mostly work when you nest a group within a subnet? Why doesn’t it explode, spewing error messages, or issue a warning? It’s the worst possible software behavior case: it just happens to work most of the time, but for reasons that nobody can explain.

[/config/dhcp3-server] permanent link