# DHCP

{% hint style="info" %}
<https://learn.microsoft.com/en-us/training/modules/deploy-manage-dynamic-host-configuration-protocol/>
{% endhint %}

DHCP stands for Dynamic Host Configuration Protocol. It is a network protocol used to automatically assign and manage IP addresses and other network configuration information to devices on a TCP/IP network. DHCP eliminates the need for administrators to manually assign static IP addresses to each device on a network.

Here's a brief overview of how DHCP works:

1. **Discover (D):** The client (device seeking an IP address) sends a DHCP Discover message to discover available DHCP servers on the network.
2. **Offer (O):** DHCP servers respond to the Discover message with a DHCP Offer, providing an IP address and other configuration details that the client can use.
3. **Request (R):** The client selects one of the offered IP addresses and sends a DHCP Request message to request the allocation of the chosen address from the DHCP server.
4. **Acknowledge (A):** The DHCP server acknowledges the client's request with a DHCP Acknowledge message, finalizing the allocation of the IP address and providing additional network configuration information.

The DORA process represents the sequence of interactions between the DHCP client and server as the client seeks and obtains an IP address dynamically from the DHCP server on the network.

<figure><img src="/files/jEVYVpwAekzcpVoGwUNf" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
In this scenario, we are going to install DHCP on the server and then specify a scope in the range of 192.168.10.0/24. Then, we'll check the client and verify the configuration.
{% endhint %}

Things to check before you start:

* Assign a static IP address to the server.
* You must have administrative privilege to install a DHCP server role.

Let’s get started.

**Step1**: Install the DHCP Server Role in Windows Server

{% hint style="info" %}
We should have sufficient permission to install the DHCP server role and to authorize the DHCP server.
{% endhint %}

1\. Open Server Manager console to view the Server Manager Dashboard. &#x20;

<div data-full-width="false"><figure><img src="/files/C6rF9TR8w2mURAxQixVh" alt=""><figcaption></figcaption></figure></div>

2. On the Server Manager dashboard, Click on Manage and select Add Roles and Features.

<div data-full-width="true"><figure><img src="/files/m0QuXYLRGlnZjPiXpxJL" alt=""><figcaption></figcaption></figure></div>

3. On the Before you begin window, click on “Next” at the lower right corner, this brings you to the next part of the process.
4. On the Select installation type window, select Role-based or feature based installation then click Next.

<figure><img src="/files/Sa31IL6VzGASSEZLFpfb" alt=""><figcaption></figcaption></figure>

5. On the Select server roles console, select the DHCP Server role for installation.

<figure><img src="/files/4tabm3TYimRQv4ugJyR4" alt=""><figcaption></figcaption></figure>

6. As soon as you choose DHCP Server role, the new window will show you the features that will be added for the DHCP Server role. Click Add Features then click Next.

<figure><img src="/files/PtvzPO7WqWEAROlcRCAG" alt=""><figcaption></figcaption></figure>

7. On the select features console, just click next because we do not require any extra features at the moment.

<figure><img src="/files/GH6CPnC0jE8OGNeY5t0t" alt=""><figcaption></figcaption></figure>

8. The next window shows you a brief description about the DHCP Service being added to the server as well as recommendations. You can click Next to continue.

<figure><img src="/files/zHHrVCi3n1KtI96pP3fY" alt=""><figcaption></figcaption></figure>

9. On the Confirm installation selections window, click Install to start the installation process. This may take a few minutes.

<figure><img src="/files/4WkQjqs1uNnkZbusg8qe" alt=""><figcaption></figcaption></figure>

10. Once the installation is done, click on the “Complete DHCP configuration” link to start the DHCP post-install wizard.

<figure><img src="/files/nIn3mRxnk2P4JEiXQsXR" alt=""><figcaption></figcaption></figure>

In case, if you close the console still you can start the “DHCP post-install wizard” by clicking on the yellow exclamation mark on the flag in server manager dashboard.

<figure><img src="/files/zn1ApPUVVWQWAuMTRxXU" alt=""><figcaption></figcaption></figure>

**Step2: DHCP Post Install Configuration**

1. The description window will show you what the DHCP post-install configuration will do next.

This will create two security groups for DHCP administration:

1. DHCP Administrators
2. DHCP Users

If the server where you are installing DHCP server role is a domain controller or member server, then this wizard is also going to register DHCP service in Active Directory as well. That is known as a DHCP authorization in Active Directory.

Click on Next to continue.

<figure><img src="/files/8GRo2xVvEaSpeddcyv53" alt=""><figcaption></figcaption></figure>

2\. On the Authorization window, we will need to specify the user credential to register the DHCP service in Active Directory. We will be using the domain administrator account which has the right privilege to join our domain, for this case it will be “HARCHIT\Administrator”.

Click Commit to proceed.

<figure><img src="/files/GjyK9ONAd52pTBQATbKO" alt=""><figcaption></figcaption></figure>

3. Once the security group creation and DHCP authorization completes, you can click close to continue.

<figure><img src="/files/iZHxWGdpFhHtA7UHexQg" alt=""><figcaption></figcaption></figure>

That’s it, we have successfully completed the installation of DHCP server role on machine.

### What is DHCP Scope?

A scope is a range of IP addresses on a particular subnet that a DHCP server has selected for allocation to clients when they make a DHCP request.

You can use the DHCP management console or PowerShell to create DHCP scope. In this tutorial we will create an IPv4 DHCP scope using the DHCP management console.&#x20;

### Create IPv4 DHCP Scope:

1\. On the Server Manager console, Click on Tools and select DHCP to open the DHCP management tool.

<figure><img src="/files/R7PSudlpYHvoLmEBtl82" alt=""><figcaption></figcaption></figure>

2. On the DHCP console, expand your **server name**. In my case it is winserver.harchit.local.

<figure><img src="/files/nrWKeW8LzOCvJzEF0iZp" alt=""><figcaption></figcaption></figure>

3\. Select **IPv4**. On the right pane you will see an overview about DHCP scope and how to create a scope.

<figure><img src="/files/6BSHl2VHCs17gNNa9dGO" alt=""><figcaption></figcaption></figure>

4\. Right click on **IPv4** and select the “**New Scope**” option.

<figure><img src="/files/CrSAoCe7CegM5VJvLj4U" alt=""><figcaption></figcaption></figure>

5. The New Scope wizard starts. Click Next.

<figure><img src="/files/Hv7hnBJKJ5uKefJhPCCv" alt=""><figcaption></figcaption></figure>

6. On the Scope Name screen, type any name of your choice for the scope name, this will help you identify the DHCP Scope once it’s created. Adding a description is optional but it can help identify the scope better in the future by adding any relevant information in the field.

<figure><img src="/files/VZCvmoUamQdDeRFGMNkx" alt=""><figcaption></figcaption></figure>

7. On the IP Address Range screen, provide an IP address range (Start IP address and End IP address). For this demo I am using **192.168.10.20** to **192.168.10.30** with subnet mask **255.255.255.0**. Once you are done with all, click **next** to proceed.

   &#x20;

   Note: The defined Start and End IP Addresses will be the IP Addresses that will be Offered to our hosts requesting an IP Address. For this case, any Requesting hosts will be given an IP address between 192.168.10.20 - 192.168.10.30 with a subnet of /24 or 255.255.255.0.

<figure><img src="/files/Ww3NO3VAGUmHu1v9yGYf" alt=""><figcaption></figcaption></figure>

8. On the Add Exclusions and Delay screen, leave it empty. Click on Next.

<figure><img src="/files/b3Zres4almxB29v1vP0y" alt=""><figcaption></figcaption></figure>

9. On the Lease Duration screen, the default lease time for an assigned IP Address will be 8 days (as shown below). I will change the default lease duration and set the new lease duration to 8 hours. You can adjust it as per your requirement. Click Next to continue.

<figure><img src="/files/1nBtBkIBcsAJnrWg1cmI" alt=""><figcaption></figcaption></figure>

10. On **Configure DHCP Option**, we can configure additional DHCP options such as our routers’ IP Address or the Default Gateway, DNS server address and WINS settings for the scope we are creating.

    &#x20;

    Select **“Yes, I want to configure these options now”** and click **Next** to continue.

<figure><img src="/files/8vbKcp3Y0zOo9h35Fm6Z" alt=""><figcaption></figcaption></figure>

11. On the Router (Default Gateway) page, add your **gateway's IP address** 192.168.10.1 then click on Add then click **Next.**

<figure><img src="/files/wjhMP0gQrRlIy7l3vjy8" alt=""><figcaption><p> We used 192.168.10.1 as our Gateway’s IP Address since we will be installing the Routing service later on in the lab.</p></figcaption></figure>

12. We have install the DHCP server role on our Domain Controller, so the wizard will automatically detect the DNS server’s address. If you wish to add another DNS server address you can but for this demo will use our local DNS address only. Click **Next.**

<figure><img src="/files/0lh3jJkoiDOo0c7K47KH" alt=""><figcaption></figcaption></figure>

13. If you have any WINS server in your network, you can specify the address here. Since we don’t have any WINS server we can simply leave it blank and click Next.

<figure><img src="/files/WpLaH3GaVCoWOKIZNXLm" alt=""><figcaption></figcaption></figure>

14. On the Activate Scope window, select “Yes, I want to activate this scope now” then click Next.

<figure><img src="/files/7V5QhP7sUJhCO8Ob14p1" alt=""><figcaption><p>Note: Your DHCP server will not be able offer an IP address to a client’s DHCP request if the DHCP scope is inactive.</p></figcaption></figure>

15. On the next screen, click Finish to create a DHCP scope and close the wizard.

<figure><img src="/files/qAxrZLx9rPsP2gIO8teW" alt=""><figcaption></figcaption></figure>

16. On the DHCP Console, Now you can see your newly created scope ready to distribute IP addresses to client computers.

<figure><img src="/files/crZ1GgLf3sz9I8gEDt71" alt=""><figcaption></figcaption></figure>

### Test DHCP server functionality:

To verify the DHCP server is working properly, we will be using a client PC which is connected to the same network where our DHCP Server is.

1\. Go to Windows 10 client machine. Right click on **start button** and select **“Network Connections”.**

<figure><img src="/files/bAfOl2Uq3Ar3fGtBWxUc" alt=""><figcaption></figcaption></figure>

2. Under change your network settings, click on **change adapter settings** that will open Network connection console.

<figure><img src="/files/oDayACWVwUBgfiEStXND" alt=""><figcaption></figcaption></figure>

3. Select **Ethernet adapter**, Right click on it and select **Properties.**

<figure><img src="/files/RjC1FHrdenpoov5Zrl3F" alt=""><figcaption></figcaption></figure>

4. Select **TCP/IPv4** and click on **Properties.**

<figure><img src="/files/qKnKAaIC9HDOPJZpNsdq" alt=""><figcaption></figcaption></figure>

5. Make sure you choose **Obtain an IP address automatically,** same goes to **Obtain DNS server address automatically**. Click **OK** button.

<figure><img src="/files/6wyqf68ZR66JCMxDSLJn" alt=""><figcaption></figcaption></figure>

6. Click on **Close** to close “Ethernet Properties” console.

<figure><img src="/files/dENOijTYcpwbpv9mMFjG" alt=""><figcaption></figcaption></figure>

7. Right click on **Ethernet adapter** again and select **status**.

<figure><img src="/files/Ba6qG2M2Ox9lgzhPbukv" alt=""><figcaption></figcaption></figure>

8. Click on **details** option.

<figure><img src="/files/bFvEOSaegrkge6YNkfAv" alt=""><figcaption></figcaption></figure>

9. Here you can verify that our windows 10 client is getting IP address from DHCP Server that you just configured.

<figure><img src="/files/g0Sw6Hl3HQhPolLf8KJd" alt=""><figcaption></figcaption></figure>

10\. Even from the DHCP management console you can verify that clients are getting IP’s from the DHCP server.

<figure><img src="/files/t57bg8GOHVX1FFkGoe0x" alt=""><figcaption></figcaption></figure>

\
After this we can safely say that our DHCP server is configured and ready to allocate TCP/IP settings to the DHCP clients.

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://talebi.gitbook.io/windows-server/dhcp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
