You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/firewall/tutorial-firewall-dnat-policy.md
+61-23Lines changed: 61 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,28 +1,30 @@
1
1
---
2
-
title: 'Tutorial: Filter inbound Internet or intranet traffic with Azure Firewall DNAT policy using the portal'
3
-
description: In this tutorial, you learn how to deploy and configure Azure Firewall policy DNAT using the Azure portal.
2
+
title: 'Tutorial: Filter inbound Internet traffic with Azure Firewall DNAT policy using the portal'
3
+
description: In this tutorial, you learn how to deploy and configure Azure Firewall policy DNAT to publish a web server using the Azure portal.
4
4
services: firewall
5
5
author: varunkalyana
6
6
ms.service: azure-firewall
7
7
ms.topic: tutorial
8
-
ms.date: 05/07/2025
8
+
ms.date: 01/22/2026
9
9
ms.author: varunkalyana
10
10
ms.custom: mvc
11
-
#Customer intent: As an administrator, I want to deploy and configure Azure Firewall policy DNAT so that I can control inbound Internet access to resources located in a subnet.
12
-
# Customer intent: "As a network administrator, I want to deploy and configure a DNAT policy using Azure Firewall, so that I can manage and filter inbound traffic to my virtual network resources effectively."
11
+
#Customer intent: As an administrator, I want to deploy and configure Azure Firewall policy DNAT so that I can publish web applications and control inbound Internet access to resources located in a subnet.
13
12
---
14
13
15
-
# Tutorial: Filter inbound Internet or intranet traffic with Azure Firewall policy DNAT using the Azure portal
14
+
# Tutorial: Filter inbound Internet traffic with Azure Firewall policy DNAT using the Azure portal
16
15
17
-
You can configure Azure Firewall policy Destination Network Address Translation (DNAT) to translate and filter inbound internet or intranet traffic to your subnets. When you configure DNAT, the *rule collection action* is set to **DNAT**. Each rule in the NAT rule collection can then be used to translate your firewall public or private IP address and port to a private IP address and port. DNAT rules implicitly add a corresponding network rule to allow the translated traffic. For security reasons, the recommended approach is to add a specific source to allow DNAT access to the network and avoid using wildcards. To learn more about Azure Firewall rule processing logic, see [Azure Firewall rule processing logic](rule-processing.md).
16
+
You can configure Azure Firewall policy Destination Network Address Translation (DNAT) to translate and filter inbound internet traffic to your subnets. When you configure DNAT, the *rule collection action* is set to **DNAT**. Each rule in the NAT rule collection can then be used to translate your firewall public IP address and port to a private IP address and port. DNAT rules implicitly add a corresponding network rule to allow the translated traffic. For security reasons, the recommended approach is to add a specific source to allow DNAT access to the network and avoid using wildcards. To learn more about Azure Firewall rule processing logic, see [Azure Firewall rule processing logic](rule-processing.md).
17
+
18
+
This tutorial demonstrates publishing a web server using DNAT.
18
19
19
20
In this tutorial, you learn how to:
20
21
21
22
> [!div class="checklist"]
22
23
> * Set up a test network environment
23
24
> * Deploy a firewall and policy
24
25
> * Create a default route
25
-
> * Configure a DNAT rule
26
+
> * Deploy and configure a web server
27
+
> * Configure a DNAT rule to publish the web server
26
28
> * Test the firewall
27
29
28
30
## Prerequisites
@@ -106,19 +108,25 @@ Now peer the two VNets.
106
108
Create a workload virtual machine, and place it in the **SN-Workload** subnet.
107
109
108
110
1. From the Azure portal menu, select **Create a resource**.
109
-
2. Under **Popular**, select **Windows Server 2016 Datacenter**.
111
+
2. Under **Popular**, select **Ubuntu Server 22.04 LTS**.
110
112
111
113
**Basics**
112
114
113
115
1. For **Subscription**, select your subscription.
114
116
1. For **Resource group**, select **RG-DNAT-Test**.
115
117
1. For **Virtual machine name**, type **Srv-Workload**.
116
118
1. For **Region**, select the same location that you used previously.
117
-
1. Type a username and password.
119
+
1. For **Image**, select **Ubuntu Server 22.04 LTS - x64 Gen2**.
120
+
1. For **Size**, select **Standard_B2s**.
121
+
1. For **Authentication type**, select **SSH public key**.
122
+
1. For **Username**, type **azureuser**.
123
+
1. For **SSH public key source**, select **Generate new key pair**.
124
+
1. For **Key pair name**, type **Srv-Workload_key**.
125
+
1. Select **None** in **Public inbound ports**.
118
126
1. Select **Next: Disks**.
119
127
120
128
**Disks**
121
-
1. Select **Next: Networking**.
129
+
- Select **Next: Networking**.
122
130
123
131
**Networking**
124
132
@@ -130,15 +138,40 @@ Create a workload virtual machine, and place it in the **SN-Workload** subnet.
130
138
131
139
**Management**
132
140
141
+
- Select **Next: Monitoring**.
142
+
143
+
**Monitoring**
144
+
133
145
1. For **Boot diagnostics**, select **Disable**.
134
146
1. Select **Review + Create**.
135
147
136
148
**Review + Create**
137
149
138
-
Review the summary, and then select **Create**. This will take a few minutes to complete.
150
+
Review the summary, and then select **Create**.
151
+
152
+
- On the **Generate new key pair** dialog, select **Download private key and create resource**. Save the key file as **Srv-Workload_key.pem**.
139
153
140
154
After deployment finishes, note the private IP address for the virtual machine. It will be used later when you configure the firewall. Select the virtual machine name, and under **Settings**, select **Networking** to find the private IP address.
141
155
156
+
## Install web server
157
+
158
+
Use the Azure portal Run Command feature to install a web server on the virtual machine.
159
+
160
+
1. Navigate to the **Srv-Workload** virtual machine in the Azure portal.
161
+
1. Under **Operations**, select **Run command**.
162
+
1. Select **RunShellScript**.
163
+
1. In the **Run Command Script** window, paste the following script:
164
+
165
+
```bash
166
+
sudo apt-get update
167
+
sudo apt-get install -y nginx
168
+
echo"<h1>Azure Firewall DNAT Demo - $(hostname)</h1>"| sudo tee /var/www/html/index.html
169
+
```
170
+
171
+
1. Select **Run**.
172
+
1. Wait for the script to complete. The output should show successful installation of Nginx.
173
+
174
+
142
175
## Deploy the firewall and policy
143
176
144
177
1. From the portal home page, select **Create a resource**.
@@ -157,6 +190,7 @@ After deployment finishes, note the private IP address for the virtual machine.
157
190
|Choose a virtual network |**Use existing**: VN-Hub|
158
191
|Public IP address |**Add new**, Name: **fw-pip**.|
159
192
193
+
1. Uncheck the box next to **Enable Firewall Management NIC**.
160
194
5. Accept the other defaults, and then select **Review + create**.
161
195
6. Review the summary, and then select **Create** to create the firewall.
162
196
@@ -194,32 +228,36 @@ For the **SN-Workload** subnet, you configure the outbound default route to go t
194
228
18. For **Next hop address**, type the private IP address for the firewall that you noted previously.
195
229
19. Select **OK**.
196
230
197
-
## Configure a NAT rule
231
+
## Configure a DNAT rule
198
232
199
-
This rule allows you to connect a remote desktop to the Srv-Workload virtual machine through the firewall.
233
+
This rule allows inbound HTTP traffic from the Internet to reach the web server through the firewall.
200
234
201
235
1. Open the **RG-DNAT-Test** resource group, and select the **fw-dnat-pol** firewall policy.
202
236
1. Under **Settings**, select **DNAT rules**.
203
237
2. Select **Add a rule collection**.
204
-
3. For **Name**, type **rdp**.
238
+
3. For **Name**, type **web-access**.
205
239
1. For **Priority**, type **200**.
206
240
1. For **Rule collection group**, select **DefaultDnatRuleCollectionGroup**.
207
-
1. Under **Rules**, for **Name**, type **rdp-nat**.
241
+
1. Under **Rules**, for **Name**, type **http-dnat**.
208
242
1. For **Source type**, select **IP address**.
209
-
1. For **Source**, specify the IP address or range that you want to allow. For example, 192.168.1.0/24.
243
+
1. For **Source**, type **\***to allow traffic from any source.
210
244
1. For **Protocol**, select **TCP**.
211
-
1. For **Destination Ports**, type **3389**.
245
+
1. For **Destination Ports**, type **80**.
212
246
1. For **Destination Type**, select **IP Address**.
213
-
1. For **Destination**, type the firewall public or private IP address.
247
+
1. For **Destination**, type the firewall public IP address.
214
248
1. For **Translated address**, type the **Srv-Workload** private IP address.
215
-
1. For **Translated port**, type **3389**.
249
+
1. For **Translated port**, type **80**.
216
250
1. Select **Add**.
217
251
218
-
219
252
## Test the firewall
220
253
221
-
1. Connect a remote desktop to firewall public IP address. You should be connected to the **Srv-Workload** virtual machine.
222
-
2. Close the remote desktop.
254
+
Now test the DNAT rule to verify that the web server is accessible through the firewall.
255
+
256
+
1. Open a web browser.
257
+
1. Navigate to `http://<firewall-public-ip>` (use the firewall's public IP address you noted earlier).
258
+
1. You should see the web page displaying: **Azure Firewall DNAT Demo - Srv-Workload**
259
+
260
+
The DNAT rule successfully translates the incoming HTTP request on the firewall's public IP address to the web server's private IP address. This demonstrates how Azure Firewall DNAT can be used to publish web applications while keeping the backend servers in a private subnet.
0 commit comments