Beginner · Security · 10 of 15

Attach an NSG to a single NIC

Your tasks
  • Attach nsg-admin to vm-admin's NIC, not to subnet-app
  • Block vm-app from reaching vm-admin on 443

vm-admin (10.1.1.5) shares subnet-app with vm-app (10.1.1.4), which serves HTTPS to everyone in the VNet. Only subnet-ops, where vm-ops lives, should reach vm-admin, and only on SSH (22). nsg-admin already has those rules. Attach it to vm-admin's NIC, vm-admin-nic, not the subnet, so vm-app isn't affected.

You'll learn
NSGs on a network interface
  1. Attach nsg-admin to vm-admin's NIC.

    az network nic update -g rg-lab --name vm-admin-nic --network-security-group nsg-admin
    What's this?

    Changes a VM's network interface, such as its NSG or IP forwarding.

    • -g the resource group the resources live in
    • --name the name of the thing to look at or change
    • --name vm-admin-nic the network interface, not the VM
    • --network-security-group nsg-admin the NSG to associate
  2. List everything that now filters vm-admin.

    az network nic list-effective-nsg -g rg-lab --name vm-admin-nic
    What's this?

    Shows every security rule applied to a VM's network interface, from the subnet's NSG and the NIC's NSG, in the order they're checked.

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

    NSG
    Network security group: a list of allow and deny rules on a subnet or a network interface.
    NIC
    Network interface: a VM's network card in Azure. It holds the VM's private IP.
Sources on Microsoft Learn (3)
0/1 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-app: tap to inspectsubnet-app10.1.1.0/24 · 251 usablevm-app 10.1.1.4: tap to inspectNICvm-app10.1.1.4vm-admin 10.1.1.5: tap to inspectNICvm-admin10.1.1.5subnet-ops: tap to inspectsubnet-ops10.1.2.0/24 · 251 usablevm-ops 10.1.2.4: tap to inspectNICvm-ops10.1.2.4:22 ✓:443 ✗
  • vm-ops → vm-admin:22should work: working
  • vm-app → vm-admin:443should stay blocked: open, but it should be blocked
Goals 0/5
Cloud Shell · bashVMsrg-lab · eastus2
cloudshell:~$