Sunday, March 29, 2015

Windows Server 2008 R2 DHCP Core – Step by Step Installation

In Windows Server 2008, we can setup the DHCP Server role and configure DHCP parameters including Scope, IP Range etc and the startup type all from command line.
This is especially useful, if you are using Windows Server Core installation.
The following step by step procedure should help you complete the task :
Install DHCP Server role
The following command from the command prompt should add the DHCP Server Role.
start /w ocsetup DHCPServer
In Windows Server 2008 Core, the Role name is “DHCPServerCore”. So, in Windows Server 2008 Core installation, it is
start /w ocsetup DHCPServerCore

Set DHCP Service to be Automatic
By default, after the role is enabled, the Service is still disabled. Hence Set the type to Auto as follows
sc \\%computername% config dhcpserver start= auto

Start the DHCP Server
net start dhcpserver

Add DHCP Server and Authorize in AD
If the DHCP server is installed in an Active Directory domain, you must authorize it in Active Directory. Now, let’s use the netsh commands to setup the server and configure the relevant parameters.
netsh dhcp add server %computername% 192.168.0.5
Adding server dc1, 192.168.0.5
Command completed successfully.
Where DC1, is the DHCP Server and the IP Address follows it

Add DHCP Scope
netsh dhcp server 192.168.0.5 add scope 192.168.10.0 255.255.255.0 Scope1 Scopevlan10
Command completed successfully.
In the above the DHCP scope – 192.168.10.0 255.255.255.0
Scope1 – Scope Name
ScopeVlan10 – Comment for the scope
Syntax is
netsh dhcp server 192.168.0.5 add scope

Set Scope IP Range
netsh dhcp server 192.168.0.5 scope 192.168.10.0 add ipra nge 192.168.10.1 192.168.10.254
Changed the current scope context to 192.168.10.0 scope.
Command completed successfully.
Here the IP range is 192.68.10.1-192.168.10.254 for the scope 192.168.10.0
Syntax is
netsh dhcp server scope 192.168.10.0 add iprange
Add Exclusion Range
Add any IP Exclusion ranges if any.
netsh dhcp server 192.168.0.5 scope 192.168.10.0 add excluderange 192.168.10.1 192.168.10.25
Changed the current scope context to 192.168.10.0 scope.
Command completed successfully.
Here the exclusion list has the range between 192.168.10.1 to 192.168.10.25
Syntax is
netsh dhcp server scope add excluderange

Set Option Code 003 for Default Routers
Set the option Code 003 and specify the Gateways
netsh dhcp server 192.168.0.5 scope 192.168.10.0 set optionvalue 003 IPADDRESS 10.1.1.1 10.1.1.2
Changed the current scope context to 192.168.10.0 scope.
Command completed successfully.
Here the gateways are 10.1.1.1 & 10.1.1.2
Syntax is
netsh dhcp server scope 192.168.10.0 set optionvalue 003 IPADDRESS

Set Option Code 006 for Default DNS Servers
netsh dhcp server 192.168.0.5 scope 192.168.10.0 set optionvalue 006 IPADDRESS 192.168.0.5 192.168.10.1
Changed the current scope context to 192.168.10.0 scope.
Command completed successfully.
Here the DNS Servers are 192.168.0.5 & 192.168.10.1
Syntax is
netsh dhcp server scope 192.168.10.0 set optionvalue 006 IPADDRESS

Activate DHCP Server Scope
Now, the relevant DHCP settings are complete. Lets activate the Scope
netsh dhcp server 192.168.0.5 scope 192.168.10.0 set state 1
Changed the current scope context to 192.168.10.0 scope.
Command completed successfully.
This should help you up and running with DHCP in less than 5 minutes. You can always modify from command line or by using DHCP MMC later on!!

No comments:

Post a Comment