Skip to content

Commit 0f8ab37

Browse files
committed
Task 544783: Add Bastion for hybrid network topology
- Changed VM-Spoke-01 from Windows to Ubuntu 22.04 LTS - Changed VM-Onprem from Windows to Ubuntu 22.04 LTS - Replaced password authentication with SSH keys (Azure-generated) - Updated network rule from AllowRDP to AllowSSH (port 3389 to 22) - Replaced IIS installation with Nginx using Azure CLI - Added AzureBastionSubnet (10.5.3.0/26) to VNet-hub - Deployed Azure Bastion with Developer SKU in hub network - Removed public inbound ports from VM-Onprem - Updated testing section to use Bastion SSH connection - Replaced RDP and web browser testing with curl and SSH - Removed screenshot reference for web page testing
1 parent 6221663 commit 0f8ab37

1 file changed

Lines changed: 93 additions & 35 deletions

File tree

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

Lines changed: 93 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,15 @@ First, add a network rule to allow web traffic.
190190
1. For **Destination type**, select **IP address**.
191191
1. For **Destination**, type **10.6.0.0/16**.
192192

193-
Now add a rule to allow RDP traffic.
193+
Now add a rule to allow SSH traffic.
194194

195195
On the second rule row, type the following information:
196196

197-
1. **Name**, type **AllowRDP**.
197+
1. **Name**, type **AllowSSH**.
198198
3. For **Source type**, select **IP address**.
199199
4. For **Source**, type **192.168.1.0/24**.
200200
2. For **Protocol**, select **TCP**.
201-
1. For **Destination Ports**, type **3389**.
201+
1. For **Destination Ports**, type **22**.
202202
1. For **Destination type**, select **IP address**.
203203
1. For **Destination**, type **10.6.0.0/16**
204204
1. Select **Add**.
@@ -389,14 +389,18 @@ Now create the spoke workload and on-premises virtual machines, and place them i
389389
Create a virtual machine in the spoke virtual network, running IIS, with no public IP address.
390390

391391
1. From the Azure portal home page, select **Create a resource**.
392-
2. Under **Popular Marketplace products**, select **Windows Server 2019 Datacenter**.
392+
2. Under **Popular Marketplace products**, select **Ubuntu Server 22.04 LTS**.
393393
3. Enter these values for the virtual machine:
394394
- **Resource group** - Select **FW-Hybrid-Test**
395395
- **Virtual machine name**: *VM-Spoke-01*
396-
- **Region** - Same region that you're used previously
397-
- **User name**: \<type a user name\>
398-
- **Password**: \<type a password\>
399-
4. For **Public inbound ports**, select **Allow selected ports**, and then select **HTTP (80)**, and **RDP (3389)**.
396+
- **Region** - Same region that you used previously
397+
- **Image** - Ubuntu Server 22.04 LTS - x64 Gen2
398+
- **Size** - Standard_B2s
399+
- **Authentication type** - SSH public key
400+
- **Username**: **azureuser**
401+
- **SSH public key source** - Generate new key pair
402+
- **Key pair name** - **VM-Spoke-01_key**
403+
4. For **Public inbound ports**, select **None**.
400404
4. Select **Next:Disks**.
401405
5. Accept the defaults and select **Next: Networking**.
402406
6. Select **VNet-Spoke** for the virtual network and the subnet is **SN-Workload**.
@@ -405,68 +409,122 @@ Create a virtual machine in the spoke virtual network, running IIS, with no publ
405409
1. Select **Next : Monitoring**.
406410
1. For **Boot diagnostics**, Select **Disable**.
407411
1. Select **Review+Create**, review the settings on the summary page, and then select **Create**.
412+
1. On the **Generate new key pair** dialog, select **Download private key and create resource**. Save the key file as **VM-Spoke-01_key.pem**.
408413

409-
### Install IIS
414+
### Install Nginx
410415

411-
After the virtual machine is created, install IIS.
416+
After the virtual machine is created, install Nginx web server.
412417

413-
1. From the Azure portal, open the Cloud Shell and make sure that it's set to **PowerShell**.
414-
2. Run the following command to install IIS on the virtual machine and change the location if necessary:
418+
1. From the Azure portal, open the Cloud Shell and make sure that it's set to **Bash**.
419+
2. Run the following command to install Nginx on the virtual machine:
415420

416-
```azurepowershell-interactive
417-
Set-AzVMExtension `
418-
-ResourceGroupName FW-Hybrid-Test `
419-
-ExtensionName IIS `
420-
-VMName VM-Spoke-01 `
421-
-Publisher Microsoft.Compute `
422-
-ExtensionType CustomScriptExtension `
423-
-TypeHandlerVersion 1.4 `
424-
-SettingString '{"commandToExecute":"powershell Add-WindowsFeature Web-Server; powershell Add-Content -Path \"C:\\inetpub\\wwwroot\\Default.htm\" -Value $($env:computername)"}' `
425-
-Location EastUS
421+
```azurecli-interactive
422+
az vm run-command invoke \
423+
--resource-group FW-Hybrid-Test \
424+
--name VM-Spoke-01 \
425+
--command-id RunShellScript \
426+
--scripts "sudo apt-get update && sudo apt-get install -y nginx && echo '<h1>'$(hostname)'</h1>' | sudo tee /var/www/html/index.html"
426427
```
427428

428429
### Create the on-premises virtual machine
429430

430-
This is a virtual machine that you use to connect using Remote Desktop to the public IP address. From there, you then connect to the on-premises server through the firewall.
431+
This is a virtual machine that you use to connect using Azure Bastion. From there, you then connect to the spoke server through the firewall.
431432

432433
1. From the Azure portal home page, select **Create a resource**.
433-
2. Under **Popular Marketplace products**, select **Windows Server 2019 Datacenter**.
434+
2. Under **Popular Marketplace products**, select **Ubuntu Server 22.04 LTS**.
434435
3. Enter these values for the virtual machine:
435436
- **Resource group** - Select existing, and then select **FW-Hybrid-Test**.
436437
- **Virtual machine name** - *VM-Onprem*.
437438
- **Region** - Same region that you used previously.
438-
- **User name**: \<type a user name\>.
439-
- **Password**: \<type a user password\>.
440-
7. For **Public inbound ports**, select **Allow selected ports**, and then select **RDP (3389)**
439+
- **Image** - Ubuntu Server 22.04 LTS - x64 Gen2
440+
- **Size** - Standard_B2s
441+
- **Authentication type** - SSH public key
442+
- **Username**: **azureuser**
443+
- **SSH public key source** - Generate new key pair
444+
- **Key pair name** - **VM-Onprem_key**
445+
446+
7. For **Public inbound ports**, select **None**
441447
4. Select **Next:Disks**.
442448
5. Accept the defaults and select **Next:Networking**.
443449
6. Select **VNet-Onprem** for virtual network and the subnet is **SN-Corp**.
450+
444451
8. Select **Next:Management**.
445452
1. Select **Next : Monitoring**.
446453
1. For **Boot diagnostics**, select **Disable**.
447454
1. Select **Review+Create**, review the settings on the summary page, and then select **Create**.
455+
1. On the **Generate new key pair** dialog, select **Download private key and create resource**. Save the key file as **VM-Onprem_key.pem**.
448456

449457
[!INCLUDE [ephemeral-ip-note.md](~/reusable-content/ce-skilling/azure/includes/ephemeral-ip-note.md)]
450458

459+
## Deploy Azure Bastion
460+
461+
Now deploy Azure Bastion in the hub virtual network to provide secure access to the on-premises virtual machine.
462+
463+
1. Navigate to the **VNet-hub** virtual network.
464+
1. Select **Subnets** > **+ Subnet**.
465+
1. Configure the new subnet:
466+
- **Name**: **AzureBastionSubnet** (this exact name is required)
467+
- **Subnet address range**: **10.5.3.0/26**
468+
1. Select **Save**.
469+
470+
1. On the Azure portal menu, select **Create a resource**.
471+
1. Search for **Bastion** and select it.
472+
1. Select **Create**.
473+
1. Configure the Bastion deployment:
474+
475+
| Setting | Value |
476+
|---------|-------|
477+
| Subscription | Your subscription |
478+
| Resource group | **FW-Hybrid-Test** |
479+
| Name | **Hub-Bastion** |
480+
| Region | Same as your other resources |
481+
| Tier | **Developer** |
482+
| Virtual network | **VNet-hub** |
483+
| Subnet | **AzureBastionSubnet** (auto-selected) |
484+
| Public IP address | Create new |
485+
| Public IP address name | **Bastion-pip** |
486+
487+
1. Select **Review + create**.
488+
1. Select **Create**.
489+
490+
The deployment takes about 10 minutes to complete.
491+
451492
## Test the firewall
452493

453494
1. First, note the private IP address for **VM-spoke-01** virtual machine.
454495

455-
2. From the Azure portal, connect to the **VM-Onprem** virtual machine.
496+
2. From the Azure portal, navigate to the **VM-Onprem** virtual machine.
497+
498+
3. Select **Connect** > **Connect via Bastion**.
499+
500+
4. Select **Use SSH Private Key from Local File**.
501+
502+
5. For **Username**, type **azureuser**.
503+
504+
6. Browse to and select the **VM-Onprem_key.pem** file you downloaded earlier.
456505

457-
3. Open a web browser on **VM-Onprem**, and browse to http://\<VM-spoke-01 private IP\>.
506+
7. Select **Connect**.
458507

459-
You should see the **VM-spoke-01** web page:
460-
![VM-Spoke-01 web page](media/tutorial-hybrid-portal/VM-Spoke-01-web.png)
508+
8. From the SSH session on **VM-Onprem**, test the web server on the spoke virtual network:
461509

462-
4. From the **VM-Onprem** virtual machine, open a remote desktop to **VM-spoke-01** at the private IP address.
510+
```bash
511+
curl http://<VM-spoke-01 private IP>
512+
```
513+
514+
You should see the **VM-spoke-01** web page with the hostname displayed.
515+
516+
9. From the **VM-Onprem** SSH session, connect to **VM-spoke-01** using SSH:
517+
518+
```bash
519+
ssh azureuser@<VM-spoke-01 private IP>
520+
```
463521

464-
Your connection should succeed, and you should be able to sign in.
522+
Your connection should succeed, and you should see a login prompt. Type **exit** to close the SSH connection.
465523

466524
So now you verified that the firewall rules are working:
467525

468-
- You can browse web server on the spoke virtual network.
469-
- You can connect to the server on the spoke virtual network using RDP.
526+
- You can browse the web server on the spoke virtual network.
527+
- You can connect to the server on the spoke virtual network using SSH.
470528

471529
Next, change the firewall network rule collection action to **Deny** to verify that the firewall rules work as expected.
472530

0 commit comments

Comments
 (0)