Monday, August 20, 2012

Server 2012 Core DHCP Server scope quick setup

I frequently have a need to use small VMS to quickly prototype things.  And lately I have been all deep in Server 2012.

Just to give myself some extra pain I have also been using Server Core whenever I have no absolute need for a GUI (getting off that Windows graphical console point-and-click bandwagon).

My latest adventure is to quickly create a DHCP Server. 

Just to get this running is really rather painless in the end.  And figuring out the proper PowerShell commands was pretty straightforward as well.

Begin with a Server 2012 Core installation.

Make sure it has a manually assigned IP.  ( you can use SCVMM 2012 SP1 CTP1/2 – or Set-NetIPAddress ).

Add the DHCP role: 

Add-WindowsFeature DHCP

Create a scope: 

Add-DhcpServerv4Scope –StartRange 192.168.1.5 –EndRange 192.168.1.254 –SubnetMask 255.255.255.0 –Name “192.168.1.x” –State Active

Believe it or not.  That is it.  Just create a VM and test it.

Mind you, this is just a DHCP server, I did not do any Active Directory integration or extra DHCP custom scope configuration.  I figure that will come in due time.

Okay, lets do a couple settings, especially for Provisioning Server fans.

Set-DhcpServerv4OptionDefinition –OptionId 66 –DefaultValue 192.168.1.2

Set-DhcpServerv4OptionDefinition –OptionId 67 –DefaultValue ARDBP32.BIN

Lets suppose you want to change the IP range.  First you must know the ScopeId, as that is required by the Set-

Get-DhcpServerv4Scope

Set-DhcpServerv4Scope –ScopeId <> –StartRange 192.168.1.100 –EndRange 192.168.1.254

If you want the DHCP server to respond to both DHCP and BOOTP then you can change that option as well:

Set-DhcpServerv4Scope –ScopeId <> –Type Both

1 comment:

BrianEh said...

I love it when cmdlet behavior changes.

So, I am working with this again and noticed that my Options were not setting with the above cmdlet. No error message, just no change was being made.

So I changed how I do this:
$scope = Add-DhcpServerv4Scope –StartRange 192.168.104.5 –EndRange 192.168.104.254 –SubnetMask 255.255.255.0 –Name “192.168.1.x” –State Active -Type Dhcp -PassThru

Set-DhcpServerv4OptionValue –OptionId 66 –Value $pxeNetIpAddress.IPAddress -ScopeId $scope.ScopeId
Set-DhcpServerv4OptionValue –OptionId 67 –Value ARDBP32.BIN -ScopeId $scope.ScopeId