Categories

Archives

Sending DHCP IP based on clients hostname

I’m working on a project where I need my DHCP server to send an IP address from a specific DHCP range if the hostname is a certain value otherwise it needs to send a normal IP address range.

I’m using Internet Systems Consortium DHCP Server V3.0.3 (ISC-DHCP).

To give a specific address range, we first need to detect if the DHCP client is sending the option 12 host-name and if so assign it to a class.

class “FooBar” { match if (option host-name = “foobar”); }

Once the client has a class associated to it we need to give it an address from a pool that doesn’t deny it.

subnet 192.168.0.0 netmask 255.255.255.0 {

Other DHCP settings here but make sure that the range is not specified; it overrides the pool settings.

pool {
allow members of “FooBar”;
range 192.168.0.90 192.168.0.99;
}

Otherwise we want the systems that don’t specify a hostname to get an address from the normal IP address pool

pool {
range 192.168.0.254 192.168.0.100;
}

Add more pools if needed

} # ending the subnet declaration

Pretty simple, hu?

UPDATE:

Thanks to a post I read by Bill Stephens of the PepsiCo Business Solutions Group, you can match a hostname using substr.  If your DHCP clients are named foobar-xyz you can use substr to match for foobar:

class “FooBar” {

match if ( substring(option host-name,0,6) = “foobar”);

}

(This would match the first 6 characters of the option 12 host-name)

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>