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
@@ -40,7 +40,7 @@ In this tutorial, you learn how to:
40
40
> * Create a default route
41
41
> * Configure an application rule to allow access to www.google.com
42
42
> * Configure a network rule to allow access to external DNS servers
43
-
> * Configure a NAT rule to allow a remote desktop to the test server
43
+
> * Configure a NAT rule to allow inbound HTTP access to the test server
44
44
> * Test the firewall
45
45
46
46
If you prefer, you can complete this procedure using [Azure PowerShell](deploy-ps-policy.md).
@@ -71,7 +71,7 @@ The resource group contains all the resources for the tutorial.
71
71
72
72
### Create a VNet
73
73
74
-
This VNet will have two subnets.
74
+
This VNet has two subnets.
75
75
76
76
> [!NOTE]
77
77
> The size of the AzureFirewallSubnet subnet is /26. For more information about the subnet size, see [Azure Firewall FAQ](firewall-faq.yml#why-does-azure-firewall-need-a--26-subnet-size).
@@ -94,7 +94,7 @@ This VNet will have two subnets.
94
94
1. Under **Subnets**, select **default**.
95
95
1. On the **Edit subnet** page, for **Subnet purpose**, select **Azure Firewall**.
96
96
97
-
The firewall will be in this subnet, and the subnet name **must** be AzureFirewallSubnet.
97
+
The firewall is in this subnet, and the subnet name **must** be AzureFirewallSubnet.
98
98
1. For **Starting address**, type **10.0.1.0**.
99
99
1. Select **Save**.
100
100
@@ -107,34 +107,84 @@ Next, create a subnet for the workload server.
107
107
1. Select **Review + create**.
108
108
1. Select **Create**.
109
109
110
+
## Deploy Azure Bastion
111
+
112
+
Deploy Azure Bastion Developer edition to securely connect to the **Srv-Work** virtual machine for testing.
113
+
114
+
1. In the search box at the top of the portal, enter **Bastion**. Select **Bastions** from the search results.
115
+
1. Select **Create**.
116
+
1. On the **Create a Bastion** page, enter or select the following values:
117
+
118
+
| Setting | Value |
119
+
| ------- | ----- |
120
+
|**Project details**||
121
+
| Subscription | Select your Azure subscription. |
122
+
| Resource group | Select **Test-FW-RG**. |
123
+
|**Instance details**||
124
+
| Name | Enter **Test-Bastion**. |
125
+
| Region | Select the same location that you used previously. |
126
+
| Tier | Select **Developer**. |
127
+
| Virtual network | Select **Test-FW-VN**. |
128
+
| Subnet | The **AzureBastionSubnet** is created automatically with address space **10.0.0.0/26**. |
129
+
130
+
1. Select **Review + create**.
131
+
1. Review the settings and select **Create**.
132
+
133
+
The deployment takes a few minutes to complete.
134
+
110
135
### Create a virtual machine
111
136
112
137
Now create the workload virtual machine, and place it in the **Workload-SN** subnet.
113
138
114
-
1.On the Azure portal menu or from the **Home** page, select **Create a resource**.
115
-
1. Select **Windows Server 2019 Datacenter**.
139
+
1.In the search box at the top of the portal enter **Virtual machine**, select **Virtual machines** in the search results.
140
+
1. Select **Create** > **Virtual machine**.
116
141
1. Enter or select these values for the virtual machine:
117
142
118
143
| Setting | Value |
119
144
| ------- | ----- |
145
+
|**Project details**||
120
146
| Subscription | Select your Azure subscription. |
121
147
| Resource group | Select **Test-FW-RG**. |
148
+
|**Instance details**||
122
149
| Virtual machine name | Enter **Srv-Work**.|
123
150
| Region | Select the same location that you used previously. |
| Image | Select **Ubuntu Server 24.04 LTS -x64 Gen2**|
154
+
| Size | Select a size for the virtual machine. |
155
+
|**Administrator account**||
156
+
| Username | Enter **azureuser**. |
157
+
| SSH public key source | Select **Generate new key pair**. |
158
+
| Key pair name | Enter **Srv-Work_key**. |
126
159
127
160
1. Under **Inbound port rules**, **Public inbound ports**, select **None**.
128
161
1. Accept the other defaults and select **Next: Disks**.
129
162
1. Accept the disk defaults and select **Next: Networking**.
130
163
1. Make sure that **Test-FW-VN** is selected for the virtual network and the subnet is **Workload-SN**.
131
164
1. For **Public IP**, select **None**.
132
-
1. Accept the other defaults and select **Next: Management**.
133
-
1. Select **Next:Monitoring**.
134
-
1. Select **Disable** to disable boot diagnostics. Accept the other defaults and select **Review + create**.
165
+
1. Select **Review + create**.
135
166
1. Review the settings on the summary page, and then select **Create**.
167
+
1. When prompted, select **Download private key and create resource**. Save the private key file to your computer.
136
168
1. After the deployment completes, select the **Srv-Work** resource and note the private IP address for later use.
137
169
170
+
### Install a web server
171
+
172
+
Connect to the virtual machine and install a web server for testing.
173
+
174
+
1. On the Azure portal menu, select **Resource groups** or search for and select *Resource groups* from any page. Select the **Test-FW-RG** resource group.
1. In the script box, enter the following commands:
178
+
179
+
```bash
180
+
sudo apt-get update
181
+
sudo apt-get install -y nginx
182
+
echo"<html><body><h1>Azure Firewall DNAT Test</h1><p>If you can see this page, the DNAT rule is working correctly!</p></body></html>"| sudo tee /var/www/html/index.html
183
+
```
184
+
185
+
1. Select **Run**.
186
+
1. Wait for the script to complete successfully.
187
+
138
188
## Deploy the firewall and policy
139
189
140
190
Deploy the firewall into the VNet.
@@ -146,23 +196,26 @@ Deploy the firewall into the VNet.
146
196
147
197
| Setting | Value |
148
198
| ------- | ----- |
199
+
|**Project details**||
149
200
| Subscription | Select your Azure subscription. |
150
201
| Resource group | Select **Test-FW-RG**. |
202
+
|**Instance details**||
151
203
| Name | Enter **Test-FW01**. |
152
204
| Region | Select the same location that you used previously. |
205
+
| Firewall SKU | Select **Standard**. |
153
206
| Firewall management | Select **Use a Firewall Policy to manage this firewall**. |
154
-
| Firewall policy | Select **Add new**, and enter **fw-test-pol**. <br> Select the same region that you used previously.|
155
-
| Choose a virtual network | Select **Use existing**, and then select **Test-FW-VN**. |
156
-
| Public IP address | Select **Add new**, and enter **fw-pip** for the **Name**. |
207
+
| Firewall policy | Select **Add new**, and enter **fw-test-pol**. <br> Select the same region that you used previously. Select **OK**. |
208
+
| Choose a virtual network | Select **Use existing**, and then select **Test-FW-VN**. **Ignore the warning about the Force Tunneling. The warning is resolved in a later step**.|
209
+
| Public IP address | Select **Add new**, and enter **fw-pip** for the **Name**. Select **OK**. |
157
210
158
211
1. Clear the **Enable Firewall Management NIC** check box.
159
212
5. Accept the other default values, then select **Next: Tags**.
160
213
1. Select **Next : Review + create**.
161
214
1. Review the summary, and then select **Create** to create the firewall.
162
215
163
-
This will take a few minutes to deploy.
216
+
This takes a few minutes to deploy.
164
217
7. After deployment completes, go to the **Test-FW-RG** resource group, and select the **Test-FW01** firewall.
165
-
8. Note the firewall private and public IP addresses. You'll use these addresses later.
218
+
8. Note the firewall private and public IP addresses. You use these addresses later.
166
219
167
220
## Create a default route
168
221
@@ -174,10 +227,12 @@ For the **Workload-SN** subnet, configure the outbound default route to go throu
174
227
175
228
| Setting | Value |
176
229
| ------- | ----- |
230
+
|**Project details**||
177
231
| Subscription | Select your Azure subscription. |
178
232
| Resource group | Select **Test-FW-RG**. |
179
-
|Region | Select the same location that you used previously.|
233
+
|**Instance details**||
180
234
| Name | Enter **Firewall-route**. |
235
+
| Region | Select the same location that you used previously. |
181
236
182
237
1. Select **Review + create**.
183
238
1. Select **Create**.
@@ -203,7 +258,7 @@ After deployment completes, select **Go to resource**.
203
258
This is the application rule that allows outbound access to `www.google.com`.
204
259
205
260
1. Open the **Test-FW-RG** resource group, and select the **fw-test-pol** firewall policy.
206
-
1. Under **Settings**, Select **Application rules**.
261
+
1. Under **Settings** > **Rules**, Select **Application rules**.
207
262
1. Select **Add a rule collection**.
208
263
1. For **Name**, enter **App-Coll01**.
209
264
1. For **Priority**, enter **200**.
@@ -218,6 +273,8 @@ This is the application rule that allows outbound access to `www.google.com`.
218
273
219
274
Azure Firewall includes a built-in rule collection for infrastructure FQDNs that are allowed by default. These FQDNs are specific for the platform and can't be used for other purposes. For more information, see [Infrastructure FQDNs](infrastructure-fqdns.md).
220
275
276
+
Wait for the application rule deployment to complete before creating the network rule in the next steps.
277
+
221
278
## Configure a network rule
222
279
223
280
This is the network rule that allows outbound access to two IP addresses at port 53 (DNS).
@@ -235,26 +292,28 @@ This is the network rule that allows outbound access to two IP addresses at port
235
292
1. For **Destination Ports**, enter **53**.
236
293
1. For **Destination type** select **IP address**.
237
294
1. For **Destination**, enter **209.244.0.3,209.244.0.4**.<br>These are public DNS servers operated by CenturyLink.
238
-
2. Select **Add**.
295
+
1. Select **Add**.
296
+
297
+
Wait for the network rule deployment to complete before creating the DNAT rule in the next steps.
239
298
240
299
## Configure a DNAT rule
241
300
242
-
This rule allows you to connect a remote desktop to the **Srv-Work** virtual machine through the firewall.
301
+
This rule allows you to connect to the web server on the **Srv-Work** virtual machine through the firewall.
243
302
244
303
1. Select the **DNAT rules**.
245
304
2. Select **Add a rule collection**.
246
-
3. For **Name**, enter **RDP**.
305
+
3. For **Name**, enter **HTTP**.
247
306
1. For **Priority**, enter **200**.
248
307
1. For **Rule collection group**, select **DefaultDnatRuleCollectionGroup**.
249
-
1. Under **Rules**, for **Name**, enter **rdp-nat**.
308
+
1. Under **Rules**, for **Name**, enter **http-nat**.
250
309
1. For **Source type**, select **IP address**.
251
310
1. For **Source**, enter *\**.
252
311
1. For **Protocol**, select **TCP**.
253
-
1. For **Destination Ports**, enter **3389**.
312
+
1. For **Destination Ports**, enter **80**.
254
313
1. For **Destination**, enter the firewall public IP address.
255
314
1. For **Translated type**, select **IP Address**.
256
315
1. For **Translated address**, enter the **Srv-work** private IP address.
257
-
1. For **Translated port**, enter **3389**.
316
+
1. For **Translated port**, enter **80**.
258
317
1. Select **Add**.
259
318
260
319
@@ -274,18 +333,50 @@ For testing purposes in this tutorial, configure the server's primary and second
274
333
275
334
Now, test the firewall to confirm that it works as expected.
276
335
277
-
1. Connect a remote desktop to firewall public IP address and sign in to the **Srv-Work** virtual machine.
278
-
3. Open Microsoft Edge and browse to `https://www.google.com`.
279
-
4. Select **OK** > **Close** on the Internet Explorer security alerts.
336
+
### Test the DNAT rule
337
+
338
+
1. Open a web browser on your local computer.
339
+
1. In the address bar, enter `http://<firewall-public-ip-address>`, where `<firewall-public-ip-address>` is the public IP address of the firewall you noted earlier.
340
+
1. You should see the custom web page: **Azure Firewall DNAT Test**. This confirms that the DNAT rule is working and traffic is being forwarded to the **Srv-Work** virtual machine.
341
+
342
+
### Test the application and network rules
343
+
344
+
Use Azure Bastion to securely connect to the **Srv-Work** virtual machine and test the firewall rules.
345
+
346
+
1. On the Azure portal menu, select **Resource groups** or search for and select *Resource groups* from any page. Select the **Test-FW-RG** resource group.
347
+
1. Select the **Srv-Work** virtual machine.
348
+
1. Select **Connect** > **Connect via Bastion**.
349
+
1. On the Bastion page, enter or select the following values:
350
+
351
+
| Setting | Value |
352
+
| ------- | ----- |
353
+
| Authentication Type | Select **SSH Private Key from Local File**. |
354
+
| Username | Enter **azureuser**. |
355
+
| Local File | Select **Browse** and select the **Srv-Work_key.pem** file that you downloaded during VM creation. |
356
+
357
+
1. Select **Connect**.
358
+
359
+
A new browser tab opens with an SSH session to the **Srv-Work** virtual machine.
360
+
361
+
1. In the SSH session, enter the following command to test access to Google:
362
+
363
+
```bash
364
+
curl -I https://www.google.com
365
+
```
366
+
367
+
You should see a successful HTTP response (200 OK), indicating that the application rule is allowing access to Google.
280
368
281
-
You should see the Google home page.
369
+
1. Now test access to Microsoft, which should be blocked. Enter:
282
370
283
-
5. Browse to `https://www.microsoft.com`.
371
+
```bash
372
+
curl -I https://www.microsoft.com
373
+
```
284
374
285
-
You should be blocked by the firewall.
375
+
The command should time out or fail after approximately 60 seconds, indicating that the firewall is blocking access.
286
376
287
377
So now you've verified that the firewall rules are working:
288
378
379
+
* You can access the web server through the DNAT rule.
289
380
* You can browse to the one allowed FQDN, but not to any others.
290
381
* You can resolve DNS names using the configured external DNS server.
0 commit comments