Skip to content

Commit 508a6fa

Browse files
authored
Merge pull request #267651 from asudbring/dhcp-vnet
New article for deploying a DHCP server on an Azure virtual machine for on-premises DHCP clients
2 parents 164ac8c + a0fba89 commit 508a6fa

File tree

4 files changed

+347
-2
lines changed

4 files changed

+347
-2
lines changed
Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
---
2+
title: Deploy a DHCP server in Azure on a virtual machine
3+
titleSuffix: Azure Virtual Network
4+
description: Learn about how to deploy a Dynamic Host Configuration Protocol (DHCP) server in Azure on a virtual machine as a target for an on-premises DHCP relay agent.
5+
author: asudbring
6+
ms.author: allensu
7+
ms.service: virtual-network
8+
ms.topic: how-to
9+
ms.date: 02/28/2024
10+
11+
#customer intent: As a Network Administrator, I want to deploy a highly available DHCP server in Azure so that I can provide DHCP services to my on-premises network.
12+
13+
---
14+
15+
# Deploy a DHCP server in Azure on a virtual machine
16+
17+
Learn how to deploy a highly available DHCP server in Azure on a virtual machine. This server is used as a target for an on-premises DHCP relay agent to provide dynamic IP address allocation to on-premises clients. Broadcast packets directly from clients to a DHCP Server don't work in an Azure Virtual Network by design.
18+
19+
## Prerequisites
20+
21+
- An Azure account with an active subscription. [Create one for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
22+
23+
[!INCLUDE [virtual-network-create-with-bastion.md](../../includes/virtual-network-create-with-bastion.md)]
24+
25+
## Create internal load balancer
26+
27+
In this section, you create an internal load balancer that load balances virtual machines. An internal load balancer is used to load balance traffic inside a virtual network with a private IP address.
28+
29+
During the creation of the load balancer, you configure:
30+
31+
* Frontend IP address
32+
* Backend pool
33+
* Inbound load-balancing rules
34+
35+
1. In the search box at the top of the portal, enter **Load balancer**. Select **Load balancers** in the search results.
36+
37+
1. In the **Load balancer** page, select **Create**.
38+
39+
1. In the **Basics** tab of the **Create load balancer** page, enter, or select the following information:
40+
41+
| Setting | Value |
42+
| --- | --- |
43+
| **Project details** | |
44+
| Subscription | Select your subscription. |
45+
| Resource group | Select **test-rg**. |
46+
| **Instance details** | |
47+
| Name | Enter **load-balancer** |
48+
| Region | Select **(US) East US 2**. |
49+
| SKU | Leave the default **Standard**. |
50+
| Type | Select **Internal**. |
51+
| Tier | Leave the default **Regional**. |
52+
53+
1. Select **Next: Frontend IP configuration** at the bottom of the page.
54+
55+
1. In **Frontend IP configuration**, select **+ Add a frontend IP configuration**.
56+
57+
1. Enter **frontend-1** in **Name**.
58+
59+
1. Select **subnet-1 (10.0.0.0/24)** in **Subnet**.
60+
61+
1. In **Assignment**, select **Static**.
62+
63+
1. In **IP address**, enter **10.0.0.100**.
64+
65+
1. Select **Add**.
66+
67+
1. Select **Next: Backend pools** at the bottom of the page.
68+
69+
1. In the **Backend pools** tab, select **+ Add a backend pool**.
70+
71+
1. Enter **backend-pool** for **Name** in **Add backend pool**.
72+
73+
1. Select **NIC** or **IP Address** for **Backend Pool Configuration**.
74+
75+
1. Select **Save**.
76+
77+
1. Select the blue **Review + create** button at the bottom of the page.
78+
79+
1. Select **Create**.
80+
81+
## Configure second load balancer frontend
82+
83+
A second frontend is required for the load balancer to provide high availability for the DHCP server. Use the following steps to add a second frontend to the load balancer.
84+
85+
1. In the Azure portal, search for and select **Load balancers**.
86+
87+
1. Select **load-balancer**.
88+
89+
1. In **Settings**, select **Frontend IP configuration**.
90+
91+
1. Select **+ Add**.
92+
93+
1. Enter or select the following information in **Add frontend IP configuration**:
94+
95+
| Setting | Value |
96+
| --- | --- |
97+
| **Name** | Enter **frontend-2**. |
98+
| **Subnet** | Select **subnet-1 (10.0.0.0/24)**. |
99+
| **Assignment** | Select **Static**. |
100+
| **IP address** | Enter **10.0.0.200**. |
101+
| **Availability zone** | Select **Zone-redundant**. |
102+
103+
1. Select **Add**.
104+
105+
1. Verify that in **Frontend IP configuration**, you have **frontend-1** and **frontend-2**.
106+
107+
## Create load balancer rules
108+
109+
The load balancer rules are used to distribute traffic to the virtual machines. Use the following steps to create the load balancer rules.
110+
111+
1. In the Azure portal, search for and select **Load balancers**.
112+
113+
1. Select **load-balancer**.
114+
115+
1. In **Settings**, select **Load balancing rules**.
116+
117+
1. Select **+ Add**.
118+
119+
1. Enter or select the following information in **Add load balancing rule**:
120+
121+
| Setting | Value |
122+
| --- | --- |
123+
| **Name** | Enter **lb-rule-1**. |
124+
| **IP version** | Select **IPv4**. |
125+
| **Frontend IP address** | Select **frontend-1**. |
126+
| **Backend pool** | Select **backend-pool**. |
127+
| **Protocol** | Select **UDP**. |
128+
| **Port** | Enter **67**. |
129+
| **Backend port** | Enter **67**. |
130+
| **Health probe** | Select **Create new**. </br> Enter **dhcp-health-probe** for **Name**. </br> Select **TCP** for **Protocol**. </br> Enter **3389** for **Port**. </br> Enter **67** for **Interval**. </br> Enter **5** for **Unhealthy threshold**. </br> Select **Save**. |
131+
| **Enable Floating IP** | Select the box. |
132+
133+
1. Select **Save**.
134+
135+
1. Repeat the previous steps to create the second load balancing rule. Replace the following values with the values for the second frontend:
136+
137+
| Setting | Value |
138+
| --- | --- |
139+
| **Name** | Enter **lb-rule-2**. |
140+
| **Frontend IP address** | Select **frontend-2**. |
141+
| **Health probe** | Select **dhcp-health-probe**. |
142+
143+
[!INCLUDE [create-two-virtual-machines-windows-load-balancer.md](../../includes/create-two-virtual-machines-windows-load-balancer.md)]
144+
145+
## Configure DHCP server network adapters
146+
147+
You'll sign-in to the virtual machines with Azure Bastion and configure the network adapter settings and DHCP server role for each virtual machine.
148+
149+
1. In the Azure portal, search for and select **Virtual machines**.
150+
151+
1. Select **vm-1**.
152+
153+
1. In the **vm-1** page, select **Connect** then **Connect via Bastion**.
154+
155+
1. Enter the username and password you created when you created the virtual machine.
156+
157+
1. Open **PowerShell** as an administrator.
158+
159+
1. Run the following command to install the DHCP server role:
160+
161+
```powershell
162+
Install-WindowsFeature -Name DHCP -IncludeManagementTools
163+
```
164+
165+
### Install Microsoft Loopback Adapter
166+
167+
Use the following steps to install the Microsoft Loopback Adapter by using the Hardware Wizard:
168+
169+
1. Open **Device Manager** on the virtual machine.
170+
171+
1. Select the computer name **vm-1** in **Device Manager**.
172+
173+
1. In the menu bar, select **Action** then **Add legacy hardware**.
174+
175+
1. In the **Add Hardware Wizard**, select **Next**.
176+
177+
1. Select **Install the hardware that I manually select from a list (Advanced)**, and then select **Next**
178+
179+
1. In the **Common hardware types** list, select **Network adapters**, and then select **Next**.
180+
181+
1. In the **Manufacturers** list box, select **Microsoft**.
182+
183+
1. In the **Network Adapter** list box, select **Microsoft Loopback Adapter**, and then select **Next**.
184+
185+
1. select **Next** to start installing the drivers for your hardware.
186+
187+
1. select **Finish**.
188+
189+
1. In **Device Manager**, expand **Network adapters**. Verify that **Microsoft Loopback Adapter** is listed.
190+
191+
1. Close **Device Manager**.
192+
193+
### Set static IP address for Microsoft Loopback Adapter
194+
195+
Use the following steps to set a static IP address for the Microsoft Loopback Adapter:
196+
197+
1. Open **Network and Internet settings** on the virtual machine.
198+
199+
1. Select **Change adapter options**.
200+
201+
1. Right-click **Microsoft Loopback Adapter** and select **Properties**.
202+
203+
1. Select **Internet Protocol Version 4 (TCP/IPv4)** and select **Properties**.
204+
205+
1. Select **Use the following IP address**.
206+
207+
1. Enter the following information:
208+
209+
| Setting | Value |
210+
| --- | --- |
211+
| **IP address** | Enter **10.0.0.100**. |
212+
| **Subnet mask** | Enter **255.255.255.0**. |
213+
214+
1. Select **OK**.
215+
216+
1. Select **Close**.
217+
218+
### Enable routing between the loopback interface and the network adapter
219+
220+
Use the following steps to enable routing between the loopback interface and the network adapter:
221+
222+
1. Open **CMD** as an administrator.
223+
224+
1. Run the following command to list the network interfaces:
225+
226+
```cmd
227+
netsh int ipv4 show int
228+
```
229+
230+
```output
231+
C:\Users\azureuser>netsh int ipv4 show int
232+
233+
Idx Met MTU State Name
234+
--- ---------- ---------- ------------ ---------------------------
235+
1 75 4294967295 connected Loopback Pseudo-Interface 1
236+
6 5 1500 connected Ethernet
237+
11 25 1500 connected Ethernet 3
238+
```
239+
240+
In this example, the network interface connected to the Azure Virtual network is **Ethernet**. The loopback interface that you installed in the previous section is **Ethernet 3**.
241+
242+
**Make note of the `Idx` number for the primary network adapter and the loopback adapter. In this example the primary network adapter is `6` and the loopback adapter is `11`. You'll need these values for the next steps.**
243+
244+
> [!CAUTION]
245+
> Don't confuse the **Loopback Loopback Pseudo-Interface 1** with the **Microsoft Loopback Adapter**. The **Loopback Pseudo-Interface 1** isn't used in this scenario.
246+
247+
1. Run the following command to enable **weakhostreceive** and **weakhostsend** on the primary network adapter:
248+
249+
```cmd
250+
netsh int ipv4 set int 6 weakhostreceive=enabled weakhostsend=enabled
251+
```
252+
253+
1. Run the following command to enable **weakhostreceive** and **weakhostsend** on the loopback adapter:
254+
255+
```cmd
256+
netsh int ipv4 set int 11 weakhostreceive=enabled weakhostsend=enabled
257+
```
258+
259+
1. Close the bastion connection to **vm-1**.
260+
261+
1. Repeat the previous steps to configure **vm-2**. Replace the IP address of **10.0.0.100** with **10.0.0.200** in the static IP address configuration of the loopback adapter.
262+
263+
## Next step
264+
265+
In this article, you learned how to deploy a highly available DHCP server in Azure on a virtual machine. You also learned how to configure the network adapters and installed the DHCP role on the virtual machines. Further configuration of the DHCP server is required to provide DHCP services to on-premises clients from the Azure Virtual Machines. The DHCP relay agent on the on-premises network must be configured to forward DHCP requests to the DHCP servers in Azure. Consult the manufacturer's documentation for the DHCP relay agent for configuration steps.

articles/virtual-network/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@
311311
href: what-is-ip-address-168-63-129-16.md
312312
- name: Troubleshoot Azure VM connectivity problems
313313
href: troubleshoot-vm-connectivity.md
314+
- name: DHCP server on Azure Virtual Machine
315+
href: how-to-dhcp-azure.md
314316
- name: Monitor virtual network
315317
href: monitor-virtual-network.md
316318
- name: Classic deployment
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
title: include file
3+
description: include file
4+
services: virtual-network
5+
author: asudbring
6+
ms.service: virtual-network
7+
ms.topic: include
8+
ms.date: 02/28/2024
9+
ms.author: allensu
10+
ms.custom: include file
11+
---
12+
13+
## Create virtual machines
14+
15+
In this section, you create two VMs (**vm-1** and **vm-2**) in two different zones (**Zone 1** and **Zone 2**).
16+
17+
These VMs are added to the backend pool of the load balancer that was created earlier.
18+
19+
1. In the search box at the top of the portal, enter **Virtual machine**. Select **Virtual machines** in the search results.
20+
21+
1. Select **+ Create** then **Azure virtual machine**.
22+
23+
1. In **Create a virtual machine**, type or select the values in the **Basics** tab:
24+
25+
| Setting | Value |
26+
|---|---|
27+
| **Project details** | |
28+
| Subscription | Select your subscription. |
29+
| Resource group | Select **test-rg**. |
30+
| **Instance details** | |
31+
| Virtual machine name | Enter **vm-1**. |
32+
| Region | Select **East US 2**. |
33+
| Availability options | Select **Availability zone**. |
34+
| Availability zone | Select **Zones 1**. |
35+
| Security type | Select **Standard**. |
36+
| Image | Select **Windows Server 2022 Datacenter - x64 Gen2**. |
37+
| VM architecture | Leave the default of **x64**. |
38+
| Size | Select a size. |
39+
| **Administrator account** | |
40+
| Authentication type | Select **Password**. |
41+
| Username | Enter **azureuser**. |
42+
| Password | Enter a password. |
43+
| Confirm password | Reenter the password. |
44+
| **Inbound port rules** | |
45+
| Public inbound ports | Select **None**. |
46+
47+
1. Select the **Networking** tab, or select **Next: Disks**, then **Next: Networking**.
48+
49+
1. In the Networking tab, enter or select the following information:
50+
51+
| Setting | Value |
52+
|-|-|
53+
| **Network interface** | |
54+
| Virtual network | Select **vnet-1**. |
55+
| Subnet | Select **subnet-1 (10.0.0.0/24)** |
56+
| Public IP | Select **None**. |
57+
| NIC network security group | Select **Basic**|
58+
| Public inbound ports | Leave the default of **None**. |
59+
| **Load balancing** |
60+
| Place this virtual machine behind an existing load-balancing solution? | Select the check box.|
61+
| **Load balancing settings** |
62+
| Load-balancing options | Select **Azure load balancer** |
63+
| Select a load balancer | Select **load-balancer** |
64+
| Select a backend pool | Select **backend-pool** |
65+
66+
1. Select **Review + create**.
67+
68+
1. Review the settings, and then select **Create**.
69+
70+
1. Follow the previous steps to create a VM with the following values and all the other settings the same as **vm-1**:
71+
72+
| Setting | VM 2 |
73+
| ------- | ----- |
74+
| Name | **vm-2** |
75+
| Availability zone | **2** |
76+
| Load-balancing options | Select **Azure load balancer** |
77+
| Select a load balancer | Select **load-balancer** |
78+
| Select a backend pool | Select **backend-pool** |

includes/virtual-network-create-with-bastion.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ The following procedure creates a virtual network with a resource subnet, an Azu
4444

4545
| Setting | Value |
4646
|---|---|
47-
| Bastion host name | Enter **bastion**. |
48-
| Bastion public IP address | Select **Create a public IP address**. </br> Enter **public-ip** for the name. </br> Select **OK**. |
47+
| Azure Bastion host name | Enter **bastion**. |
48+
| Azure Bastion public IP address | Select **Create a public IP address**. </br> Enter **public-ip-bastion** in Name. </br> Select **OK**. |
4949

5050
:::image type="content" source="./media/virtual-network-create-with-bastion/enable-bastion.png" alt-text="Screenshot of options for enabling an Azure Bastion host as part of creating a virtual network in the Azure portal.":::
5151

0 commit comments

Comments
 (0)