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

I have an environment where there is one DHCP server servicing a number of different hosts/vlans. The switches are configured to forward the DHCP requests over (via ip-helper) and include information about the port (option 82). I'd like to take that information and translate it into an actual lease for the server.

I don't think it's particularly feasible for me to pregenerate a list of available leases, but I should be able to determine an address for a lease as it comes in.

Is there an DHCP server that can execute a script when it receives a request? (Note: I'm looking to assign the IP from the script, not have the DHCP server assign an IP then execute the script)

Edit: So, ultimately I'm trying to provide DHCP/PXE services over a large number of distinct vlans. This is so we can do OS installs via PXE booting without having to have a separate PXE vlan. I've got the switch config down no problem, and I have the DHCP server recognizing option 82.

I need a way to pull DHCP assignments from another system (this other system would know what subnet to use on what vlan), but I do not want to have to pregenerate a list of vlan:DHCP range pairs.

share|improve this question

2 Answers 2

Maybe you should take a look at dnsmasq. It can execute external and internal (LUA) scripts. The option --leasefile-ro should be what you are looking for.

http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

share|improve this answer
    
Based on my understanding of DNSMasq, the Lua functions are only executed after an IP is assigned. It's not possible to use the Lua functions to assign an IP. –  devicenull Oct 19 '12 at 21:08
    
You are correct. I'm sorry, it seems I overlooked that in the manual. –  bjoern Oct 20 '12 at 4:52

See this ServerFault question to give you some starting points if your DHCP server is Windows. 198383 ISC has functionalility for this. There is a lot of info on their web-site. Google will help.

Anyway this is quite complicated as the relay info you will get from the switch is very vendor specific.
For a small network you can probably get a much easier setup by simply setting up DHCP reservations for all your clients. If that is not feasible, which you seem to imply, be prepared for a lot of work figuring out how to do this.

share|improve this answer
    
I updated my initial post a bit. Getting Option 82 configured isn't really the problem, the problem is using that information without pregenerating a list of DHCP pools. –  devicenull Oct 3 '12 at 21:29
    
I think I understand your intent, but I wonder if its worth the effort? It might be a lot simpler to pre-generate that list. If you can script the on-the-fly assignment you should be able to apply the same logic to generate that list. –  Tonny Oct 3 '12 at 21:44
    
Well, the problem I have with the pregenerated stuff is that can be up to an hour out of date for us (that's the time between RANCID runs). Maybe it's worth investigating speeding up RANCID so we can pregenerate though. –  devicenull Oct 3 '12 at 22:12
    
I'm very much interested in the details of your use-case. I have a hard time imagining any scenario in which you have a such fast-changing environment that you need to run RANCID that often and at the same time need to reshuffle your ip address-space across your VLAN's. About the only thing I can think of is that you are using multiple VLAN's to separate L2 traffic while you only have 1 L3 subnet (of limited size) spread across those vlans and equipment and access-ports get moved between vlans every couple of minutes. –  Tonny Oct 4 '12 at 15:18
    
We run a datacenter. We'd like new machines to get provisioned (networking wise), then installed shortly after via PXE. There may not be a lot of time between the network setup and the machine needing an OS install. It's not so much that everything is constantly shifting, instead it's that changes need to be noticed fairly quickly. –  devicenull Oct 5 '12 at 0:44

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.