PowerShell

Configure DHCP-Server-Role with PowerShell

The Dynamic Host Control Protocol (DHCP) helps you manage your network by automatically assigning IP-Adresses to hosts. In this article I will show you how to configure a DHCP Server with a Windows Server operating system. Let’s dive in.

Install Server-Role

First, we need to install the DHCP Server-Role along with its management tools.

Install-WindowsFeature DHCP -IncludeManagementTools

Once complete, we can discover all DHCP PowerShell cmdlets by running Get-Command with the appropriate module.

Get-Command -Module DHCPServer

Define Scope and Scope Options

Now we are ready to create a scope with a start and end range.

Add-DhcpServerv4Scope -Name pagr `
-StartRange 192.168.99.200 `
-EndRange 192.168.99.250 `
-SubnetMask 255.255.255.0

Next, we define the DNS settings, DNS-Server and the Gateway for the newly created scope.

Set-DhcpServerv4OptionValue `
-DnsDomain pagr.inet `
-DnsServer 192.168.99.10 `
-Router 192.168.0.1

Authorization

Windows Server operating systems which want to act as a DHCP Server must be authorized by an enterprise adminstrator of the domain. Otherwise, the server will not start the DHCP service on the local computer.

Add-DhcpServerInDC

Reservation

You may want to add a reserveration for a particular host.

Add-DhcpServerv4Reservation `
-ScopeId 192.168.99.200 `
-IPAddress 192.168.99.250 `
-ClientId "F9-FF-F1-7B-01-6E" `
-Description "Beamer"

Hope this was helpful.

For more information, refer to the DHCP Server module.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.