Skip to main content

Programming DHCP via NETSH


If you need to configure more than two subnets on a Windows 2008 R2 DHCP server (Or all versions later), doing via the GUI is a painful way to do it.

Here's a simple cut and paste script that you can run via netsh that will make the subnets much quicker.

Launch netsh from the command line, and paste this in:

Replace 10.1.0.50 with your DHCP server, and 10.2.0.224 with your Scope's Network (check the subnet mask and the IP range) 

Just repeat each section below for each subnet.  I find it easy to just use find and replace to make lots of these.

Dhcp Server \\10.1.0.50 add scope 10.2.0.224 255.255.255.224 "Name of the Subnet" "Description of Subnet"
Dhcp Server \\10.1.0.50 Scope 10.2.0.224 set state 1
Dhcp Server \\10.1.0.50 Scope 10.2.0.224 set delayoffer 0


# ===============================================================
# Start Add Ipranges to the Scope 10.2.0.224, Server 10.1.0.50
# ===============================================================

Dhcp Server \\10.1.0.50 Scope 10.2.0.224 Add iprange 10.2.0.226 10.2.0.254
Dhcp Server \\10.1.0.50 scope 10.2.0.224 set napstate Off
#================================================================
# End Add Ipranges to the Scope 10.2.0.224, Server 10.1.0.50
#================================================================
#================================================================
# Start Add OptionValues to the Scope : 10.2.0.224, Server : 10.1.0.50
#================================================================
Dhcp Server \\10.1.0.50 Scope 10.2.0.224 set optionvalue 51 DWORD "691200"
Dhcp Server \\10.1.0.50 Scope 10.2.0.224 set optionvalue 3 IPADDRESS "10.2.0.225"
#================================================================
# End Add OptionValues to the Scope : 10.2.0.224, Server : 10.1.0.50
#================================================================
#================================================================
# Start Add ReservedIp to the Scope : 10.2.0.224, Server : 10.1.0.50
#================================================================
Dhcp Server \\10.1.0.50 Scope 10.2.0.224 Add reservedip 10.2.0.235 001122334455 "Name of Reserved  "Description of Reserved" "DHCP"
Dhcp Server \\10.1.0.50 v4 Scope 10.2.0.224 Set NameProtection enable= 0
Dhcp Server \\10.1.0.50 Scope 10.2.0.224 Set DnsConfig 1 1 1 1
#================================================================
# End Add ReservedIp to the Scope : 10.2.0.224, Server : 10.1.0.50
#================================================================


Comments

Popular posts from this blog

Embed a Slideshow from Picasa Web / Google Plus

One of the great features of Picasa Web was that you could embed a Flash slideshow of your albums. Google would even give you the code to do it.  There was a button that said Embed and it would give you the code. Just cut and paste and you were done. With the migration to Google Plus Photos, this disappeared. Here's a work around. Use the following link to get back to the original PicasaWeb site. https://picasaweb.google.com/ lh/myphotos?noredirect=1 Hopefully the embed button makes a re-appearance, or Google leaves the old page up forever. *******UPDATE******* One of the commenters below posted this website. http://www.slidemypics.com/ It seems to work pretty good!

WPAD does not resolve in DNS

At work, we're doing a POC (proof of concept) with a web-proxy, specifically Ironport Websecurity Appliance. Like most all proxies, you have to get the traffic from the client to the proxy. It supports transparent traffic redirection, but we're looking at using WPAD instead. However, when I created the WPAD DNS entry, it didn't resolve. C:\>ping wpad Ping request could not find host wpad. Please check the name and try again. C:\>nslookup wpad <DNSServer1> Server: <DNSServer1>.domain.net Address: <IPofDNSServer1> *** <DNSServer1>.domain.net can't find wpad: Non-existent domain This of course, is a big problem. It took a little investigating, but I found the cause. Windows Server 2008 introduced a new feature, called "Global Query Block list", which prevents some arbitrary machine from registering the DNS name of WPAD. This is a good security feature, as it prevents someone from just joining your network, and setting himsel