Skip to content

Commit ec430c2

Browse files
committed
Task 544781: Add Bastion alternative to DNAT tutorial
- Changed VM from Windows Server 2016 to Ubuntu 22.04 LTS - Replaced password authentication with SSH keys (Azure-generated) - Updated DNAT rule to use SSH (port 22) instead of RDP (port 3389) - Changed DNAT destination port to 2222 for SSH access - Added comprehensive Azure Bastion alternative section - Documented benefits of Bastion over DNAT - Provided step-by-step Bastion deployment with Developer SKU - Added AzureBastionSubnet (192.168.2.0/26) to VN-Spoke - Updated testing section to show both DNAT and Bastion methods - Added note recommending Bastion for production environments
1 parent d9c6f63 commit ec430c2

1 file changed

Lines changed: 87 additions & 9 deletions

File tree

articles/firewall/tutorial-firewall-dnat-policy.md

Lines changed: 87 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,20 @@ Now peer the two VNets.
106106
Create a workload virtual machine, and place it in the **SN-Workload** subnet.
107107

108108
1. From the Azure portal menu, select **Create a resource**.
109-
2. Under **Popular**, select **Windows Server 2016 Datacenter**.
109+
2. Under **Popular**, select **Ubuntu Server 22.04 LTS**.
110110

111111
**Basics**
112112

113113
1. For **Subscription**, select your subscription.
114114
1. For **Resource group**, select **RG-DNAT-Test**.
115115
1. For **Virtual machine name**, type **Srv-Workload**.
116116
1. For **Region**, select the same location that you used previously.
117-
1. Type a username and password.
117+
1. For **Image**, select **Ubuntu Server 22.04 LTS - x64 Gen2**.
118+
1. For **Size**, select **Standard_B2s**.
119+
1. For **Authentication type**, select **SSH public key**.
120+
1. For **Username**, type **azureuser**.
121+
1. For **SSH public key source**, select **Generate new key pair**.
122+
1. For **Key pair name**, type **Srv-Workload_key**.
118123
1. Select **Next: Disks**.
119124

120125
**Disks**
@@ -130,12 +135,18 @@ Create a workload virtual machine, and place it in the **SN-Workload** subnet.
130135

131136
**Management**
132137

138+
1. Select **Next: Monitoring**.
139+
140+
**Monitoring**
141+
133142
1. For **Boot diagnostics**, select **Disable**.
134143
1. Select **Review + Create**.
135144

136145
**Review + Create**
137146

138-
Review the summary, and then select **Create**. This will take a few minutes to complete.
147+
Review the summary, and then select **Create**.
148+
149+
1. On the **Generate new key pair** dialog, select **Download private key and create resource**. Save the key file as **Srv-Workload_key.pem**.
139150

140151
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.
141152

@@ -198,6 +209,9 @@ For the **SN-Workload** subnet, you configure the outbound default route to go t
198209

199210
This rule allows you to connect a remote desktop to the Srv-Workload virtual machine through the firewall.
200211

212+
> [!NOTE]
213+
> This tutorial demonstrates DNAT configuration for educational purposes. For production environments, **Azure Bastion is the recommended approach** for secure VM access. See the [Alternative: Using Azure Bastion](#alternative-using-azure-bastion-recommended) section below for the modern best practice.
214+
201215
1. Open the **RG-DNAT-Test** resource group, and select the **fw-dnat-pol** firewall policy.
202216
1. Under **Settings**, select **DNAT rules**.
203217
2. Select **Add a rule collection**.
@@ -206,20 +220,84 @@ This rule allows you to connect a remote desktop to the Srv-Workload virtual mac
206220
1. For **Rule collection group**, select **DefaultDnatRuleCollectionGroup**.
207221
1. Under **Rules**, for **Name**, type **rdp-nat**.
208222
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.
223+
1. For **Source**, specify the IP address or range that you want to allow. For example, your current public IP address.
210224
1. For **Protocol**, select **TCP**.
211-
1. For **Destination Ports**, type **3389**.
225+
1. For **Destination Ports**, type **2222**.
212226
1. For **Destination Type**, select **IP Address**.
213-
1. For **Destination**, type the firewall public or private IP address.
227+
1. For **Destination**, type the firewall public IP address.
214228
1. For **Translated address**, type the **Srv-Workload** private IP address.
215-
1. For **Translated port**, type **3389**.
229+
1. For **Translated port**, type **22**.
216230
1. Select **Add**.
217231

232+
## Alternative: Using Azure Bastion (Recommended)
233+
234+
For production deployments, Azure Bastion provides a more secure alternative to DNAT rules for VM access. Azure Bastion eliminates the need to expose VMs to the internet and provides secure RDP/SSH connectivity directly from the Azure portal.
235+
236+
### Benefits of Azure Bastion over DNAT
237+
238+
- **No public IP exposure**: VMs don't need public IPs or DNAT rules
239+
- **Protection against port scanning**: No exposed RDP/SSH ports
240+
- **Built-in security**: Integrated with Azure security features
241+
- **Simplified management**: Connect directly from Azure portal
242+
- **Compliance**: Meets regulatory requirements for secure access
243+
244+
### Deploy Azure Bastion
245+
246+
1. In the **VN-Spoke** virtual network, add a new subnet:
247+
- Navigate to **VN-Spoke** > **Subnets** > **+ Subnet**
248+
- **Name**: **AzureBastionSubnet** (this exact name is required)
249+
- **Subnet address range**: **192.168.2.0/26**
250+
- Select **Save**
251+
252+
1. On the Azure portal menu, select **Create a resource**.
253+
1. Search for **Bastion** and select it.
254+
1. Select **Create**.
255+
1. Configure the Bastion deployment:
256+
257+
| Setting | Value |
258+
|---------|-------|
259+
| Subscription | Your subscription |
260+
| Resource group | **RG-DNAT-Test** |
261+
| Name | **VN-Spoke-Bastion** |
262+
| Region | Same as your other resources |
263+
| Tier | **Developer** |
264+
| Virtual network | **VN-Spoke** |
265+
| Subnet | **AzureBastionSubnet** (auto-selected) |
266+
| Public IP address | Create new |
267+
| Public IP address name | **Bastion-pip** |
268+
269+
1. Select **Review + create**.
270+
1. Select **Create**.
271+
272+
Deployment takes about 10 minutes to complete.
273+
274+
### Connect using Azure Bastion
275+
276+
Once Azure Bastion is deployed, you can connect to the VM:
277+
278+
1. Navigate to the **Srv-Workload** virtual machine in the Azure portal.
279+
1. Select **Connect** > **Connect via Bastion**.
280+
1. Select **Use SSH Private Key from Local File**.
281+
1. For **Username**, type **azureuser**.
282+
1. Browse to and select the **Srv-Workload_key.pem** file you downloaded earlier.
283+
1. Select **Connect**.
284+
285+
You're now securely connected to the VM without any DNAT rules or firewall configuration.
286+
218287

219288
## Test the firewall
220289

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.
290+
1. If using DNAT: Use an SSH client to connect to the firewall public IP address on port 2222. Use the private key file you downloaded during VM creation. You should be connected to the **Srv-Workload** virtual machine.
291+
292+
```bash
293+
ssh -i Srv-Workload_key.pem azureuser@<firewall-public-ip> -p 2222
294+
```
295+
296+
2. If using Azure Bastion: Navigate to the **Srv-Workload** VM in the Azure portal, select **Connect** > **Connect via Bastion**, and use your SSH key to connect.
297+
298+
3. Close the connection.
299+
300+
You've successfully tested access to the VM. For production environments, use Azure Bastion for enhanced security.
223301

224302
## Clean up resources
225303

0 commit comments

Comments
 (0)