Advanced · Inside the VM · 22 of 32

Check the VM's own firewall and app

Problem

vm-client can't open the site on vm-web at 443.

Your job
  • Let vm-client open the site on vm-web (443)
Without breaking
  • Keep UFW running on vm-webbroken
  • Keep SSH from vm-client to vm-web blockedbroken

vm-client can't open the site on vm-web at 443. There's no NSG and no route table anywhere in vnet-app, so Azure isn't filtering anything. Find out what's stopping it inside the VM. SSH to vm-web is for subnet-admin only, so vm-client must not get it.

You'll learn
Ruling the network out
  1. Test the connection from Azure's side. Look at the issue type on the last hop.

    az network watcher test-connectivity -g rg-lab --source-resource vm-client --dest-address 10.1.1.4 --dest-port 443
    What's this?

    Tests a real connection from a VM to a destination and reports whether it works, each hop on the way, and the issue that stops it.

    • -g the resource group the resources live in
    • --source-resource the VM the test starts from
    • --dest-address the IP or name to reach
    • --dest-port the port to reach
  2. GuestFirewall: the VM itself dropped it. Look inside with Run command.

    az vm run-command invoke -g rg-lab -n vm-web --command-id RunShellScript --scripts "ufw status numbered"
    What's this?

    Runs a script inside a VM through the VM agent, without logging in to it.

    • -g the resource group the resources live in
    • -n the name of the thing to look at or change
    • --command-id RunShellScript run your own shell script
    • --scripts the script, run as root by the VM agent
  3. Only SSH from the admin subnet is allowed. Allow 443 from the client subnet, nothing more.

    az vm run-command invoke -g rg-lab -n vm-web --command-id RunShellScript --scripts "ufw allow from 10.1.2.0/24 to any port 443 proto tcp"
    What's this?

    Runs a script inside a VM through the VM agent, without logging in to it.

    • -g the resource group the resources live in
    • -n the name of the thing to look at or change
  4. Test again. The issue changes.

    az network watcher test-connectivity -g rg-lab --source-resource vm-client --dest-address 10.1.1.4 --dest-port 443 --protocol Tcp
    What's this?

    Tests a real connection from a VM to a destination and reports whether it works, each hop on the way, and the issue that stops it.

    • -g the resource group the resources live in
    • --source-resource the VM the test starts from
    • --dest-address the IP or name to reach
    • --dest-port the port to reach
    • --protocol TCP or UDP
  5. NoListenerOnDestination: the firewall lets it in, but nothing answers. See what's listening, and the web server's state.

    az vm run-command invoke -g rg-lab -n vm-web --command-id RunShellScript --scripts "ss -tlnp && systemctl status nginx"
    What's this?

    Runs a script inside a VM through the VM agent, without logging in to it.

    • -g the resource group the resources live in
    • -n the name of the thing to look at or change
  6. Start the web server.

    az vm run-command invoke -g rg-lab -n vm-web --command-id RunShellScript --scripts "systemctl start nginx"
    What's this?

    Runs a script inside a VM through the VM agent, without logging in to it.

    • -g the resource group the resources live in
    • -n the name of the thing to look at or change
  7. Answer the question below.

    UFW
    Uncomplicated Firewall: the firewall inside an Ubuntu VM.
Sources on Microsoft Learn (5)
0/2 changes
Network map
?
  • Resource group, the outer dashed frame
  • Virtual network, with its address space top right
  • Subnet, with range and usable IPs (5 reserved)
  • Network security group. A small shield on a VM's NIC means the NIC has one too
  • Route table on the subnet
  • NICVM Appliance Private endpoint
  • Peering Connected Initiated or access off
  • Goal working Goal broken, X marks where it stops
  • Private DNS zone, dotted lines go to linked VNets
  • Orange pulse: what your last command changed. Drag to pan, Ctrl and scroll to zoom.
Resource grouprg-labvnet-app: tap to inspectVirtual networkvnet-app10.1.0.0/16subnet-web: tap to inspectsubnet-web10.1.1.0/24 · 251 usablevm-web 10.1.1.4: tap to inspectNICvm-web10.1.1.4subnet-client: tap to inspectsubnet-client10.1.2.0/24 · 251 usablevm-client 10.1.2.4: tap to inspectNICvm-client10.1.2.4subnet-admin: tap to inspectsubnet-admin10.1.9.0/24 · 251 usablevm-admin 10.1.9.4: tap to inspectNICvm-admin10.1.9.4:443 ✗
  • vm-client → vm-web:443should work: not working
  • vm-client → vm-web:22should stay blocked: blocked
Goals 0/4
Cloud Shell · bashVMs: Linuxrg-lab · eastus2
cloudshell:~$