Configuring DHCP server by PowerShell

Posted: January 10, 2017 in Windows Server

Install DHCP role:

Install-WindowsFeature DHCP -IncludeManagementTools

 

Create and activate DHCP scope which will lease addresses from 192.168.0.20-192.168.0.30

Add-DhcpServerv4Scope -name 'corpnet' -StartRange 192.168.0.20 -EndRange 192.168.0.30 -SubnetMask 255.255.255.0 -State Active

 

Create DHCP exclusion for range 192.168.0.1-192.168.20

Add-DhcpServerv4ExclusionRange -ScopeId 192.168.0.0 -StartRange 192.168.0.1 -EndRange 192.168.0.20

 

Set Scope options (DNS server,domain name and Default Gateway

Set-DhcpServerv4OptionValue -DnsDomain test.com -DnsServer 192.168.0.5 -Router 192.168.0.1

 

Authorize DHCP server in AD (allow it to lease address)

Add-DhcpServerInDC -DnsName server-01.test.com

 

Create DHCP reservation

Add-DhcpServerv4Reservation -ComputerName client.test.com -ScopeId 192.168.0.0 -IPAddrs 192.168.0.21 -ClientId "F0-DE-F1-7A-00-5E" -Description "Reservation for test client"
Advertisements

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 )

Google+ photo

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

Connecting to %s