I have a nice set up in my unixland where I have all my host information (names, IPs, mac addresses) in DNS and the associated NIS maps. This makes it easy to write a script which can generate a file containing DHCP lease reservation information, which can then be included by the isc dhcpd.conf for each scope. This means whenever a system is booted, it always gets the same IP whether it is static or not, and can figure out its DNS name trivially. This means for example that when I kickstart nodes, the post-install scripts can do host-specific things based on what name the system finds for itself at install time.

Now I'm being assimilated by a new organization, and their infrastructure runs on Windows. I am about to receive my brand new Windows DC, which will be the site's DNS and DHCP server.

So. Is there a way to put DHCP reservations in the new DHCP server, without having to do it manually?


So how this works in unix is that for each machine on my subnet, I can (effectively) do this:

$ ypmatch $MACHINE hosts
$ ypmatch $MACHINE ethers

...and generate a file full of entries like this:

host amstel
    hardware ethernet 00:04:76:f8:d8:71;
    option host-name "amstel";

...the filename of which is included in my dhcpd.conf as so:

subnet netmask
        # Include automatically-generated reservations
        include "/etc/dhcpd-";    

Then whenever I make an update, all I have to do is run the updater script and restart dhcpd.

So. Starting from the ypmatch ... what can I run on unixland that will insert this kind of reservation into a Windows DHCP server?


You can manuipulate DHCP using netsh. Using the DHCP server named srv1, add a reservation for computer named clientA.domain.lan, with MAC 00FF00FF00FF, to the scope

netsh dhcp server srv1 scope add reservedip 00FF00FF00FF clientA.domain.lan

You can do much more than DHCP with netsh. Typing netshenter in a Windows commmand prompt will switch you to the netsh context. The help command will display available options.

| improve this answer | |
  • OK, how do I get information out of NIS and into netsh? – David Mackintosh Sep 1 '10 at 19:34
  • @David: Could you detail the formatting of the "file containing DHCP lease reservation information" you mention? Does this file not contain MAC, hostname, IP? I may have misunderstood something. – jscott Sep 1 '10 at 19:45
  • See update. What I'm asking is, what is the workflow? Should my script generate a "netsh" batchfile which gets copied to the Windows server? Or is there something I can run right on my linux system to do this? – David Mackintosh Sep 2 '10 at 14:44
  • 1
    @david The workflow is to generate a script full of netsh calls, and then execute that script on the new DHCP server. To the best of my knowledge, even with Samba4 this can't be done directly from the Linux machine. – sysadmin1138 Sep 2 '10 at 15:49

Yes, netsh is a Windows command utility that can do this.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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