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
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
Copy file name to clipboardExpand all lines: articles/firewall/tutorial-firewall-dnat-policy.md
+87-9Lines changed: 87 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,15 +106,20 @@ Now peer the two VNets.
106
106
Create a workload virtual machine, and place it in the **SN-Workload** subnet.
107
107
108
108
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**.
110
110
111
111
**Basics**
112
112
113
113
1. For **Subscription**, select your subscription.
114
114
1. For **Resource group**, select **RG-DNAT-Test**.
115
115
1. For **Virtual machine name**, type **Srv-Workload**.
116
116
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**.
118
123
1. Select **Next: Disks**.
119
124
120
125
**Disks**
@@ -130,12 +135,18 @@ Create a workload virtual machine, and place it in the **SN-Workload** subnet.
130
135
131
136
**Management**
132
137
138
+
1. Select **Next: Monitoring**.
139
+
140
+
**Monitoring**
141
+
133
142
1. For **Boot diagnostics**, select **Disable**.
134
143
1. Select **Review + Create**.
135
144
136
145
**Review + Create**
137
146
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**.
139
150
140
151
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
152
@@ -198,6 +209,9 @@ For the **SN-Workload** subnet, you configure the outbound default route to go t
198
209
199
210
This rule allows you to connect a remote desktop to the Srv-Workload virtual machine through the firewall.
200
211
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
+
201
215
1. Open the **RG-DNAT-Test** resource group, and select the **fw-dnat-pol** firewall policy.
202
216
1. Under **Settings**, select **DNAT rules**.
203
217
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
206
220
1. For **Rule collection group**, select **DefaultDnatRuleCollectionGroup**.
207
221
1. Under **Rules**, for **Name**, type **rdp-nat**.
208
222
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.
210
224
1. For **Protocol**, select **TCP**.
211
-
1. For **Destination Ports**, type **3389**.
225
+
1. For **Destination Ports**, type **2222**.
212
226
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.
214
228
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**.
216
230
1. Select **Add**.
217
231
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**.
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
+
218
287
219
288
## Test the firewall
220
289
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.
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.
0 commit comments