|
1 | 1 | --- |
2 | | -title: Filter inbound Internet or intranet traffic with Azure Firewall DNAT using the portal |
3 | | -description: In this article, you learn how to deploy and configure Azure Firewall DNAT using the Azure portal. |
| 2 | +title: Filter inbound Internet traffic with Azure Firewall DNAT using the portal |
| 3 | +description: In this article, you learn how to deploy and configure Azure Firewall 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: how-to |
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 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 DNAT rules on Azure Firewall so that I can effectively manage and control inbound traffic to my network resources. |
| 11 | +#Customer intent: As an administrator, I want to deploy and configure Azure Firewall DNAT so that I can publish web applications and control inbound Internet access to resources located in a subnet. |
13 | 12 | --- |
14 | 13 |
|
15 | | -# Filter inbound Internet or intranet traffic with Azure Firewall DNAT using the Azure portal |
| 14 | +# Filter inbound Internet traffic with Azure Firewall DNAT using the Azure portal |
16 | 15 |
|
17 | | -You can configure Azure Firewall Destination Network Address Translation (DNAT) to translate and filter inbound internet traffic to your subnets or intranet traffic between private networks. When you configure DNAT, the NAT rule collection action is set to **DNAT**. Each rule in the NAT rule collection can then be used to translate your firewall's 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, it's recommended 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 Destination Network Address Translation (DNAT) to translate and filter inbound internet traffic to your subnets. When you configure DNAT, the NAT rule collection action is set to **DNAT**. Each rule in the NAT rule collection can then be used to translate your firewall's 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, 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). |
18 | 17 |
|
19 | 18 | > [!NOTE] |
20 | 19 | > This article uses classic Firewall rules to manage the firewall. The preferred method is to use [Firewall Policy](../firewall-manager/policy-overview.md). To complete this procedure using Firewall Policy, see [Tutorial: Filter inbound Internet traffic with Azure Firewall policy DNAT using the Azure portal](tutorial-firewall-dnat-policy.md). |
@@ -100,15 +99,20 @@ Now peer the two VNets. |
100 | 99 | Create a workload virtual machine, and place it in the **SN-Workload** subnet. |
101 | 100 |
|
102 | 101 | 1. From the Azure portal menu, select **Create a resource**. |
103 | | -2. Under **Popular Marketplace products**, select **Windows Server 2019 Datacenter**. |
| 102 | +2. Under **Popular Marketplace products**, select **Ubuntu Server 22.04 LTS**. |
104 | 103 |
|
105 | 104 | **Basics** |
106 | 105 |
|
107 | 106 | 1. For **Subscription**, select your subscription. |
108 | 107 | 2. For **Resource group**, select **RG-DNAT-Test**. |
109 | 108 | 3. For **Virtual machine name**, type **Srv-Workload**. |
110 | 109 | 4. For **Region**, select the same location that you used previously. |
111 | | -5. Type a username and password. |
| 110 | +5. For **Image**, select **Ubuntu Server 22.04 LTS - x64 Gen2**. |
| 111 | +6. For **Size**, select **Standard_B2s**. |
| 112 | +7. For **Authentication type**, select **SSH public key**. |
| 113 | +8. For **Username**, type **azureuser**. |
| 114 | +9. For **SSH public key source**, select **Generate new key pair**. |
| 115 | +10. For **Key pair name**, type **Srv-Workload_key**. |
112 | 116 | 6. Select **Next: Disks**. |
113 | 117 |
|
114 | 118 | **Disks** |
@@ -136,10 +140,30 @@ Create a workload virtual machine, and place it in the **SN-Workload** subnet. |
136 | 140 |
|
137 | 141 | Review the summary, and then select **Create**. This process takes a few minutes to complete. |
138 | 142 |
|
| 143 | +1. On the **Generate new key pair** dialog, select **Download private key and create resource**. Save the key file as **Srv-Workload_key.pem**. |
| 144 | + |
139 | 145 | After the deployment finishes, note the private IP address of the virtual machine. You need this IP address later when configuring the firewall. Select the virtual machine name, go to **Overview**, and under **Networking**, note the private IP address. |
140 | 146 |
|
141 | 147 | [!INCLUDE [ephemeral-ip-note.md](~/reusable-content/ce-skilling/azure/includes/ephemeral-ip-note.md)] |
142 | 148 |
|
| 149 | +## Install web server |
| 150 | + |
| 151 | +Use the Azure portal Run Command feature to install a web server on the virtual machine. |
| 152 | + |
| 153 | +1. Navigate to the **Srv-Workload** virtual machine in the Azure portal. |
| 154 | +1. Under **Operations**, select **Run command**. |
| 155 | +1. Select **RunShellScript**. |
| 156 | +1. In the **Run Command Script** window, paste the following script: |
| 157 | + |
| 158 | + ```bash |
| 159 | + sudo apt-get update |
| 160 | + sudo apt-get install -y nginx |
| 161 | + echo "<h1>Azure Firewall DNAT Demo - $(hostname)</h1>" | sudo tee /var/www/html/index.html |
| 162 | + ``` |
| 163 | + |
| 164 | +1. Select **Run**. |
| 165 | +1. Wait for the script to complete. The output should show successful installation of Nginx. |
| 166 | + |
143 | 167 | ## Deploy the firewall |
144 | 168 |
|
145 | 169 | 1. From the portal home page, select **Create a resource**. |
@@ -196,29 +220,37 @@ For the **SN-Workload** subnet, configure the outbound default route to go throu |
196 | 220 | 20. For **Next hop address**, type the private IP address of the firewall noted previously. |
197 | 221 | 21. Select **Add**. |
198 | 222 |
|
199 | | -## Configure a NAT rule |
| 223 | +## Configure a DNAT rule |
| 224 | + |
| 225 | +This rule allows inbound HTTP traffic from the Internet to reach the web server through the firewall. |
200 | 226 |
|
201 | 227 | 1. Open the **RG-DNAT-Test** resource group, and select the **FW-DNAT-test** firewall. |
202 | | -2. On the **FW-DNAT-test** page, under **Settings**, select **Rules (classic)**. |
203 | | -3. Select **Add NAT rule collection**. |
204 | | -4. For **Name**, type **RC-DNAT-01**. |
205 | | -5. For **Priority**, type **200**. |
206 | | -6. Under **Rules**, for **Name**, type **RL-01**. |
207 | | -7. For **Protocol**, select **TCP**. |
208 | | -8. For **Source type**, select **IP address**. |
209 | | -9. For **Source**, type *. |
210 | | -10. For **Destination Addresses**, type the firewall's public IP address. |
211 | | -11. For **Destination ports**, type **3389**. |
212 | | -12. For **Translated Address**, type the private IP address of the Srv-Workload virtual machine. |
213 | | -13. For **Translated port**, type **3389**. |
214 | | -14. Select **Add**. |
215 | | - |
216 | | -This process takes a few minutes to complete. |
| 228 | +1. On the **FW-DNAT-test** page, under **Settings**, select **Rules (classic)**. |
| 229 | +1. Select the **NAT rule collection** tab. |
| 230 | +1. Select **Add NAT rule collection**. |
| 231 | +1. For **Name**, type **web-access**. |
| 232 | +1. For **Priority**, type **200**. |
| 233 | +1. Under **Rules**, for **Name**, type **http-dnat**. |
| 234 | +1. For **Protocol**, select **TCP**. |
| 235 | +1. For **Source type**, select **IP address**. |
| 236 | +1. For **Source**, type **\*** to allow traffic from any source. |
| 237 | +1. For **Destination Addresses**, type the firewall public IP address. |
| 238 | +1. For **Destination ports**, type **80**. |
| 239 | +1. For **Translated address**, type the **Srv-Workload** private IP address. |
| 240 | +1. For **Translated port**, type **80**. |
| 241 | +1. Select **Add**. |
217 | 242 |
|
218 | 243 | ## Test the firewall |
219 | 244 |
|
220 | | -1. Connect a remote desktop to the firewall's public IP address. You should be connected to the **Srv-Workload** virtual machine. |
221 | | -2. Close the remote desktop. |
| 245 | +1. Open a web browser and navigate to the firewall's public IP address: |
| 246 | + |
| 247 | + ``` |
| 248 | + http://<firewall-public-ip> |
| 249 | + ``` |
| 250 | + |
| 251 | + You should see the web page displaying "Azure Firewall DNAT Demo - Srv-Workload." |
| 252 | + |
| 253 | +1. This procedure confirms that the DNAT rule is successfully translating incoming HTTP traffic on the firewall's public IP address to the web server's private IP address. |
222 | 254 |
|
223 | 255 | ## Clean up resources |
224 | 256 |
|
|
0 commit comments