Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have a large number of clients who connect to our DHCP machine. We want to assign some of them to a different IP block, which is routed with lower priority. Every DHCP lease renewal, we'd like to check a database and decide which IP block we'd like to assign a customer to.

Is there a way to have a DHCP server execute a script, look in a database, or execute some dynamic code when deciding which address to assign in which pool? Each client is uniquely identified by option82, aka "DHCP Relay Agent Information Option".

share|improve this question
    
Which DHCP server on what OS? –  Zypher Jul 14 '10 at 18:35
    
This sounds like a carrier-type setup... is that the case? I would be surprised if something like this already existed in the open tools. I would probably look at writing it myself. Very interesting question though! –  MikeyB Jul 14 '10 at 20:18
    
@Zypher: Debian OS, regular dhcpd @MikeyB: Yes, carrier setup –  Andomar Jul 14 '10 at 21:15
add comment

4 Answers

up vote 2 down vote accepted
+50

Ideally, you'd modify dhcpd to support address assignment based on Option82, equivalent to the "hardware" lines in host objects. I've done it with the OpenBSD dhcpd when I worked at an ISP, which has a simpler internal structure to isc-dhcpd.

If you're not in a position to do that, then look at omapi(3) and omshell(1); you'd use OMAPI to dynamically create "class" and "pool" objects, to implement Zypher's suggestion. I just checked dhcpd.h and the class struct has an OMAPI_OBJECT_PREAMBLE, so this should be possible. Beware that the documentation on OMAPI can be a little ... skimpy.

share|improve this answer
    
The solution Zypher suggested is what we currently have. And I don't think the sysadmins would appreciate an edited version of dhcpd. But OMAPI seems like a good alternative, thanks! –  Andomar Jul 20 '10 at 22:31
add comment

So i havn't done this with option 82, but your best bet would be to use classing in isc dhcpd.

What you would do is setup a class like:

class "userclass1" { 
    match if substring(option agent.circuit-id, 2, 2) = "<your_id1>";
}
class "userclass2" { 
    match if substring(option agent.circuit-id, 2, 2) = "<your_id2>";
}

Then in your pool statement:

pool {
  allow members of "userclass1";
  range 10.0.0.11 10.0.0.50;
}
pool {
   allow members of "userclass2";
   range 10.0.0.51 10.0.0.100;
}

Reference: dhcpd.conf

This should at least get you on the right track, i don't have my play server up to test it, but i've done something similar with other options.

share|improve this answer
    
Wouldn't we have to reset dhcpd every time there is a change? Is it possible to have pool membership determined dynamically by a script call? –  Andomar Jul 15 '10 at 5:48
    
@Andomar: Yep you would. Unfortunately i don't think so - but i could be very wrong there –  Zypher Jul 15 '10 at 13:30
add comment

Maybe you can start from here:

http://blog.nominet.org.uk/tech/2005/12/21/using-omapi-object-management-application-programming-interface/

Never used, but with a bit of scripting I think it could work.

EDIT

man omshell(1) would give some other examples

share|improve this answer
add comment

One way to do this is to assign those clients to a separate VLAN, then the DHCP address those clients get will automatically be in a different pool.

share|improve this answer
    
Actually, switching VLAN is what we'd like to avoid. VLAN switches confuse the client's modems and take a long time to execute –  Andomar Jul 14 '10 at 21:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.