4

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?

Update:

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";
    fixed-address 10.16.5.23;
}

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

subnet 10.16.0.0 netmask 255.255.240.0
{
...
        # Include automatically-generated reservations
        include "/etc/dhcpd-10.16.0.0-20.conf";    
}

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?

David Mackintosh
  • 14,293
  • 7
  • 49
  • 78

2 Answers2

2

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

2

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 192.168.0.0:

netsh dhcp server srv1 scope 192.168.0.0 add reservedip 192.168.0.101 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.

jscott
  • 24,484
  • 8
  • 79
  • 100
  • OK, how do I get information out of NIS and into netsh? – David Mackintosh Sep 01 '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 01 '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 02 '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 02 '10 at 15:49