Adding DHCP Scopes using command line in Windows Server 2008
Adding so many DHCP scopes to the server all at the same time, this will consume a lot of time, so it is good to know how to add, configure and activate DHCP scopes using command line in Windows Server 2008.
The following commands are used to add the scope 172.16.16.0 with the name of “HR Users” with the subnet mask 255.255.255.0.
The IP range for
netsh dhcp server \\DHCP-Server add scope 172.16.16.0 255.255.255.0 "HR Users"
netsh dhcp server \\DHCP-Server scope 172.16.16.0 add iprange 172.16.16.1 172.16.16.254
netsh dhcp server \\DHCP-Server scope 172.16.16.0 add excluderange 172.16.16.1 172.16.16.20
netsh dhcp server \\DHCP-Server scope 172.16.16.0 set optionvalue 003 ipaddress 172.16.16.1
netsh dhcp server \\DHCP-Server scope 172.16.16.0 set optionvalue 006 ipaddress 172.16.10.10 172.16.10.11
netsh dhcp server \\DHCP-Server scope 172.16.16.0 set state 1
Commands’ description:
netsh dhcp server \\<Server> add scope <Subnet> <Subnet mask> <ScopeName>
netsh dhcp server \\<Server> scope 172.16.16.0 add iprange <StartIP> <EndIP>
netsh dhcp server \\<Server> scope 172.16.16.0 add excluderange <StartExclusion> <End-Exclusion>
netsh dhcp server \\<Server> scope 172.16.16.0 set optionvalue 003 IPADDRESS <Gateway1>
netsh dhcp server \\<Server> scope 172.16.16.0 set optionvalue 006 IPADDRESS <Primary DNS> <Secondary DNS>
netsh dhcp server \\<Server> scope 172.16.16.0 set state 1