Set DHCP Reservations in a Windows DHCP server from a Linux node

dhcpwindows-server-2008

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?

Best Answer

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.

Related Topic