Learn What IT Pros Need to Know About Windows 11 - August 26th at 1 PM ET! Learn What IT Pros Need to Know About Windows 11 - August 26th at 1 PM ET!
Windows Server

Install Windows Server DHCP, Configure Scopes, and Authorize in AD

servers-hero

In today’s Ask the Admin, I’ll show you how to set up a DHCP server in Windows Server using PowerShell.

If you’re working with Windows Server Core, or need to configure Windows Server DHCP using the Remote Server Administration Tools (RSAT) for Windows 10, learning how to install and configure DHCP using PowerShell will come in handy. Server Core doesn’t have a GUI, so there’s no Server Manager or DHCP management console. And RSAT for Windows 10 no longer includes a DHCP management snap-in.

 

Sponsored Content

Read the Best Personal and Business Tech without Ads

Staying updated on what is happening in the technology sector is important to your career and your personal life but ads can make reading news, distracting. With Thurrott Premium, you can enjoy the best coverage in tech without the annoying ads.

 

In the instructions that follow, I’ll show you how to install the DHCP server role in Windows Server using PowerShell. Once DHCP is installed, we’ll configure a scope, authorize the DHCP server in Active Directory (AD), and add some DHCP server options. The instructions are intended for a DHCP server that will issue IP addresses to domain-joined devices.

  • Log in to Windows Server with an account that has local administrator permissions and the right to authorize DHCP in AD.
  • Open a PowerShell prompt by clicking the blue PowerShell icon on the desktop taskbar.
  • In the PowerShell window, run the Install-WindowsFeature cmdlet as shown below to install the DHCP server role and management tools:

Install-WindowsFeature DHCP -IncludeManagementTools

Let’s add the DHCP Users and DHCP Administrators security groups to the local server using Add-DHCPServerSecurityGroup, replacing dhcpsrv1 with the name of your DHCP server.
Add-DHCPServerSecurityGroup -ComputerName dhcpsrv1

We need to point the DHCP server to a DNS server, which it will use to register and deregister client DNS records. In my lab, DNS is running on a domain controller (DC), dc1. Replace dc1 with the name of your DNS server.
Set-DHCPServerDnsCredential -ComputerName dc1

The next step is to define a scope, or pool, of IP addresses that the DHCP server will issue to clients. I’m going to keep it simple and use a range of 192.168.2.0/24. In the code below, I define the scope ID in a variable and then use the Add-DhcpServerv4Scope cmdlet to configure an IPv4 scope (192.168.2.20 – 192.168.2.254) on the server.
$scopeID = '192.168.2.0' 
Add-DhcpServerv4Scope -Name Internal -StartRange 192.168.2.20 -EndRange 192.168.2.254 -SubnetMask 255.255.255.0 -Description 'My DHCP' -State Active

I need to set some DHCP server options: DnsServer, DnsDomain and the Router (default gateway) address. DHCP will issue these options to clients, along with an IP address, to ensure that they can communicate successfully on the network. Don’t forget to replace the -DnsServer, -DnsDomain, and -Router parameter values to match those for your network and domain.
Set-DHCPServerv4OptionValue -ScopeID $scopeID -DnsServer 192.168.2.1 -DnsDomain ad.contoso.com -Router 192.168.2.1

And the final step is to authorize the DHCP in Active Directory. You’ll need to replace the value of -DnsName with the fully qualified domain name (FQDN) of a DC in your AD domain, and -IPAddress with the IP address of the same DC.

Add-DhcpServerInDC -DnsName dc1.ad.contoso.com -IPAddress 192.168.2.1

Once the DHCP server is authorized in AD, it should start successfully issuing IP addresses to clients.

Related Topics:

BECOME A PETRI MEMBER:

Don't have a login but want to join the conversation? Sign up for a Petri Account

Register
Comments (0)

Leave a Reply

IT consultant, Contributing Editor @PetriFeed, and trainer @Pluralsight. All about Microsoft, Office 365, Azure, and Windows Server.

Register for Advanced Microsoft 365 Day!

GET-IT: Advanced Microsoft 365 1-Day Virtual Conference - Live August 24th!

Join us on Tuesday, August 24th and hear from Microsoft MVPs and industry experts about how to take advantage of Microsoft 365 at a technical level and dive deep into the features and functionality that will make your environment more secure and compliant.

RSVP Now

Sponsored By