Results 1 to 9 of 9
Hey all.. I want to change my dhcpd.conf file dynamically using C program.. The values of the parameters in the dhcpd.conf file will be provided by an application which will ...
- 08-27-2011 #1Just Joined!
- Join Date
- Aug 2011
- Posts
- 5
DHCP Server
Hey all.. I want to change my dhcpd.conf file dynamically using C program.. The values of the parameters in the dhcpd.conf file will be provided by an application which will take inputs from the admin and accordingly, pass the values which I need to change in my dhcpd.conf file.. Please suggest some way to do it..
I thought of rewriting the .conf file each time when the values are given by the admin but will it be feasible??
Please anyone reply asap..
Thanks in advance...
- 08-27-2011 #2
Depends on the usecase, the implementation and tools used.
- We have several hundred servers
- each of them has at least three NICs (out-of-band management, "backend" and "production")
- with one mac per NIC
- at least one IP per NIC
- at least one hostname per NIC
We decided to use dhcp to give the same IP per mac.
In order to do this, we maintain hostname/IP and mac in a central place, namely our dns.
The mac address is realized as a HINFO record.
As the dns holds all informations neccessary for the dhcp config,
we wrote a puppet manifest that generates dhcpd config with dns data.
- On a puppet run (every 15min) the dhcp manifest will initiate a AXFR zone transfer
- There are some sanity checks of course: did the dig command exit succesfully, is there a minimum amount of data, etc
- The zone is then parsed into variables and arrays
- These variables and arrays are used in a dhcpd.conf template. Puppet allows ruby code in templates, so you can easily iterate over the array items and create each hostname/ip/mac definition.
- If (and only if) the newly generated dhcpd.conf differs from the previous one, then puppet will reload the appropiate dhcp server.
So, if we get a bunch of new machines,
- We decide on their names (which is based on their datacenter and a running number)
- Add those names along with IPs and macs to dns
- That is already enough to have also dhcp in place,
- which in turn allows a automated kickstart installation,
- which in turn establishes the machines first puppet run,
- which in turn puts the machine to work.
In your case:
What is your usecase? Is your dhcpd config also basically static and differs only in the amount of host definitions?
Or do you want your application to cover each possible config option? The latter might be a bit hard.
Writing an own application is surely possible, but is it worth it?
An effort like this is never a one shot action. You will have to maintain that app from then on.
As illustrated above, puppet may be usefull, as it is made for system management, has already some years of development,
can deal with files, has facilities to stop/start/reload daemons, has templating, etc,etc.You must always face the curtain with a bow.
- 08-27-2011 #3Just Joined!
- Join Date
- Aug 2011
- Posts
- 5
Actually, I want to cover the general used options only.. But the DHCP server will have to allocate the IP's statically to some hosts as per the application demands as well as dynamically to all the other hosts. And the information to the application will be provided by the admin. Currently, I have an idea of asking for all the parameters from the admin to enter into the application and hence rewriting the dhcpd.conf file each time a new update is encountered. This will be handled using a message queue.. Are there any other options available?? Please reply if any..
- 08-27-2011 #4
What would be the advantages for the admin using this application to enter information against just editing the dhcpd.conf with an editor of his/her choice?
One could imagine syntax checks and/or versioning and/or automatic restart for the daemon.
But this also has already been invented
- Syntax checks: dhcpd -t
- Versioning: svn/git/whatever
- Restart: see above, can be done with puppet
Imho: As an admin, I would hate to be limited in editing the dhcpd.conf by whatever the application can or cannot cover.You must always face the curtain with a bow.
- 08-27-2011 #5Just Joined!
- Join Date
- Aug 2011
- Posts
- 5
but what if the application GUI turns out to be a blessing in disguise for the admin and he doesnt want to manually modify the .conf file using a text editor.. What to do in this case??
- 08-27-2011 #6
I seriously doubt a unix guy would prefer a gui application over vi/emacs to edit dhcpd.conf, but ymmv.
Knock yourself out and report back.
I am interested to hear the outcome
You must always face the curtain with a bow.
- 08-27-2011 #7Just Joined!
- Join Date
- Aug 2011
- Posts
- 5
Basically, I m not a UNIX guy to think as u do.. So I prefer GUI unlike u
Moreover, when ppl demand something from us, we must try to fulfill their demands rather than negotiating it.. And as I was asked to do such a thing using a GUI so I have to do it..
- 08-27-2011 #8
Sorry, I didnt mean to offend you.
Moreover, some years ago I worked in an agency, so I know demanding clients.
We: "Do you want option A *or* option B?"
Client: 'Yes'
Meaning: Best of both -even if they contradict-, for half the price and yesterday...
I still believe it pays in the end to support the customer with in-depth knowledge and maybe alter the goals in that process instead of blindly doing whatever he wants.
After all, he searched for expertise
But back to topic:
Is it maybe an option to rely on something that has evolved since years instead of reinventing the wheel?
This here is graphical, with lots of icons to click on.
DHCPServer < Webmin < TWiki
Plus: As a webapp it can (via https/auth/vpn) always be available, no matter on which machine the admin happens to work.You must always face the curtain with a bow.
- 08-29-2011 #9Just Joined!
- Join Date
- Aug 2011
- Posts
- 5
okay wht u said is correct, but my case is such that the GUI will be prepared by someone else and I just have to read the data that will b coming from the GUI and interpret it properly to change my config file.. So any ideas on how to do so??
FYI, the data will be transfered in the form of mesasge queues.. Please reply if u know something abt it.. Thanks.


Reply With Quote