Most organizations are already going to have DHCP deployed on their servers. If you have a new server on which you want to deploy DHCP, just run the PowerShell command:
Install-WindowsFeature DHCP -IncludeManagementTools
Once you’ve installed a DHCP server on a computer running Windows Server, you need to authorize that server in Active Directory. If you don’t do this, then the DHCP server won’t be able to lease addresses to clients. You’ll need to run the command with an account that has Enterprise Admin privileges in the forest, or is a Domain Admin account in the forest root domain.
You can do this by running the PowerShell command (where you substitute in the appropriate FQDN and IP address of the DHCP server that you want to authorize). Note that you don’t need to run this on the DHCP server, you can have someone else with the appropriate privileges run it on a DC.
Add-DhcpServerInDC -DNSName dhcp-srv.contoso.internal -IPAddress 172.16.0.50
You can view a list of DHCP server that are authorized in AD by running the following command:
Now that the DHCP server is authorized, you’ll need to add a scope. You can do this with the Add-DhcpServerV4Scope cmdlet. For example, to create a scope named Subnet-Alpha that includes the range 172.16.0.100 through 172.16.0.200 with a /24 subnet mask, run the command:
Add-DhcpServerV4Scope -name “Subnet-Alpha” -StartRange 172.16.0.100 -Endrange 172.16.0.200 -SubnetMask 255.255.255.0 -State Active
You can check which scopes are present on a server using the Get-DHCPServerV4Scope cmdlet.
You’ll need to add both a default gateway and a DNS server address to that scope, which you can do with the Set-DhcpServerv4OptionValue cmdlet. For example, to set the DNS server to 172.16.0.10 and the default gateway to 172.16.0.1 for the Subnet-Alpha scope, which has the scope ID 172.16.0.100 (or the first address in the range for the scope) run the command:
Set-DhcpServerV4OptionValue -ComputerName dhcp-srv.contoso.internal -ScopeID 172.16.0.100 -DNSServer 172.16.0.10 -Router 172.16.0.1
You can then check that the options have been set correctly using the Get-DhcpServerV4OptionValue cmdlet with the ScopeID parameter.
You can view DHCP leases from a specific scope using the Get-DhcpServerv4Lease cmdlet with the ScopeID parameter.
You can use the Add-DhcpServerv4Reservation cmdlet to convert a lease to a reservation. To do this, you need the MAC address, which is represented by the client ID in the output of Get-DHCPServerV4Lease cmdlet. For example, to create a reservation for the computer with the MAC address 00-16-5d-56-9e-04 for the IP address 172.16.0.45 in the scope ID 172.16.0.0, run the command:
Add-DhcpServerv4Reservation -ScopeID 172.16.0.0 -IPaddress 172.16.0.45 -ClientID “00-15-5d-56-9e-04” -Description “Reservation for MEL-SVR2”
You can validate which reservations are present within a scope using the Get-DhcpServerV4Reservation cmdlet.
If you wish to locate several free IP addresses within a scope that are not being leased, you can use the Get-DhcpServerv4FreeIPAddress cmdlet with the NumAddress parameters. For example, to locate five IP addresses that aren’t being used in the 172.16.0.0 scope, run the command:
Get-DhcpServerv4FreeIPAddress -ScopeID 172.16.0.0 -NumAddress 5
You can learn more about the PowerShell cmdlets that you use to manage DHCP in the following docs.microsoft article.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.