Another quick post to show how you can quickly deploy fully working DHCP server with multiple scopes in a matter of seconds. In my case it was a single server with 90 very different scopes and doing this manually would be just soo boring and long that’s unreal. Unfortunately Windows Server 2012 wasn’t an option so no PowerShell love but Windows Server 2008 R2 is still pretty decent and using netsh wasn’t as painful as it seemed. To get us started we need to install the DHCP Server role and start the required service (dhcpserver):
1 2 3 |
<strong>start /w ocsetup DHCPServer sc config dhcpserver start= auto net start dhcpserver</strong> |
Next step is to authorize DHCP server in the enterprise so we can actually use it to dish out IP addresses:
1 |
<strong>netsh dhcp add server %COMPUTERNAME% ip_address_goes_here</strong> |
Other useful commands here would include:
To deauthorize the server –
1 |
<strong>netsh dhcp delete server %COMPUTERNAME% ip_address_goes_here</strong> |
and to list all authorized servers –
1 |
<strong>netsh dhcp show server</strong> |
This part should conclude basic setup of DHCP server, time to move on to scopes and other settings.
To add scope named “My DHCP Scope” on 10.10.103.0/24 network you need to run the following (DHCP IP = 10.10.103.186):
1 |
<strong>netsh dhcp server 10.10.103.186 add scope 10.10.103.0 255.255.255.0 "My DHCP Scope"</strong> |
Adding IP range (.16 to .250 so you have 234 available addresses) for distribution can be accomplished by:
1 |
<strong>netsh dhcp server 10.10.103.184 scope 10.10.103.0 add iprange 10.10.103.5 10.10.103.250</strong> |
Adding defuault gateway and two DNS servers as well as DNS search domain:
1 2 3 |
<strong>netsh dhcp server 10.10.103.184 scope 10.10.103.0 set optionvalue 003 IPADDRESS 10.10.103.1 netsh dhcp server 10.10.103.184 scope 10.10.103.0 set optionvalue 006 IPADDRESS 10.10.103.10 10.10.103.11 netsh dhcp server 10.10.103.184 scope 10.10.103.0 set optionvalue 015 STRING contoso.com</strong> |
Specifying lease time (in seconds):
1 |
<strong>netsh dhcp server 10.73.103.184 scope 10.10.103.0 set optionvalue 51 DWORD 3600</strong> |
Activating the scope:
1 |
<strong>netsh dhcp server 10.73.103.184 scope 10.10.103.0 set state 1</strong> |
That should be it to cover the basics.
Useful link if you guys need to know more about netsh – Netsh commands for DHCP