LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   external script/program - dhcp server (http://www.linuxquestions.org/questions/linux-server-73/external-script-program-dhcp-server-4175432118/)

Linux Chips 10-14-2012 04:37 AM

external script/program - dhcp server
 
Hi All

i want to set up a new dhcp server, but what i need is not a static configurations. i want to calculate one of the options in an external script/program and give the results back, so it can be included in the offer packet. the closest thing i have found is "execute", but i can't get an output from it.
are there other servers with such a feature? or do i need to hack some code?

if i will be adding this to the source, any hints/suggestions will be appreciated.

thanks in advance

Noway2 10-14-2012 12:43 PM

From the DHCP man page:
Quote:

Dhcpd can be made to use an alternate configuration file with the -cf flag, an alternate lease file with the -lf flag, or an alternate pid file with the -pf flag. Because of the importance of using the same lease database at all times when running dhcpd in production, these options should be used only for testing lease files or database files in a non-production environment.
You will probably want to modify the init script that starts the DHCP server to perform the tests required and then select the appropriate file.

Linux Chips 10-15-2012 05:36 AM

hi Noway2

thanks for your reply, though it dose not serve my purpose. this is kind of static configurations selected at start up. what i need is to give back replies based on the request. e.g. based on mac address or time of day and some other attributes. so i can do something like:

Code:

    subnet 192.168.0.0 netmask 255.255.255.0 {
    range 192.168.0.20 192.168.0.250;
    option domain-name execute_GetOutPut(getdomainname,clientmac);
    option domain-name-servers execute_GetOutPut(getdomainip,clientmac);;
    option broadcast-address 192.168.0.255;
    option routers 192.168.0.1;
    next-server 192.168.0.1;
    option subnet-mask 255.255.255.0;
}

getdomainname would be an executable that would print the correct domain for this device to stdout.
any other ideas?? is it even possible??

Noway2 10-15-2012 04:09 PM

I don't know of any way to call functions dynamically from within the configuration file. I also don't know if DHCP supports this type of function. In all likelihood, you would have to modify the process daemon that performs the initialization to read this configuration line and make the call(s) and then set the options. The closest thing I know of in DHCP is to filter based on an attribute like MAC address and make static assignments. If you have a large number of entries, this could be a monster to feed and support.

My honest suggestion would be to take another look at how your network is partitioned and see if there is a way to break things down into more logical groupings that you could then zone off into common sections and write DHCP blocks for these sections.

Linux Chips 10-16-2012 04:43 AM

thanks Noway2.... i am afraid that my setup requires per single user configuration and it would be very hard to put it all in a config file.
if any one is interested/willing to help , i ll try and dive into the code when i get some free time. if i get some thing working i ll be posting the result back here.


All times are GMT -5. The time now is 12:40 PM.