DHCP on Server Core

I am loving being back in charge of a proper IT Infrastructure, and of course every admin is going to want to put his own touches on their servers.  One of the things I did in my first week was create a couple of new domain controllers running Windows Server Core.  Of course, when you create a domain controller the process will automatically install the DNS Server, but I also like to have DHCP running on some of my DCs.  In Server Core, at least in Server 2008 R2, there are a couple of quirks.

I should mention that a lot of this has changed in Server 2012, but until I upgrade our licenses I had to go back through my memory to remember how to do it in 2008 R2.  Here’s what I did.

  1. The first thing you have to do is install the role.  There are two ways to do it – I use DISM – dism.exe /online /enable-feature /FeatureName:DHCPServerCore.
  2. Next you have to enable the feature, and set it to start automatically.  use this command: sc config dhcpserver start= auto. Note the space after the =… I don’t question these things, but it doesn’t work without it.
  3. Now you simply start the service: net start dhcpserver.

Once this is done you have to authorize the server in Active Directory, and create a scope.  There is no way I would do this in the command line when I have the Remote Server Administration Toolkit installed on my laptop… but if you want to do so then here it is:

  1. netsh dhcp add server %computername% <ip address>
  2. netsh dhcp server <server ip address> add scope 10.200.15.0 255.255.255.0 ScopeName
  3. netsh dhcp server <server ip address> scope 10.200.15.0 add iprange 10.200.15.1 10.200.15.255

This has authorized the server, created a scope, and created an IP range in the new scope.

To add a Default Gateway and DNS Server to the scope (two very common options) you would do the following:

  1. netsh dhcp server <server ip address> scope 10.200.15.0 set optionvalue 003 IPADDRESS 10.200.1.1
  2. netsh dhcp server <server ip address> scope 10.200.15.0 set optionvalue006 IPADRESS 10.200.5.1

In the event you want to add an exclusion range, simply do the following:

netsh dhcp server <server ip address> scope 10.200.15.0 add excluderange 10.200.15.0 10.200.15.100.

And finally, we have to activate the scope.  Run the following:

netsh dhcp server <server ip address> scope 10.200.15.0 set state 1.

That’s it… of course a lot of this will be different in Server 2012, especially with PowerShell.  However if you are still running <slightly> older servers, this will do you well!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: