Skip to content

Commit 13822a2

Browse files
authored
Merge pull request #310391 from asudbring/tsk544779-sfi-bastion
Replace insecure RDP testing with HTTP-based DNAT validation in Firewall tutorial
2 parents c855952 + b88f10a commit 13822a2

1 file changed

Lines changed: 120 additions & 29 deletions

File tree

articles/firewall/tutorial-firewall-deploy-portal-policy.md

Lines changed: 120 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ In this tutorial, you learn how to:
4040
> * Create a default route
4141
> * Configure an application rule to allow access to www.google.com
4242
> * 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
4444
> * Test the firewall
4545
4646
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.
7171

7272
### Create a VNet
7373

74-
This VNet will have two subnets.
74+
This VNet has two subnets.
7575

7676
> [!NOTE]
7777
> 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.
9494
1. Under **Subnets**, select **default**.
9595
1. On the **Edit subnet** page, for **Subnet purpose**, select **Azure Firewall**.
9696

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.
9898
1. For **Starting address**, type **10.0.1.0**.
9999
1. Select **Save**.
100100

@@ -107,34 +107,84 @@ Next, create a subnet for the workload server.
107107
1. Select **Review + create**.
108108
1. Select **Create**.
109109

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+
110135
### Create a virtual machine
111136

112137
Now create the workload virtual machine, and place it in the **Workload-SN** subnet.
113138

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**.
116141
1. Enter or select these values for the virtual machine:
117142

118143
| Setting | Value |
119144
| ------- | ----- |
145+
| **Project details** | |
120146
| Subscription | Select your Azure subscription. |
121147
| Resource group | Select **Test-FW-RG**. |
148+
| **Instance details** | |
122149
| Virtual machine name | Enter **Srv-Work**.|
123150
| Region | Select the same location that you used previously. |
124-
| Username | Enter a username. |
125-
| Password | Enter a password. |
151+
| Availability options | Select **No infrastructure redundancy required**. |
152+
| Security type | Select **Standard**. |
153+
| 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**. |
126159

127160
1. Under **Inbound port rules**, **Public inbound ports**, select **None**.
128161
1. Accept the other defaults and select **Next: Disks**.
129162
1. Accept the disk defaults and select **Next: Networking**.
130163
1. Make sure that **Test-FW-VN** is selected for the virtual network and the subnet is **Workload-SN**.
131164
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**.
135166
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.
136168
1. After the deployment completes, select the **Srv-Work** resource and note the private IP address for later use.
137169

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.
175+
1. Select the **Srv-Work** virtual machine.
176+
1. Select **Operations** > **Run command** > **RunShellScript**.
177+
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+
138188
## Deploy the firewall and policy
139189

140190
Deploy the firewall into the VNet.
@@ -146,23 +196,26 @@ Deploy the firewall into the VNet.
146196

147197
| Setting | Value |
148198
| ------- | ----- |
199+
| **Project details** | |
149200
| Subscription | Select your Azure subscription. |
150201
| Resource group | Select **Test-FW-RG**. |
202+
| **Instance details** | |
151203
| Name | Enter **Test-FW01**. |
152204
| Region | Select the same location that you used previously. |
205+
| Firewall SKU | Select **Standard**. |
153206
| 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**. |
157210

158211
1. Clear the **Enable Firewall Management NIC** check box.
159212
5. Accept the other default values, then select **Next: Tags**.
160213
1. Select **Next : Review + create**.
161214
1. Review the summary, and then select **Create** to create the firewall.
162215

163-
This will take a few minutes to deploy.
216+
This takes a few minutes to deploy.
164217
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.
166219

167220
## Create a default route
168221

@@ -174,10 +227,12 @@ For the **Workload-SN** subnet, configure the outbound default route to go throu
174227

175228
| Setting | Value |
176229
| ------- | ----- |
230+
| **Project details** | |
177231
| Subscription | Select your Azure subscription. |
178232
| Resource group | Select **Test-FW-RG**. |
179-
| Region | Select the same location that you used previously. |
233+
| **Instance details** | |
180234
| Name | Enter **Firewall-route**. |
235+
| Region | Select the same location that you used previously. |
181236

182237
1. Select **Review + create**.
183238
1. Select **Create**.
@@ -203,7 +258,7 @@ After deployment completes, select **Go to resource**.
203258
This is the application rule that allows outbound access to `www.google.com`.
204259

205260
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**.
207262
1. Select **Add a rule collection**.
208263
1. For **Name**, enter **App-Coll01**.
209264
1. For **Priority**, enter **200**.
@@ -218,6 +273,8 @@ This is the application rule that allows outbound access to `www.google.com`.
218273

219274
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).
220275

276+
Wait for the application rule deployment to complete before creating the network rule in the next steps.
277+
221278
## Configure a network rule
222279

223280
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
235292
1. For **Destination Ports**, enter **53**.
236293
1. For **Destination type** select **IP address**.
237294
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.
239298

240299
## Configure a DNAT rule
241300

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.
243302

244303
1. Select the **DNAT rules**.
245304
2. Select **Add a rule collection**.
246-
3. For **Name**, enter **RDP**.
305+
3. For **Name**, enter **HTTP**.
247306
1. For **Priority**, enter **200**.
248307
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**.
250309
1. For **Source type**, select **IP address**.
251310
1. For **Source**, enter *\**.
252311
1. For **Protocol**, select **TCP**.
253-
1. For **Destination Ports**, enter **3389**.
312+
1. For **Destination Ports**, enter **80**.
254313
1. For **Destination**, enter the firewall public IP address.
255314
1. For **Translated type**, select **IP Address**.
256315
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**.
258317
1. Select **Add**.
259318

260319

@@ -274,18 +333,50 @@ For testing purposes in this tutorial, configure the server's primary and second
274333

275334
Now, test the firewall to confirm that it works as expected.
276335

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.
280368

281-
You should see the Google home page.
369+
1. Now test access to Microsoft, which should be blocked. Enter:
282370

283-
5. Browse to `https://www.microsoft.com`.
371+
```bash
372+
curl -I https://www.microsoft.com
373+
```
284374

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.
286376

287377
So now you've verified that the firewall rules are working:
288378

379+
* You can access the web server through the DNAT rule.
289380
* You can browse to the one allowed FQDN, but not to any others.
290381
* You can resolve DNS names using the configured external DNS server.
291382

0 commit comments

Comments
 (0)