Since Dynamic Host Configuration Protocol (DHCP) Plays a key role to give clients IP, we need to configure that as Perfectly as we can but before installing and Configuring DHCP Server Role we have to learn How it Works?
DHCP is a network Protocol which is used in Internet Protocol. The server that supports the protocol is called DHCP server. As its name indicates, DHCP server dynamically distributes IP for network interfaces and devices. When somebody sends a request for IP, DHCP server distributes IP address based on the DHCP server configurations. DHCP is a role in Windows Server 2016. The things which we are going to discuss:
- Install DHCP Role with PowerShell.
- Set a Static IP address.
- Create Scope with PowerShell
How Install Configure DHCP Server windows Server 2016
Install DHCP Role with PowerShell
Step 1. Open PowerShell.
Step 2. Type Get-Windowsfeature Command to show a list of the Features available in the Server.
Step 3. Since we are installing DHCP, we need to find that. When you find that copy its name.
Step 4. To install it type Install-WindowsFeature -Name DHCP -Restart –IncludeManagementTools command. When the installation Completes it will look like this.
Note: You can see a Yellow bar on the screenshot. It says that no static IP addresses were found on this computer. So we need to configure a static IP address.
Set a Static IP Address
Step 1. To set a static IP address with PowerShell type Get-NetIPConfiguration cmdlet.
The Get-NetIPConfiguration cmdlet gets network configuration, including usable interfaces, IP addresses, and DNS servers.
Step 2. Now that you have those Information, type New-NetIPAddress -IPAddress <> InterfaceAlias <> cmdlet. This cmdlet creates and configures an IP address.
- Instead of <> after IP address type an IP like 184.108.40.206 which you want to be a static IP.
- Instead of <> after InterfaceAlias, type the Internet Port which you get from Get-NetIPconfiguration cmdlet.
Now that we have installed and configured the static IP Address let’s get into configuring the DHCP for creating Scopes.
Creating Scope with PowerShell
To create a scope, I am using the add-dhcpserverv4scope cmdlet, this cmdlet allows you to Add an IPv4 scope on the Dynamic Host Configuration Protocol (DHCP) server service. Here is the full command to create a new scope.
Add-DhcpServerv4Scope -Name ‘Quetta Lab’ -StartRange 220.127.116.11 -EndRange 18.104.22.168 -S
ubnetMask 255.255.255.0 -Description “This scope has been created for Quetta Users”
- Type Get-WindowsFeature cmdlet and copy the DHCP Name.
- Type this Install-WindowsFeature -Name DHCP -Restart –IncludeManagementTools cmdlet to install DHCP.
- Type Get-NetIPConfiguration cmdlet to get the network information.
- Type this command to renew the IP address New-NetIPAddress -IPAddress <> InterfaceAlias <>.
- and Finally, type Add-DhcpServerv4Scope -Name ‘Quetta Lab’ -StartRange 22.214.171.124 -EndRange 126.96.36.199 -SubnetMask 255.255.255.0 -Description “This scope has been created for Quetta Users” cmdlet to create the scope.
That’s all, I hope this article helped you Install and Configure DHCP with PowerShell on Server 2016. If you liked this article, then please subscribe to our YouTube Channel for WordPress, Windows Server, the Internet and Business video tutorials. You can also find us on Twitter and Facebook.