Azure 31 min read Beginner

Azure VNet, Subnet, and NSG Fundamentals: Plan Address Space, Read Rules, and Verify Traffic

Learn Azure networking through a three-tier example: plan non-overlapping CIDRs, segment subnets, read stateful NSG rules, and prove both allowed and denied traffic paths.

Microsoft Learn reviewed
2026-08-11
Aerial view of city blocks divided by streets, representing an Azure VNet divided into subnets with controlled traffic paths
자료 이미지: Photo by Zoshua Colah on Unsplash
On this page
  1. Explicitly out of scope
  2. 1. The decision this article helps you make
  3. 2. One mental model for VNet, subnet, route, and NSG
  4. 3. Inventory connected networks before choosing a CIDR
  5. 4. Read CIDR without fear
  6. 5. Create a non-overlapping address plan
  7. 6. Budget for Azure reservations and growth
  8. 7. Split subnets by role, trust, scale, and lifecycle
  9. 8. Reserve room for platform and future subnets
  10. 9. A subnet is not an automatic security wall
  11. 10. Draw the three-tier reference architecture
  12. 11. Write the traffic inventory before writing rules
  13. 12. Walk one packet from source to application
  14. 13. What an NSG does—and does not do
  15. 14. Read an NSG rule from left to right
  16. Why the source port is usually *
  17. 15. Lower number wins, and first match stops
  18. 16. Read the six default rules before trusting segmentation
  19. Default inbound rules
  20. Default outbound rules
  21. 17. Understand stateful return traffic
  22. 18. Subnet NSG and NIC NSG evaluation
  23. 19. Use service tags, ASGs, and advanced rules without hiding intent
  24. Service tags represent managed IP prefix sets
  25. Application security groups represent NIC roles
  26. Augmented rules reduce rule count
  27. Central admin rules may be evaluated before local NSGs
  28. Azure platform endpoints require caution
  29. 20. Translate the three-tier intent into learning rules
  30. 21. Evaluate packets like the NSG
  31. Case A: Edge → Web TCP 443
  32. Case B: Edge → Web TCP 80
  33. Case C: Web → App TCP 8443
  34. Case D: Web → Data TCP 1433
  35. Case E: App → Data TCP 1433
  36. Case F: App → Data TCP 3306
  37. Case G: Data response to the permitted App request
  38. Case H: The allow rule was just removed
  39. 22. Prove both allowed and denied paths
  40. Layer 1: configuration evidence
  41. Layer 2: simulated rule decisions
  42. Layer 3: real positive and negative connections
  43. Layer 4: operating evidence
  44. 23. Operate changes as policy, not portal memory
  45. Address and subnet checklist
  46. NSG checklist
  47. Validation and operations checklist
  48. 24. Self-review questions and one-minute memory card
  49. Questions
  50. Memory card
  51. References

An Azure virtual network can look deceptively simple in the portal: choose an address range, create a subnet, attach a network security group, and add a few rules. The difficult part is not clicking Create. It is being able to answer, before and after deployment:

Which component may initiate a connection?
Which destination and port does it actually need?
Which route carries the packet?
Which rule allows or denies it?
How do we prove both the required path and the forbidden path?

Beginners often treat a VNet as a private room, a subnet as a wall, and an NSG as a small firewall appliance. That mental model is incomplete. Resources in the same VNet can communicate through Azure system routes by default. Separating two resources into different subnets organizes addresses and creates policy-attachment points, but it does not automatically deny traffic between them. An NSG filters Layer 3 and Layer 4 flows, but it does not create routes, perform source network address translation (SNAT), resolve names, authenticate users, or prove that an application is listening.

This is the fifth detailed note in the 12-topic Module 1 study plan for Coursera’s Azure Cybersecurity Solutions and Microsoft Defender course. The Module 1 review provides the wider control map. The preceding private VM design note separated administration, application inbound, internet outbound, and Azure service access. This article now explains the VNet, subnet, and NSG building blocks that make those paths enforceable.

These are independent study notes, not a transcript, assessment answer, production deployment record, or substitute for an application-specific threat model. Product behavior and limitations were reviewed against official Microsoft documentation on August 11, 2026.

Explicitly out of scope

This article teaches IPv4 address planning and NSG evaluation through one simplified three-tier workload. It does not provide portal, CLI, PowerShell, Bicep, or Terraform deployment steps. Full IPv6 design, hub-and-spoke transit, user-defined route implementation, VPN and ExpressRoute configuration, Azure Firewall policy, WAF tuning, Private Link DNS, and operating-system hardening remain separate topics. Example ports express a learning contract, not a ready-to-deploy production rule set.

1. The decision this article helps you make

The practical question is:

How should a beginner divide one Azure VNet into subnets, translate an application’s required connections into least-privilege NSG rules, and prove that allowed and denied traffic behave as intended?

By the end, you should be able to:

  • read /16, /24, and /29 CIDR notation without guessing;
  • calculate usable Azure IPv4 addresses after platform reservations;
  • choose address ranges that do not collide with future connected networks;
  • divide a VNet by role, trust, scale, and lifecycle;
  • explain why a subnet is not an automatic security wall;
  • read every field in an NSG rule from left to right;
  • predict which rule wins by direction and priority;
  • explain stateful return traffic and existing-flow behavior;
  • understand subnet-level and NIC-level NSG evaluation;
  • use service tags and application security groups (ASGs) without hiding intent;
  • convert a three-tier flow inventory into a small learning rule set; and
  • validate configuration, simulated rule decisions, actual connectivity, and flow evidence separately.

The output is not “an NSG exists.” It is a compact evidence package:

Address plan
+ subnet allocation table
+ required-flow inventory
+ versioned NSG rules
+ effective rule and route exports
+ positive and negative test results
+ log destination and owner
+ review date and rollback method

2. One mental model for VNet, subnet, route, and NSG

Use a city analogy carefully.

Azure conceptCity analogyTechnical job
VNet address spaceThe full city boundary and address planDefines which private IP ranges belong to the virtual network
SubnetA district inside the cityAllocates a smaller CIDR range and provides a placement/policy scope
Network interface (NIC)A building’s network entranceConnects a VM to one subnet and receives private IP configuration
RouteA road sign and next intersectionSelects the next hop for a destination prefix
NSGA traffic checkpointAllows or denies an L3/L4 flow by source, destination, port, protocol, and direction
DNSAn address directoryResolves a name into an address
Guest firewall and listenerThe building’s final door and service deskDecide whether the operating system and application accept the connection

The analogy stops before it becomes misleading. Azure networking is software-defined Layer 3 networking, not a physical Ethernet segment. A subnet boundary does not contain an invisible firewall. Azure also reserves addresses and provides platform services in ways that differ from a home network.

The memory model is:

Address space says where an IP belongs.
A route chooses the next hop.
An NSG permits or denies the flow.
None of them proves that the application is listening.

3. Inventory connected networks before choosing a CIDR

Do not begin by selecting 10.0.0.0/16 because it is familiar. First inventory every network this VNet might need to reach during its expected lifetime. The table below is a completed learning example; a real record must contain the organization’s actual prefixes and evidence that every overlap check passed.

Connected or future networkCurrent CIDRConnection methodOwnerOverlap checked?
Corporate datacenter10.0.0.0/16ExpressRouteNetwork teamYes
Branch offices172.16.0.0/16Site-to-site VPNNetwork teamYes
Existing Azure production10.20.0.0/16VNet peeringPlatform teamYes
Disaster-recovery region10.50.0.0/16 reservedGlobal VNet peeringPlatform teamYes
AWS or Google Cloud10.60.0.0/16 reservedFuture interconnectCloud platform teamYes
Vendor network192.168.50.0/24VPNService ownerYes

RFC 1918 provides three familiar private IPv4 ranges: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. Azure can also treat supported shared address space such as RFC 6598 100.64.0.0/10 as private in documented scenarios. “Private” does not mean “globally unique.” Thousands of organizations use the same ranges.

Two isolated VNets can technically reuse a CIDR. The problem appears when the organization later tries to connect them. Ordinary VNet peering requires non-overlapping address space, and overlapping hybrid or cross-cloud routes make the intended destination ambiguous. Readdressing running systems is much harder than reserving a non-overlapping block before deployment.

An address decision record should name the inventory date and approver:

Selected block: 10.40.0.0/16
Environment: learning example / production equivalent to be confirmed
Checked against: Azure, on-premises, DR, other clouds, vendors
Growth horizon: 24–36 months
Owner: platform networking
Review trigger: new peering, VPN, region, cloud, acquisition, or address expansion

4. Read CIDR without fear

CIDR notation combines a base address and a prefix length. In IPv4 there are 32 bits. The prefix says how many leading bits describe the network; the remaining bits describe addresses inside it.

Address count = 2 ^ (32 - prefix length)
CIDRHost bitsTotal IPv4 addressesAzure-usable addresses after five reservationsTypical lesson
/161665,536Not normally used as one enormous workload subnetUseful as a parent VNet block to subdivide
/248256251Easy learning and general workload subnet example
/2666459Required minimum for some dedicated platform subnets
/2753227Small subnet with limited scale headroom
/29383Smallest supported IPv4 subnet; rarely a flexible production choice

A smaller prefix number represents a larger address block. /16 is much larger than /24. The prefix is not a resource capacity target; a service might require a particular minimum or consume several addresses during scale-out and upgrade.

For the learning VNet:

VNet: 10.40.0.0/16

Possible /24 child ranges:
10.40.0.0/24
10.40.1.0/24
...
10.40.255.0/24

This does not mean all 256 child ranges should be created immediately. It means the parent block leaves a structured space from which the team can allocate without overlap.

5. Create a non-overlapping address plan

Use a table rather than a diagram alone.

AllocationCIDRPurposeStateGrowth note
VNet10.40.0.0/16Entire workload networkAllocatedMust not overlap connected networks
snet-edge10.40.0.0/24Approved application frontendAllocatedPlatform-specific sizing must be rechecked
snet-web10.40.10.0/24Web-tier backendsAllocatedScale-out and upgrade headroom
snet-app10.40.20.0/24Application-tier servicesAllocatedScale-out and blue/green headroom
snet-data10.40.30.0/24Database-tier hostsAllocatedPrivate endpoints evaluated separately
snet-management10.40.40.0/24Approved management componentsReservedActual administration design is outside scope
Future platform/workloadsRemaining non-overlapping rangesGrowth, DR, or dedicated servicesReserved poolAllocate only through IP management process

The gaps between examples are intentional. They make diagrams and summaries easier to read and leave room for related subnets. A production allocation might use different sizes and a centrally managed IP Address Management (IPAM) system. Azure Virtual Network Manager includes IPAM capabilities for larger estates; a small team can begin with a controlled register if ownership and review are real.

Do not copy 10.40.0.0/16 into production without checking the organization’s actual inventory. The example is documentation address planning, not a universal safe range.

6. Budget for Azure reservations and growth

Azure reserves five IPv4 addresses in every subnet:

Address positionExample in 10.40.10.0/24Azure purpose
First10.40.10.0Network identifier
Second10.40.10.1Default gateway
Third10.40.10.2Azure DNS mapping
Fourth10.40.10.3Azure DNS mapping
Last10.40.10.255Reserved broadcast address

Therefore a /24 has 256 total addresses but 251 usable Azure resource addresses, not 254. A /29 has eight total and only three usable. Azure is a Layer 3 overlay and does not provide traditional broadcast or multicast behavior merely because the final address is reserved.

Sizing must also include:

  • current VM and NIC count;
  • temporary addresses during scale-out, rolling upgrades, blue/green deployment, or failover;
  • private endpoints and platform instances that consume subnet addresses;
  • required dedicated subnet sizes;
  • monitoring, recovery, and management components;
  • two- to three-year growth; and
  • enough contiguous free space to expand without readdressing.

“We need six VMs, so /28 is enough today” is not a design. The next deployment may need surge instances, parallel replacement, or a service whose minimum size is larger. Record the calculation and its growth assumption.

7. Split subnets by role, trust, scale, and lifecycle

Subnet design should express meaningful differences. Useful reasons to separate resources include:

  • Application role: edge, web, application, data, management, and private endpoints have different required flows.
  • Trust level: an internet-facing frontend and a database should not inherit one undifferentiated policy.
  • Scale pattern: a stateless web tier can scale differently from a fixed management component.
  • Lifecycle: platform-owned shared services and application-owned instances may change on different schedules.
  • Routing requirement: a subnet may need a route table that directs egress through a firewall.
  • Service requirement: Azure Firewall, Bastion, VPN Gateway, Route Server, and DNS Private Resolver have documented subnet naming or sizing requirements.
  • Delegation requirement: some Azure services require a delegated subnet and restrict which other resources can share it.

Avoid both extremes:

One subnet for everything
→ simple initially, weak policy boundaries and difficult change ownership

One subnet for every VM
→ excessive objects, wasted reserved addresses, fragmented policy and operations

A good starting principle is to group components that share the same trust boundary, required flows, route behavior, scale pattern, and owner. Exceptions should be explicit rather than discovered in rule names such as TemporaryAllowAll2.

8. Reserve room for platform and future subnets

Some Azure services require a dedicated subnet or strongly recommended capacity. Current examples include:

ServiceCurrent design referenceBeginner implication
Azure FirewallDedicated AzureFirewallSubnet, /26 minimumDo not fill the VNet before planning central inspection
Azure BastionDedicated AzureBastionSubnet, /26 minimum for current dedicated deploymentsReserve the correct name and capacity if Bastion is selected
VPN GatewayGatewaySubnet, /27 or larger recommendedHybrid connectivity consumes planned address space
Azure DNS Private ResolverDedicated inbound and outbound endpoint subnets, /28 minimum eachDNS design may require two additional subnets
Application Gateway v2Dedicated subnet; /24 commonly recommended for scaleFrontend capacity is not just the current instance count
Private EndpointConsumes a private IP in a subnet; dedicated subnet not universally requiredCount endpoints and decide an ownership pattern

These values can change and some services have SKU- or scenario-specific requirements. Treat this table as a planning prompt and verify the current product documentation before deployment.

The lesson is not “make every subnet /24.” It is “inventory platform requirements before allocating the easy ranges.”

9. A subnet is not an automatic security wall

Azure creates system routes that let resources in the same VNet reach one another by default. A subnet partitions addresses and provides attachment scope for NSGs and route tables, but creating snet-web and snet-data alone does not deny Web-to-Database traffic.

If an NSG exists, its default inbound rule at priority 65000 is AllowVNetInBound. The VirtualNetwork service tag is broader than “this subnet.” It can include the VNet address space and connected ranges such as peered VNets or on-premises networks, depending on topology and routes. Treating that default as least-privilege segmentation is unsafe.

Subnet separation only

Web 10.40.10.4 ───────────────► Database 10.40.30.4:1433
                  system route
                  no intended deny yet

Segmentation needs both:

  1. an address and placement boundary that makes roles understandable; and
  2. an enforcement rule that permits the required source, destination, protocol, and port while denying unintended neighboring paths.

This does not mean every pair of subnets requires a custom deny in every architecture. It means the team must inspect the actual applicable rules and prove the result instead of assuming the subnet name enforces intent.

10. Draw the three-tier reference architecture

The rest of this article uses one simplified topology.

Internet user
    │
    ▼ HTTPS 443
Approved reverse-proxy frontend
Learning assumption: Application Gateway v2
snet-edge 10.40.0.0/24
    │
    ▼ HTTPS 443
Web tier
snet-web 10.40.10.0/24
    │
    ▼ TCP 8443
Application tier
snet-app 10.40.20.0/24
    │
    ▼ TCP 1433
Database tier
snet-data 10.40.30.0/24

The intended application flow is sequential:

Edge → Web → App → Data

The following shortcuts should fail:

Internet ─X→ Web / App / Data directly
Edge     ─X→ App / Data directly
Web      ─X→ Data directly
App      ─X→ Data on an unapproved port

This learning topology assumes that Application Gateway v2 acts as a reverse proxy in snet-edge and opens a new connection to the Web backend. Another frontend can present a different source to the backend. For example, Azure Load Balancer preserves the original client source IP, and its load-balancing rule does not replace an applicable NSG permission. Recheck the selected product’s backend source semantics before copying the later NSG examples.

Ports 443, 8443, and 1433 are learning examples. A real application contract must identify the actual listener, encryption, authentication, health probe, source, destination, and availability requirements. SQL Server’s familiar port does not mean every data tier should expose TCP 1433.

11. Write the traffic inventory before writing rules

Rules are implementation. Begin with flows and reasons.

IDPurposeSourceDestinationProtocol / destination portExpected resultOwnerFailure impact
F01Frontend deliverysnet-edgeWeb tierTCP 443AllowEdge teamUser requests fail
F02Application callWeb tierApp tierTCP 8443AllowApp teamWeb requests fail
F03Database callApp tierData tierTCP 1433AllowData teamTransactions fail
F04Direct database shortcutWeb tierData tierTCP 1433DenySecurity ownerLimits lateral movement
F05Wrong app portWeb tierApp tierTCP 22DenySecurity ownerPrevents unintended administration path
F06Wrong database portApp tierData tierTCP 3306DenySecurity ownerEnforces actual application contract
F07Direct public accessInternetApp and Data tiersAnyDenyPlatform teamPrevents direct exposure

This table is deliberately incomplete for deployment. Add actual requirements for:

  • DNS resolution;
  • operating-system updates and package repositories;
  • identity and time synchronization;
  • monitoring and log export;
  • backup and recovery;
  • load-balancer or application health probes;
  • vulnerability management;
  • administration through the approved private path; and
  • outbound application dependencies.

An owner must decide each dependency. “Allow any outbound because agents need things” is not a flow inventory.

12. Walk one packet from source to application

Suppose the Web tier calls app.internal.example on TCP 8443. Follow the dependencies in the documented outbound and inbound evaluation order.

1. DNS
   app.internal.example → 10.40.20.4

2. Source-side filtering
   Any applicable Web NIC/subnet outbound NSGs evaluate the new flow

3. Route selection
   Web NIC effective route for 10.40.20.4 → Virtual network next hop

4. Destination-side filtering
   Any applicable App subnet/NIC inbound NSGs evaluate the new flow

5. Guest operating system
   OS firewall permits TCP 8443

6. Listener
   Application is bound to the expected interface and TCP 8443

7. TLS and identity
   Certificate, client identity, and application authorization succeed

8. Application health
   The process can serve the requested operation and its dependencies

An NSG Allow proves only the network-filter decision for its scope. It does not prove that DNS returned the intended address, a route exists, the return path is valid, the guest firewall permits traffic, the service is listening, or authentication succeeds.

The inverse is also important. A correct route cannot override an NSG Deny. Troubleshooting must identify the failing layer instead of repeatedly changing the NSG.

13. What an NSG does—and does not do

An Azure Network Security Group is a distributed, stateful Layer 3 and Layer 4 traffic filter. It contains inbound and outbound rules and can be associated with supported subnets and VM network interfaces.

An NSG can decide:

  • whether a new inbound or outbound flow is allowed or denied;
  • based on source, source port, destination, destination port, and protocol;
  • at subnet or NIC enforcement scope; and
  • using IP/CIDR values, service tags, or application security groups where supported.

An NSG does not:

  • create a route or select a network virtual appliance;
  • provide SNAT or a stable outbound public IP;
  • create a public or private endpoint;
  • resolve DNS names or filter by arbitrary FQDN;
  • inspect HTTP paths, SQL injection, malware, or TLS content;
  • authenticate a user or workload identity;
  • patch or harden an operating system;
  • prove that a destination application is listening; or
  • replace centralized firewall policy when the architecture requires inspection, egress governance, or cross-network operations.

This boundary is why “NSG is a cheaper Azure Firewall” is a poor comparison. They can both filter some packet attributes, but their enforcement, inspection, routing, logging, and operating models differ. The next Module 1 topics examine Azure Firewall separately.

14. Read an NSG rule from left to right

Every rule should be readable as a sentence.

FieldExampleQuestion it answers
NameAllow-Web-To-App-8443Why does this rule exist?
Priority100When is it evaluated relative to neighboring rules?
DirectionInboundIs the flow entering or leaving the protected resource?
Sourceasg-webWho initiates the connection?
Source port*Which client-side port can initiate it?
Destinationasg-appWhich role receives the connection?
Destination port8443Which service port is required?
ProtocolTCPWhich Layer 4 protocol is allowed?
ActionAllowIs the matching flow accepted or rejected?

Read it aloud:

For inbound traffic, allow TCP connections initiated by Web-tier NICs from any client source port to App-tier NICs on destination port 8443, before lower-priority rules are considered.

Why the source port is usually *

A client commonly selects an ephemeral source port, such as 51542, when it connects to server destination port 8443. Restricting both source and destination to 8443 can accidentally describe a connection the client never makes.

Web client 10.40.10.4:51542 → App server 10.40.20.4:8443
                source port                         destination port

Restrict the destination service port. Restrict the source address or role. Limit source ports only when the protocol contract genuinely requires it.

For inbound traffic through a public IP, NSG evaluation occurs after Azure translates the public destination to the private address. For outbound, the NSG evaluates the private source before public translation. Use the VM’s private IP, subnet CIDR, or ASG—not its public IP—as the workload endpoint in the rule model.

15. Lower number wins, and first match stops

Custom NSG rule priorities range from 100 through 4096. A lower number is evaluated first. Once traffic matches a rule in that NSG, evaluation in that NSG stops.

Consider:

PriorityRuleResult for Web → App TCP 8443
100Allow Web to App TCP 8443Matches and allows; evaluation stops
200Deny Web to App TCP 8443Never evaluated for that flow
4000Deny remaining VirtualNetwork inboundNever evaluated for that flow

Now reverse the first two actions:

PriorityRuleResult
100Deny Web to App TCP 8443Matches and denies immediately
200Allow Web to App TCP 8443Never evaluated

Priority 100 is not “more secure” than priority 200. It is simply earlier. The result depends on the matching conditions and action.

Leave intentional gaps—such as 100, 200, 300, and 4000—so urgent rules can be inserted without renumbering everything. Do not rely on names or portal display order; evaluate the numeric priority and direction.

Two custom rules cannot use the same priority in the same direction within one NSG. Infrastructure as code and review checks should detect accidental conflicts and overly broad shadowed rules.

16. Read the six default rules before trusting segmentation

Azure creates six default rules inside each NSG you create. They are not an invisible NSG attached to every VNet.

Default inbound rules

PriorityNameSourceDestinationProtocol / portAction
65000AllowVNetInBoundVirtualNetworkVirtualNetworkAnyAllow
65001AllowAzureLoadBalancerInBoundAzureLoadBalancerAnyAnyAllow
65500DenyAllInboundAnyAnyAnyDeny

Default outbound rules

PriorityNameSourceDestinationProtocol / portAction
65000AllowVnetOutBoundVirtualNetworkVirtualNetworkAnyAllow
65001AllowInternetOutBoundAnyInternetAnyAllow
65500DenyAllOutBoundAnyAnyAnyDeny

You cannot delete these defaults, but a custom rule at 100–4096 is evaluated first and can override their practical result.

Three corrections matter:

  1. AllowVNetInBound is not least privilege. The VirtualNetwork tag can include peered and connected ranges beyond the local subnet.
  2. AllowInternetOutBound does not create internet connectivity. It permits filtering if a valid route and explicit or legacy outbound mechanism exist. For API versions released after March 31, 2026, subnets created as part of a new VNet default to defaultOutboundAccess=false. Existing VNets are not changed automatically, and older API versions can retain the earlier implicit behavior. Inspect the real subnet and egress design.
  3. AzureLoadBalancer represents platform health-probe traffic, not all customer traffic through a load balancer. Backend data traffic retains the original source context documented for the service.

There is another separate default: Standard public IP frontends are secure by default for inbound traffic until an NSG explicitly permits it. When the frontend belongs to a Standard Load Balancer, the load-balancing rule and the applicable NSG permission are both required. Do not confuse that public-IP behavior with the six default rules that exist only inside an NSG.

17. Understand stateful return traffic

NSGs keep flow state. If a new App-to-Database TCP 1433 connection is allowed, the response packets for that established flow do not require a mirrored Database → App allow rule.

New flow initiation
App 10.40.20.4:52341 → Data 10.40.30.4:1433
NSG rule evaluates and allows

Stateful response
Data 10.40.30.4:1433 → App 10.40.20.4:52341
Return traffic is allowed for the established flow

This does not allow the Database tier to initiate an unrelated new connection back to the App tier. A new reverse-direction flow is evaluated against the applicable rules in its own direction.

Rule changes also affect new connections. Removing an SSH allow rule does not necessarily terminate an existing SSH flow. The session can remain until it closes or its state expires. A test that reuses an old connection can therefore make a new deny look ineffective.

After a rule change:

  1. retain the change timestamp and rule version;
  2. close or distinguish the existing test session;
  3. initiate a genuinely new connection;
  4. test the required allow and prohibited deny cases; and
  5. inspect the matching rule and logs.

Stateful does not mean “automatically secure.” It means return packets for a permitted conversation are tracked.

18. Subnet NSG and NIC NSG evaluation

An NSG can be associated with a subnet, a supported VM NIC, or both.

For inbound traffic, documented processing is:

Source → Subnet NSG → NIC NSG → Guest OS / application

For outbound traffic:

Guest OS / application → NIC NSG → Subnet NSG → Next hop

If both levels apply, every applicable NSG must allow the new flow. A subnet allow cannot override a NIC deny, and a NIC allow cannot override a subnet deny. The first blocking level stops the packet.

The same principle applies to communication between VMs in one subnet. Intra-subnet traffic does not bypass NSG evaluation.

Microsoft recommends avoiding simultaneous subnet and NIC NSGs when one level can express the requirement. Two levels create more places for rules to conflict and more difficult troubleshooting. A beginner-friendly starting model is:

Uniform tier policy → subnet NSG
Exceptional NIC rule → use only with a documented requirement and owner

Do not infer processing from the order in which legacy flow-log records happen to appear. Inspect the aggregate effective rules and both configured scopes.

19. Use service tags, ASGs, and advanced rules without hiding intent

Service tags represent managed IP prefix sets

A service tag such as Storage, AzureLoadBalancer, or VirtualNetwork represents a Microsoft-managed group of IP prefixes. Microsoft updates the addresses so teams do not hardcode a changing list.

A service tag is not:

  • a Microsoft Entra identity;
  • a tenant or subscription boundary;
  • one specific service resource instance;
  • proof that traffic is encrypted or authenticated; or
  • a replacement for the destination service’s firewall, identity, and authorization.

Use a regional tag where the service supports it and the requirement is regional. Avoid broad AzureCloud or VirtualNetwork permissions without understanding their current scope. Service tags simplify IP maintenance; they do not make an overly broad requirement safe.

Application security groups represent NIC roles

An ASG groups VM NICs by workload role, such as asg-web, asg-app, or asg-data. An NSG rule can then express:

Allow asg-web → asg-app TCP 8443
Allow asg-app → asg-data TCP 1433

The rule survives private-IP changes and scale operations as NIC membership changes. ASGs do not group human users, Azure resources of every type, or NICs arbitrarily across VNets. ASG members and ASG-to-ASG rule use must respect the same-VNet constraints.

Augmented rules reduce rule count

An augmented NSG rule can combine multiple explicit IP addresses, CIDR ranges, and port ranges in one rule. Use this when the combined items have the same purpose, owner, action, and lifecycle. Do not compress unrelated exceptions into one unreadable rule merely to reduce count, and do not assume multiple service tags can be mixed arbitrarily in one field.

Central admin rules may be evaluated before local NSGs

In an enterprise managed through Azure Virtual Network Manager, Security Admin Rules can apply before local NSGs. An admin Deny stops traffic, Always Allow can bypass NSG evaluation, and Allow lets evaluation continue to the NSG. If a local NSG appears correct but the result differs, include central admin rules in the evidence review.

Azure platform endpoints require caution

Azure uses host virtual addresses such as 168.63.129.16 and 169.254.169.254 for different platform functions. The former participates in services such as Azure-provided DNS, health probes, DHCP, and VM platform communication; the latter is the non-routable Instance Metadata Service endpoint. Do not add raw-IP denies from an internet threat list without understanding Azure platform dependencies. Dedicated tags such as AzurePlatformDNS, AzurePlatformIMDS, and AzurePlatformLKM exist for specific controls. Denying them can disrupt their named dependencies: Azure-provided DNS, IMDS/managed identity, and Windows licensing. VM Agent WireServer traffic to 168.63.129.16 on TCP 80 and 32526 is not subject to NSGs and must instead remain allowed in the guest firewall.

20. Translate the three-tier intent into learning rules

The following inbound rules illustrate the policy. They assume subnet-level NSGs, the earlier CIDRs, and separate documented flows for management and platform dependencies.

NSGPrioritySourceSource portDestinationDestination portProtocolAction
nsg-web10010.40.0.0/24*10.40.10.0/24443TCPAllow
nsg-web4000VirtualNetwork*10.40.10.0/24*AnyDeny
nsg-app10010.40.10.0/24*10.40.20.0/248443TCPAllow
nsg-app4000VirtualNetwork*10.40.20.0/24*AnyDeny
nsg-data10010.40.20.0/24*10.40.30.0/241433TCPAllow
nsg-data4000VirtualNetwork*10.40.30.0/24*AnyDeny

The allow comes before the remaining connected-network deny. Sources outside VirtualNetwork that do not match another custom allow eventually reach DenyAllInbound at 65500.

An ASG version can replace fixed workload CIDRs with roles:

asg-web → asg-app TCP 8443 Allow
asg-app → asg-data TCP 1433 Allow

The CIDR table is easier for learning, while the ASG form can better express a scaling VM role. The correct choice depends on supported resources and ownership.

This is not a production deployment template. Before the priority-4000 deny, a real design must add narrowly defined rules for approved management, health probes, monitoring, backup, identity, and other documented inbound dependencies. Outbound rules and explicit egress policy also require a separate flow inventory. A broad deny without dependency tests can create an outage; omitting it without understanding AllowVNetInBound can leave unintended lateral paths.

21. Evaluate packets like the NSG

Practice first-match evaluation against the learning rules.

Case A: Edge → Web TCP 443

Source 10.40.0.4, destination 10.40.10.4, TCP 443
→ nsg-web priority 100 matches
→ Allow; stop evaluating nsg-web

Case B: Edge → Web TCP 80

Priority 100 does not match destination port
→ Priority 4000 matches remaining VirtualNetwork inbound
→ Deny

Case C: Web → App TCP 8443

Source 10.40.10.4, destination 10.40.20.4, TCP 8443
→ nsg-app priority 100 matches
→ Allow

Case D: Web → Data TCP 1433

Source is Web, not the allowed App subnet
→ nsg-data priority 100 does not match
→ priority 4000 VirtualNetwork deny matches
→ Deny

This is the critical shortcut test. Without an applicable custom deny, a same-VNet flow might reach default AllowVNetInBound.

Case E: App → Data TCP 1433

nsg-data priority 100 matches
→ Allow

Case F: App → Data TCP 3306

Priority 100 does not match destination port
→ Priority 4000 matches
→ Deny

Case G: Data response to the permitted App request

Response belongs to the established App → Data TCP 1433 flow
→ Stateful return traffic is permitted
→ No mirrored new-flow rule is required

Case H: The allow rule was just removed

Old connection may continue
New connection is evaluated against the changed rules
→ Close or distinguish the old session and test again

For every case, also ask whether a NIC NSG or central admin rule applies. Evaluating only the visually closest subnet NSG is not enough.

22. Prove both allowed and denied paths

Use four evidence layers.

Layer 1: configuration evidence

  • Export the VNet address space and subnet allocations.
  • Confirm the actual NSG-to-subnet and NSG-to-NIC associations.
  • View Effective security rules for each relevant VM NIC; this aggregates subnet, NIC, and applicable central admin rules.
  • View Effective routes and use Network Watcher Next hop to confirm the selected path.

Layer 2: simulated rule decisions

Network Watcher IP flow verify evaluates TCP or UDP direction, local/remote address, and ports against applicable NSG and admin rules. It returns allow or deny and the matching rule. Use NSG diagnostics for ICMP and scenarios such as scale sets that IP flow verify does not cover.

An Allowed result is not an end-to-end application test. It does not prove the route, guest firewall, listener, TLS, identity, or application health.

Layer 3: real positive and negative connections

TestExpected resultEvidence
Edge → Web TCP 443SucceedsApplication request plus matching path evidence
Edge → Web TCP 80FailsNew connection result plus matching deny rule
Web → App TCP 8443Succeedscurl, Test-NetConnection, or approved client test
Web → App TCP 22FailsNew connection result and rule decision
Web → Data TCP 1433FailsShortcut denial evidence
App → Data TCP 1433SucceedsApplication/database handshake evidence
App → Data TCP 3306FailsWrong-port denial evidence
Internet → App/DataFailsExposure inventory, public edge check, and connection result

Test from realistic source NICs. A laptop test outside Azure does not prove Web-to-App segmentation. After rule changes, use new connections.

Layer 4: operating evidence

For new designs, use Virtual Network flow logs where the workload is supported. They record Layer 4 flow metadata such as the five-tuple, direction, state, rule, bytes, and packets to Azure Storage. They do not capture packet payloads and do not support every Azure service.

NSG flow logs can no longer be newly created after June 30, 2025 and are scheduled to retire on September 30, 2027. Existing stored records follow their storage retention, but a new 2026 monitoring design should use Virtual Network flow logs. Avoid duplicate collection and cost by following Microsoft’s migration order when both logging types touch the same workload.

23. Operate changes as policy, not portal memory

Every rule should have:

  • a business or technical purpose;
  • source and destination owner;
  • protocol and port contract;
  • rule priority rationale;
  • creation and review date;
  • ticket or decision reference;
  • positive and negative test;
  • monitoring destination;
  • expiry for temporary exceptions; and
  • rollback procedure.

Use infrastructure as code and policy checks where practical. A portal screenshot can help a reviewer, but it cannot prove current associations, effective rules, or behavior after drift.

Address and subnet checklist

  • The CIDR was checked against Azure, on-premises, DR, other clouds, and vendor networks.
  • Every subnet is inside the VNet address space and does not overlap another subnet.
  • Five Azure-reserved IPv4 addresses are included in capacity calculations.
  • Scale-out, upgrades, failover, private endpoints, and platform services have headroom.
  • Subnets represent role, trust, routing, scale, lifecycle, or service requirements—not arbitrary names.
  • Required dedicated subnet names and current minimum sizes were rechecked.
  • Unallocated ranges and their owner are recorded.

NSG checklist

  • Every NSG association is known at subnet and NIC scope.
  • Rules can be read as source → destination → protocol/port → action.
  • Source ports are not accidentally restricted to server destination ports.
  • Lower-number priorities and first-match shadowing were reviewed.
  • The scope of VirtualNetwork, Internet, and AzureLoadBalancer tags is understood.
  • Required allow rules appear before any broad connected-network deny.
  • Outbound requirements are reviewed instead of relying blindly on AllowInternetOutBound.
  • NIC and subnet NSGs are not combined without a documented reason.
  • Central Security Admin Rules are included when Azure Virtual Network Manager governs the VNet.
  • Temporary Any rules have an owner and automatic or dated removal.

Validation and operations checklist

  • Required paths succeed from the real source.
  • Neighboring forbidden paths fail from the real source.
  • Tests use new connections after rule changes.
  • Effective security rules and effective routes are retained with timestamps.
  • IP flow verify or NSG diagnostics identifies the expected matching rule.
  • Guest firewall, listener, TLS, identity, and application health are tested separately.
  • Virtual Network flow logs, retention, access, cost, and review owner are defined where applicable.
  • Alerts exist for dangerous broad rules, association removal, and unexplained policy changes.
  • Rollback restores the previous known rule set without leaving an emergency allow open.
  • A reassessment trigger covers new peering, address expansion, scale, service, or workload dependencies.

24. Self-review questions and one-minute memory card

Questions

  1. Why does a /24 provide 251 usable Azure IPv4 addresses rather than 254?
  2. Why should connected and future networks be inventoried before choosing a VNet CIDR?
  3. Why does dividing Web and Data into separate subnets not automatically deny Web-to-Data traffic?
  4. What separate questions do an address plan, route, NSG, and application listener answer?
  5. Which five fields form the NSG flow tuple?
  6. If priority 100 denies and priority 200 allows the same flow, which result wins?
  7. Why is an NSG source port commonly * for a client-to-server rule?
  8. Why does a permitted response not require a mirrored rule in a stateful NSG?
  9. Why might an SSH session continue after its allow rule is deleted?
  10. What order applies to subnet and NIC NSGs for inbound and outbound traffic?
  11. How is a service tag different from an ASG?
  12. Why might VirtualNetwork be broader than the current VNet subnet?
  13. What should you inspect when IP flow verify says Allowed but the application still fails?
  14. Why are both positive and negative tests necessary?
  15. Which current flow-log type should a new 2026 design use?

Memory card

Plan the space → separate roles → name every flow
→ allow only the required path → prove both allow and deny.

Address plan = where addresses can exist
Subnet = placement and policy scope, not an automatic wall
Route = where the packet goes next
NSG = whether the L3/L4 flow may pass

Lower number wins.
First match stops.
Return traffic is stateful.
Reconnect after a rule change.

NSG Allowed ≠ application healthy.
Subnet separated ≠ traffic denied.

The final memory line is:

Secure VNet design begins with non-overlapping addresses, turns named application flows into narrowly scoped rules, and proves both what can connect and what cannot.

The next Module 1 detailed note will compare Azure Firewall Basic, Standard, and Premium before later notes examine routing, DNS, rules, logging, and validation. It remains planned until the complete English and Korean article pair is ready; no empty route is linked.

References

Series

Azure Cybersecurity & Microsoft Defender Course Notes

Part 6 of 11. This series collects related build notes so the context is easier to follow later.

  1. 1. Module 1 Review: Azure Basic Security Capabilities
  2. 2. Azure Defense in Depth: Build Security Layers That Still Work When One Fails
  3. 3. Azure DDoS Infrastructure Protection: What the Built-In Baseline Actually Covers
  4. 4. Azure DDoS IP Protection vs. Network Protection: Choose by Scope, Operations, and Cost
  5. 5. Secure an Azure VM Without a Public IP: Separate Management, Inbound, and Outbound Paths
  6. 6. Azure VNet, Subnet, and NSG Fundamentals: Plan Address Space, Read Rules, and Verify Traffic
  7. 7. Azure Firewall Basic vs. Standard vs. Premium: Choose by Traffic, Inspection, and Operations
  8. 8. Azure Firewall UDR and DNS Design: Prove the Traffic Path Before Writing Rules
  9. 9. Module 2 Review: Security Management in Azure
  10. 10. Module 3 Review: Connecting Microsoft Defender Threat Protection Signals
  11. 11. Module 4 Review: Designing and Proving a Layered Azure VM Defense

Related