We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Configure DHCP Server on Windows Server 2022

Learn how to – Configure DHCP Server on Windows Server 2022.

DHCP stands for Dynamic Host Configuration Protocol. A DHCP server is a network server that assigns IP addresses and other network configuration information dynamically to devices on a network. When a device connects to a network, it sends a request to the DHCP server for an IP address and other information such as subnet mask, default gateway, and DNS server addresses. The DHCP server then assigns an IP address to the device from a pool of available addresses and configures the other network settings.

This is such an important tool because it makes network administration and management. Without it, network administrators would need to manually assign IP addresses to each device on the network, which would be time-consuming and susceptible to errors.

DHCP also allows for the efficient use of IP addresses, as it can assign temporary addresses to devices that are only connected to the network temporarily, such as visitors’ devices. It can also provide other network configuration information such as DNS server addresses, time servers, and network boot servers. DHCP servers can also allocate reserved IP addresses to specific devices, ensuring that they always receive the same IP address whenever they connect to the network

How does a DHCP server work?

Before we plunge into the crux of this matter, it is important to understand how the DHCP server works.

When a device is connecting to a network, it sends a broadcast message requesting network configuration information. The DHCP server on the network receives this broadcast and responds with a message offering to assign an IP address and other network configuration information to the device. If the device accepts the offer, it sends a request to the DHCP server, and the server assigns the IP address and other configuration information to the device.

The DHCP server will assign an IP address available from the network pool that it has been configured to manage. It can also reserve certain IP addresses for specific devices based on their Media Access Control (MAC) addresses.

The below diagram will help you understand how a DHCP server works.

This guide will demonstrate how to install and configure a DHCP Server on Windows Server 2022.

1. Install DHCP Server on Windows Server 2022

There are two ways one can follow when installing a DHCP Server on Windows Server 2022. These are:

  • Using GUI
  • Using PowerShell

Follow any of the below methods to install a DHCP Server on Windows Server 2022.

Method 1: Install DHCP Server on Windows Server 2022 Using GUI

To install the DHCP server from the GUI, launch the server manager and click Add Roles and Features

On this page, select the Role-based or feature-based installation option.

Select the destination server you want to install.

On the roles tab, select DHCP Server

Allow installation of any additional features to the DHCP server and install it.

Method 2: Install DHCP Server on Windows Server 2022 Using PowerShell

It is also possible to install a DHCP server on Windows Server 2022 Using PowerShell. All you need is to run PowerShell with an elevated privilege and execute the below command:

Install-WindowsFeature DHCP -IncludeManagementTools

Sample Output:

2. Configure DHCP Server on Windows Server 2022

Also when configuring the DHCP server on Windows Server 2022, you can use both the GUI and PowerShell. This step also covered both methods, select one that best works for you.

Method 1: Configure DHCP Server on Windows Server 2022 using GUI

Once the DHCP server has been installed, you can modify it from the server manager. Select DHCP and select more on the notification that appears.

Click on Complete DHCP configuration on the upper right.

Proceed to the configuration tab.

On this tab, if your server is a stand-alone, you will Skip AD authorization and just commit the changes.

But if the server is joined to AD Domain, the current user is automatically set for authorization. You can set another user for authorization and then commit the changes.

Now after successfully configuring the authorization, click the close button. Now get back to the server manager and click on Tools->DHCP

Right-click on IPv4 ad select New Scope

Proceed to the configuration.

Provide the name and description of the new scope to be created:

Provide the IP address range and subnet for the new scope.

You can provide IP addresses you wish to preserve/exclude from leasing. If you don’t need to preserve, leave this empty.

Provide the lease duration.

Proceed and configure the DHCP options.

Provide the gateway for the network.

Provide the domain name and DNS server for the network. If the server is on AD, this will be set automatically, just double-check to ensure it is okay before you proceed.

Make the WINS Server configs, if uninterested, you can also leave this empty and proceed.

Activate the created scope.

Finish the creation.

Method 2: Configure DHCP Server on Windows Server 2022 using PowerShell

All the above configurations to the DHCP server can also be made from the PowerShell. Launch PowerShell with elevated privileges and follow the below steps:

Start by creating a security group on your system:

Add-DhcpServerSecurityGroup -ComputerName "server_name_here" 
netsh dhcp add securitygroups

If the Server is in the AD domain, run the below command below for authorization. Provide the server name and IP address.

Add-DhcpServerInDC -DnsName "server_name_here" -IPAddress 192.168.205.20 -PassThru

Now we will create a scope and provide the IPV4 configuration. This includes the IP range, subnet and lease period. For example:

Add-DhcpServerv4Scope -Name "Home Network" `
-StartRange 192.168.205.30 `
-EndRange 192.168.205.254 `
-SubnetMask 255.255.255.0 `
-LeaseDuration 8.00:00:00 `
-State Active `
-PassThru 

Finally, set the domain name, DNS server and gateway for the scope:

Set-DhcpServerv4OptionValue -DnsDomain "learnhowto.org" `
-DnsServer "192.168.205.20" `
-Router "192.168.205.1" `
-ScopeId "192.168.205.0" `
-PassThru 

Sample Output:

Restart the scope for the changes to apply:

Restart-Service DHCPServer 

3. Configure DHCP Client

We want to test if the DHCP Server on Windows Server 2022 is working as desired. You can configure a Windows, Linux, OS-X clients to connect to it.

For this guide, I will demonstrate with a Windows and Linux client.

1. On Windows

On Windows, navigate to Network settings, under IP assignment, set to Automatic (DHCP) as shown.

Once saved, the client should obtain an IP in the address range as well as a DNS server as configured on your DHCP server.

You can also do that in PowerShell. First, get the network interface index(ifIndex number) with the command:

Get-NetIPInterface -AddressFamily IPv4

Then enable DHCP on the interface with the commands:

Set-NetIPInterface -InterfaceIndex 4 -Dhcp Enabled 

Remember to replace 4 with your correct interface number.

Then apply the changes:

ipconfig /all 

Once the changes have been saved, you will have the IP assignment output.

2. On Linux

Still on Linux, you can set DHCP IP assignment from both the GUI and from the terminal.

Using the terminal, launch the network manager:

 nmtui

While here, edit the connection.

Select interface you want to use for the connection.

Now switch to automatic IP and DNS:

Save the changes then deactivate and activate the interface for the changes to apply:

From the GUI, you navigate to Network Settings set automatic IP and DNS as show below:

Once saved, the changes will appear as shown.

Also on the DNS server, the added devices will appear under Address leases.

Voila!

Verdict

At this point, you should be able to install and configure a DHCP Server on Windows Server 2022 through the PowerShell and the GUI. I hope this guide was of importance to you.

See more on this page:

Cart

Your Cart is Empty

Back To Shop