Configure Network Security for the Server

Lab overview

Surf City Boats' new server has no public IP, but nothing yet controls what can reach it inside the network. In this lab you create nsg-surfcity-servers in rg-surfcity-infra, read the three default inbound rules Azure ships with every security group, add a priority-300 rule that allows RDP (TCP 3389) only from the VirtualNetwork service tag, and associate the NSG with the snet-servers subnet rather than the VM's network interface. You finish on vm-surfcity-01's Network settings page, confirming the subnet-level NSG applies to the server while its NIC stays unprotected by any second group.

Why you'd do this

A network security group is Azure's stateful packet filter: an ordered list of allow and deny rules evaluated by priority, lowest number first, with the first match winning. Every NSG starts with three inbound defaults you can't edit: AllowVnetInBound (65000), AllowAzureLoadBalancerInBound (65001), and DenyAllInBound (65500). You'll open those rules in this lab and notice they're read-only, which is the point: anything you don't explicitly allow above 65500 is dropped.

The rule you'll add, Allow-RDP-From-VNet, looks redundant next to AllowVnetInBound, and in today's configuration it is. It becomes meaningful the moment someone adds a broad deny rule below it or tightens the defaults, because it pins down the one path Surf City actually needs: RDP from inside the virtual network, where Bastion will live after lab 5. Using the VirtualNetwork service tag instead of a hard-coded address range means the rule keeps working as subnets are added, and the Service: RDP preset fills in TCP 3389 so you're not typing port numbers by hand.

Where you attach the NSG matters as much as what's in it. Associating it with the subnet protects every current and future server on snet-servers with one set of rules. Attaching NSGs to individual NICs works too, but when a subnet NSG and a NIC NSG both exist, traffic has to pass both, and that layering is the number one cause of "the rule is there but it still doesn't connect" support tickets. Leaving the NIC at None, as you did in lab 3, keeps one place to look.

The verification step is worth slowing down for. The VM's Network settings page shows the NSG with "attached to subnet: snet-servers" and "Impacts 1 subnets, 0 network interfaces", and expanding Inbound port rules lists your rule at 300 above the three defaults. Reading effective rules from the VM's side, not the NSG's, is how you troubleshoot connectivity in production, and NSG rule evaluation, service tags, and subnet-versus-NIC association are all tested on AZ-104.

Lab details

  • Network security group: nsg-surfcity-servers in rg-surfcity-infra · Region: (US) East US 2
  • Default inbound rules reviewed: AllowVnetInBound (65000), AllowAzureLoadBalancerInBound (65001), DenyAllInBound (65500)
  • New inbound rule: Allow-RDP-From-VNet · Priority 300 · Source: Service Tag VirtualNetwork · Service: RDP (TCP 3389) · Action: Allow
  • Association: subnet vnet-surfcity / snet-servers (not the VM's network interface)
  • Verification: vm-surfcity-01 Network settings — NSG attached to subnet, impacts 1 subnet and 0 NICs

Learning objectives

  1. Create a network security group in an existing resource group.
  2. Read the default inbound rules and explain priority-based evaluation.
  3. Add an inbound allow rule scoped to a service tag and a service preset.
  4. Associate an NSG with a subnet and explain subnet versus NIC association.
  5. Verify which NSG and rules apply to a VM from its Network settings page.

Exam relevance

  • AZ-900 — Microsoft Azure Fundamentals — network security groups, inbound and outbound rules, defense in depth.
  • AZ-104 — Microsoft Azure Administrator — create and configure NSGs, rule priority and evaluation, service tags, associate NSGs with subnets and NICs, evaluate effective security rules.

Where this lab fits in the project

Lab 3 deployed vm-surfcity-01 onto snet-servers with no public IP and no NIC-level security group, which left the subnet itself as the place to put network controls. This lab adds them. The RDP-from-VNet rule you create is what will let Azure Bastion, deployed into the same virtual network in lab 5, open a desktop session to the server, and it stays in force when you mount the file share from that session in lab 6.

Step-by-step instructions

  1. Open the Network security groups service:
    • On the Azure portal Home page, in the search box at the top, type Network security groups and select it under Services.
    • Select + Create.
  2. Configure the Basics tab:
    • Confirm the Surf City Boats subscription is selected and choose resource group rg-surfcity-infra.
    • In the Name field, type nsg-surfcity-servers and select region (US) East US 2.
    • Select Review + create.
  3. Create the network security group:
    • Confirm Validation passed is displayed and select Create.
    • When deployment completes, select Go to resource.
  4. Review the default inbound rules:
    • In the left menu, under Settings, select Inbound security rules.
    • Review AllowVnetInBound at priority 65000, AllowAzureLoadBalancerInBound at 65001, and DenyAllInBound at 65500.
    • Select DenyAllInBound and confirm its properties are read-only.
  5. Add an inbound rule for RDP from the virtual network:
    • Select + Add.
    • In the Source dropdown, select Service Tag; in the Source service tag dropdown, select VirtualNetwork.
    • Confirm Source port ranges is * and Destination is Any.
    • In the Service dropdown, select RDP, and confirm Destination port ranges shows 3389 and Protocol shows TCP.
    • Confirm Action is Allow, set Priority to 300, and name the rule Allow-RDP-From-VNet.
    • Select Add and confirm the rule appears in the list at priority 300.
  6. Associate the NSG with the server subnet:
    • In the left menu, under Settings, select Subnets, then + Associate.
    • In the Virtual network dropdown, select vnet-surfcity; in the Subnet dropdown, select snet-servers.
    • Select OK and confirm snet-servers is listed under Subnets.
  7. Verify the NSG is applied to the server:
    • In the search box at the top of the portal, type vm-surfcity-01 and select it under Resources.
    • Under Networking, select Network settings.
    • Under Essentials, confirm Network security group shows -, meaning no NSG is attached directly to the network interface.
    • Below Essentials, confirm the card shows nsg-surfcity-servers (attached to subnet: snet-servers) and reads Impacts 1 subnets, 0 network interfaces.
    • Expand Inbound port rules and confirm Allow-RDP-From-VNet is listed at priority 300 (port 3389, TCP, source VirtualNetwork) with the three default rules below it at 65000, 65001, and 65500.

Launch the lab simulation — free with a labITpro account; no Azure subscription required.

An Introduction to Microsoft Entra ID

Learn what you need to know to get started with Microsoft Entra ID with this easily-digestible 5-hour bootcamp from best-selling instructor, Thomas Mitchell.

Disable these ads by becoming a labITpro Supporter!

Azure vNets Explained

Want to learn about Azure virtual networks? In this quick-hitting explanation, you’ll learn what they are, what they do, and you’ll learn about key Azure vNet features.

Disable these ads by becoming a labITpro Supporter!