Wednesday, July 23, 2014

Create DHCP Scopes From Command Line

Sorry everyone, I know it has been a while again. I recently started a new job again and it is back in the education field except it is now at the post-secondary level. Huge difference between the K-12 enviroment I was in before.

Anyway, I have been helping out on a subnetting project implementing a lot of VLANs (almost 50). I was given the task of creating the DHCP scopes for all of these new VLANs on the Windows 2012 R2 server. Sounds fun right? Not really when you think about going through the scope wizard 40+ times but I found a way to do it from the command line.

To get started you have to open up a command prompt and use the netsh command. 

Once you get to the netsh> prompt, type in the following:
dhcp server IP Address/ServerName add scope NetworkAddress SubnetMask  ScopeName ScopeDescription
 The NetworkAddress, SubnetMask, and ScopeName are required. *Side note: You need the quote marks " " if the ScopeName and ScopeDescription have spaces.

Here is an example of a complete command looks like:
dhcp server add scope "Wireless 200" "Wireless VLAN for 200 Building"
Now that the scope is created, we need to add a range of addresses for the server to hand out. That command looks like:
dhcp server IP Address/ServerName scope NetworkAddress add iprange RangeStart RangeEnd
Here is my example:
dhcp server scope add iprange 
Another command that I used was to add the gateway address. To set different options, you will need to know the option number; for my case, the Router option is number 003.

dhcp server scope set optionvalue 003 IPADDRESS

There are a lot of other things that you do like add/delete scopes, super-scopes, etc., just click on the resource link below.


No comments:

Post a Comment