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.
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
I guess you can do this with the hook-system supported by ISC Kea (which is the meant-to-be replacement for ISC dhcpd). In KEA you can write your own hooks that run at specific stages. In this case the subnet4_select and lease4_select hooks would have to be implemented. In subnet4_select you make KEA choose the right subnet and in lease4_select you make it offer the right IP-Adress. However, this way you will have to write quite an amount of C++ code.
I would use ISC dhcpd/Kea and configure different IPs using conditions based on options set in the DHCP request.
See also:
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.