Deploy DHCP Using Windows PowerShell | Microsoft Learn
This guide provides instructions on how to use Windows PowerShell to deploy an Internet Protocol (IP) version 4 Dynamic Host Configuration Protocol (DHCP) server that automatically assigns IP addresses and DHCP options to IPv4 DHCP clients that are connected to one or more subnets on your network.
Note
To download this document in Word format from TechNet Gallery, see Deploy DHCP Using Windows PowerShell in Windows Server 2016.
Using DHCP servers to assign IP addresses saves in administrative overhead because you do not need to manually configure the TCP/IP v4 settings for every network adapter in every computer on your network. With DHCP, TCP/IP v4 configuration is performed automatically when a computer or other DHCP client is connected to your network.
You can deploy your DHCP server in a workgroup as a standalone server, or as part of an Active Directory domain.
This guide contains the following sections.
-
DHCP Deployment Overview
-
Technology Overviews
-
Plan DHCP Deployment
-
Using This Guide in a Test Lab
-
Deploy DHCP
-
Verify Server Functionality
-
Windows PowerShell Commands for DHCP
-
List of Windows PowerShell Commands in this guide
DHCP Deployment Overview
The following illustration depicts the scenario that you can deploy by using this guide. The scenario includes one DHCP server in an Active Directory domain. The server is configured to provide IP addresses to DHCP clients on two different subnets. The subnets are separated by a router that has DHCP Forwarding enabled.

Technology Overviews
The following sections provide brief overviews of DHCP and TCP/IP.
DHCP overview
DHCP is an IP standard for simplifying the management of host IP configuration. The DHCP standard provides for the use of DHCP servers as a way to manage dynamic allocation of IP addresses and other related configuration details for DHCP-enabled clients on your network.
DHCP allows you to use a DHCP server to dynamically assign an IP address to a computer or other device, such as a printer, on your local network, rather than manually configuring every device with a static IP address.
Every computer on a TCP/IP network must have a unique IP address, because the IP address and its related subnet mask identify both the host computer and the subnet to which the computer is attached. By using DHCP, you can ensure that all computers that are configured as DHCP clients receive an IP address that is appropriate for their network location and subnet, and by using DHCP options, such as default gateway and DNS servers, you can automatically provide DHCP clients with the information that they need to function correctly on your network.
For TCP/IP-based networks, DHCP reduces the complexity and amount of administrative work involved in configuring computers.
TCP/IP overview
By default, all versions of Windows Server and Windows Client operating systems have TCP/IP settings for IP version 4 network connections configured to automatically obtain an IP address and other information, called DHCP options, from a DHCP server. Because of this, you do not need to configure TCP/IP settings manually unless the computer is a server computer or other device that requires a manually configured, static IP address.
For example, it is recommended that you manually configure the IP address of the DHCP server, and the IP addresses of DNS servers and domain controllers that are running Active Directory Domain Services (AD DS).
TCP/IP in Windows Server 2016 is the following:
-
Networking software based on industry-standard networking protocols.
-
A routable enterprise networking protocol that supports the connection of your Windows-based computer to both local area network (LAN) and wide area network (WAN) environments.
-
Core technologies and utilities for connecting your Windows-based computer with dissimilar systems for the purpose of sharing information.
-
A foundation for gaining access to global Internet services, such as Web and File Transfer Protocol (FTP) servers.
-
A robust, scalable, cross-platform, client/server framework.
TCP/IP provides basic TCP/IP utilities that enable Windows-based computers to connect and share information with other Microsoft and non-Microsoft systems, including:
-
Windows Server 2016
-
Windows 10
-
Windows Server 2012 R2
-
Windows 8.1
-
Windows Server 2012
-
Windows 8
-
Windows Server 2008 R2
-
Windows 7
-
Windows Server 2008
-
Windows Vista
-
Internet hosts
-
Apple Macintosh systems
-
IBM mainframes
-
UNIX and Linux systems
-
Open VMS systems
-
Network-ready printers
-
Tablets and cellular telephones with wired Ethernet or wireless 802.11 technology enabled
Plan DHCP Deployment
Following are key planning steps before installing the DHCP server role.
Planning DHCP servers and DHCP forwarding
Because DHCP messages are broadcast messages, they are not forwarded between subnets by routers. If you have multiple subnets and want to provide DHCP service for each subnet, you must do one of the following:
-
Install a DHCP server on each subnet
-
Configure routers to forward DHCP broadcast messages across subnets and configure multiple scopes on the DHCP server, one scope per subnet.
In most cases, configuring routers to forward DHCP broadcast messages is more cost effective than deploying a DHCP server on each physical segment of the network.
Planning IP address ranges
Each subnet must have its own unique IP address range. These ranges are represented on a DHCP server with scopes.
A scope is an administrative grouping of IP addresses for computers on a subnet that use the DHCP service. The administrator first creates a scope for each physical subnet and then uses the scope to define the parameters used by clients.
A scope has the following properties:
-
A range of IP addresses from which to include or exclude addresses used for DHCP service lease offerings.
-
A subnet mask, which determines the subnet prefix for a given IP address.
-
A scope name assigned when it is created.
-
Lease duration values, which are assigned to DHCP clients that receive dynamically allocated IP addresses.
-
Any DHCP scope options configured for assignment to DHCP clients, such as DNS server IP address and router/default gateway IP address.
-
Reservations are optionally used to ensure that a DHCP client always receives the same IP address.
Before deploying your servers, list your subnets and the IP address range you want to use for each subnet.
Planning subnet masks
Network IDs and host IDs within an IP address are distinguished by using a subnet mask. Each subnet mask is a 32-bit number that uses consecutive bit groups of all ones (1) to identify the network ID and all zeroes (0) to identify the host ID portions of an IP address.
For example, the subnet mask normally used with the IP address 131.107.16.200 is the following 32-bit binary number:
11111111 11111111 00000000 00000000
This subnet mask number is 16 one-bits followed by 16 zero-bits, indicating that the network ID and host ID sections of this IP address are both 16 bits in length. Normally, this subnet mask is displayed in dotted decimal notation as 255.255.0.0.
The following table displays subnet masks for the Internet address classes.
| Address class | Bits for subnet mask | Subnet mask |
| --- | --- | --- |
| Class A | 11111111 00000000 00000000 00000000 | 255.0.0.0 |
| Class B | 11111111 11111111 00000000 00000000 | 255.255.0.0 |
| Class C | 11111111 11111111 11111111 00000000 | 255.255.255.0 |
When you create a scope in DHCP and you enter the IP address range for the scope, DHCP provides these default subnet mask values. Typically, default subnet mask values are acceptable for most networks with no special requirements and where each IP network segment corresponds to a single physical network.
In some cases, you can use customized subnet masks to implement IP subnetting. With IP subnetting, you can subdivide the default host ID portion of an IP address to specify subnets, which are subdivisions of the original class-based network ID.
By customizing the subnet mask length, you can reduce the number of bits that are used for the actual host ID.
To prevent addressing and routing problems, you should make sure that all TCP/IP computers on a network segment use the same subnet mask and that each computer or device has an unique IP address.
Planning exclusion ranges
When you create a scope on a DHCP server, you specify an IP address range that includes all of the IP addresses that the DHCP server is allowed to lease to DHCP clients, such as computers and other devices. If you then go and manually configure some servers and other devices with static IP addresses from the same IP address range that the DHCP server is using, you can accidentally create an IP address conflict, where you and the DHCP server have both assigned the same IP address to different devices.
To solve this problem, you can create an exclusion range for the DHCP scope. An exclusion range is a contiguous range of IP addresses within the scope's IP address range that the DHCP server is not allowed to use. If you create an exclusion range, the DHCP server does not assign the addresses in that range, allowing you to manually assign these addresses without creating an IP address conflict.
You can exclude IP addresses from distribution by the DHCP server by creating an exclusion range for each scope. You should use exclusions for all devices that are configured with a static IP address. The excluded addresses should include all IP addresses that you assigned manually to other servers, non-DHCP clients, diskless workstations, or Routing and Remote Access and PPP clients.
It is recommended that you configure your exclusion range with extra addresses to accommodate future network growth. The following table provides an example exclusion range for a scope with an IP address range of 10.0.0.1 - 10.0.0.254 and a subnet mask of 255.255.255.0.
| Configuration items | Example values |
| --- | --- |
| Exclusion range Start IP Address | 10.0.0.1 |
| Exclusion range End IP Address | 10.0.0.25 |
Planning TCP/IP static configuration
Certain devices, such as routers, DHCP servers, and DNS servers, must be configured with a static IP address. In addition, you might have additional devices, such as printers, that you want to ensure always have the same IP address. List the devices that you want to configure statically for each subnet, and then plan the exclusion range you want to use on the DHCP server to ensure that the DHCP server does not lease the IP address of a statically configured device. An exclusion range is a limited sequence of IP addresses within a scope, excluded from DHCP service offerings. Exclusion ranges assure that any addresses in these ranges are not offered by the server to DHCP clients on your network.
For example, if the IP address range for a subnet is 192.168.0.1 through 192.168.0.254 and you have ten devices that you want to configure with a static IP address, you can create an exclusion range for the 192.168.0.x scope that includes ten or more IP addresses: 192.168.0.1 through 192.168.0.15.
In this example, you use ten of the excluded IP addresses to configure servers and other devices with static IP addresses and five additional IP addresses are left available for static configuration of new devices that you might want to add in the future. With this exclusion range, the DHCP server is left with an address pool of 192.168.0.16 through 192.168.0.254.
Additional example configuration items for AD DS and DNS are provided in the following table.
| Configuration items | Example values |
| --- | --- |
| Network Connect Bindings | Ethernet |
| DNS Server Settings | DC1.corp.contoso.com |
| Preferred DNS server IP address | 10.0.0.2 |
| Scope values<br>1. Scope Name2. Starting IP Address3. Ending IP Address4. Subnet Mask5. Default Gateway (optional)6. Lease duration | 1. Primary Subnet2. 10.0.0.13. 10.0.0.2544. 255.255.255.05. 10.0.0.16. 8 days |
| IPv6 DHCP Server Operation Mode | Not enabled |
Using This Guide in a Test Lab
You can use this guide to deploy DHCP in a test lab before you deploy in a production environment.
Note
If you do not want to deploy DHCP in a test lab, you can skip to the section Deploy DHCP.
The requirements for your lab differ depending on whether you are using physical servers or virtual machines (VMs), and whether you are using an Active Directory domain or deploying a standalone DHCP server.
You can use the following information to determine the minimum resources you need to test DHCP deployment using this guide.
Test Lab requirements with VMs
To deploy DHCP in a test lab with VMs, you need the following resources.
For either domain deployment or standalone deployment, you need one server that is configured as a Hyper-V host.
Domain deployment
This deployment requires one physical server, one virtual switch, two virtual servers, and one virtual client:
On your physical server, in Hyper-V Manager, create the following items.
-
One Internal virtual switch. Do not create an External virtual switch, because if your Hyper-V host is on a subnet that includes a DHCP server, your test VMs will receive an IP address from your DHCP server. In addition, the test DHCP server that you deploy might assign IP addresses to other computers on the subnet where the Hyper-V host is installed.
-
One VM running Windows Server 2016 configured as a domain controller with Active Directory Domain Services that is connected to the Internal virtual switch you created. To match this guide, this server must have a statically configured IP address of 10.0.0.2. For information on deploying AD DS, see the section Deploying DC1 in the Windows Server 2016 Core Network Guide.
-
One VM running Windows Server 2016 that you will configure as a DHCP server by using this guide and that is connected to the Internal virtual switch you created.
-
One VM running a Windows client operating system that is connected to the Internal virtual switch you created and that you will use to verify that your DHCP server is dynamically allocating IP addresses and DHCP options to DHCP clients.
Standalone DHCP server deployment
This deployment requires one physical server, one virtual switch, one virtual server, and one virtual client:
On your physical server, in Hyper-V Manager, create the following items.
-
One Internal virtual switch. Do not create an External virtual switch, because if your Hyper-V host is on a subnet that includes a DHCP server, your test VMs will receive an IP address from your DHCP server. In addition, the test DHCP server that you deploy might assign IP addresses to other computers on the subnet where the Hyper-V host is installed.
-
One VM running Windows Server 2016 that you will configure as a DHCP server by using this guide and that is connected to the Internal virtual switch you created.
-
One VM running a Windows client operating system that is connected to the Internal virtual switch you created and that you will use to verify that your DHCP server is dynamically allocating IP addresses and DHCP options to DHCP clients.
Test Lab requirements with physical servers
To deploy DHCP in a test lab with physical servers, you need the following resources.
Domain deployment
This deployment requires one hub or switch, two physical servers and one physical client:
-
One Ethernet hub or switch to which you can connect the physical computers with Ethernet cables
-
One physical computer running Windows Server 2016 configured as a domain controller with Active Directory Domain Services. To match this guide, this server must have a statically configured IP address of 10.0.0.2. For information on deploying AD DS, see the section Deploying DC1 in the Windows Server 2016 Core Network Guide.
-
One physical computer running Windows Server 2016 that you will configure as a DHCP server by using this guide.
-
One physical computer running a Windows client operating system that you will use to verify that your DHCP server is dynamically allocating IP addresses and DHCP options to DHCP clients.
