Azure VNet Design Best Practices: CIDR, Subnets, NSGs
Design Azure VNets with a CIDR plan that survives peering, subnets sized for the services that land in them, and NSGs a team can still read a year later.

On this page
- Build the CIDR Plan Before the First VNet
- The Five Addresses Azure Takes From Every Subnet
- Size Subnets for the Service That Lands in Them
- Create the VNet With the Address Plan in Hand
- Write NSGs You Can Still Read in a Year
- Peer VNets Without Creating an Overlap
- Audit the VNet Before It Grows
- The First Step
An Azure network usually begins with a virtual network, a default address space, and a subnet named something like default. That works until the first on premises connection, the second subscription, or the acquisition that arrives with its own 10.0.0.0/8. By then the VNet has workloads in it, the address space is in use, and the overlap has become a project rather than a decision.
The design work is not complicated, but the order matters. Choose the address plan before the first VNet, size each subnet for the service that will land in it, write NSGs as a small set of named flows rather than a list of addresses, and peer only after you have proved the ranges do not overlap. This guide follows that order and uses the actual Azure limits and the actual CLI commands, so the result can be checked rather than assumed.
Build the CIDR Plan Before the First VNet
The first decision is which private range the organization will use in Azure. The common choices are 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16, plus the shared address space 100.64.0.0/10 that Azure treats as private. The right choice is the one that does not overlap your on premises network, your other clouds, your partners, or the networks you expect to acquire.
Reserve a block large enough to hold every environment and region you might deploy, then carve it into VNets. A useful shape is one /16 per VNet, because Azure lists a limit of 65,536 private IP addresses per VNet and a /16 is exactly 65,536 addresses. A larger prefix is allowed, but it does not give one VNet more usable private addresses, so a /16 is the practical ceiling and a comfortable unit to plan around.
The example assumes on premises uses 10.0.0.0/8 and 192.168.0.0/16, which is why Azure gets a carved block inside 172.16.0.0/12. Substitute your real ranges. The important part is not the numbers, it is that every VNet gets a contiguous block with unused space around it, so a future region or environment can be added without renumbering an existing VNet.
Write the plan down as a table before creating anything. A table that shows the block, the environment, the region, and the owner is enough. The Azure portal will happily create a VNet without it, and that is exactly how two teams end up with the same 10.0.0.0/16 in two subscriptions.
The Five Addresses Azure Takes From Every Subnet
Every Azure subnet loses five addresses before you assign anything. The first address is the network address, the next is reserved for the default gateway, the next two map Azure DNS into the virtual network space, and the last is the broadcast address. A /24 has 256 addresses and 251 usable ones. A /29 has eight addresses and three usable ones.
usable = 2^(32 - prefix length) - 5
The smallest IPv4 subnet Azure supports is /29, and the largest is /2. An IPv6 subnet must be exactly /64. The /29 floor is a trap in two ways. It leaves only three usable addresses, and it looks large enough to hold a gateway until you remember that the gateway subnet needs a /27 for every SKU except Basic. A /29 is a test case, not a production subnet.
The /2 ceiling is equally misleading. Azure allows a very large subnet by CIDR, but the private IP limit per VNet is 65,536, so a /2 subnet does not give one VNet more usable addresses than a /16. If a design document proposes a /8 VNet to avoid thinking about growth, the address plan has been replaced by a wish.
Size Subnets for the Service That Lands in Them
A subnet is not just a size. It is a unit of delegation, routing, and policy. Some Azure services require a dedicated subnet with an exact name and a minimum size, and the service will refuse to deploy if the subnet is too small or shared with something else. The table below covers the services that most often cause a redesign.
| Subnet | Minimum or recommended size | Why | What to avoid |
|---|---|---|---|
GatewaySubnet |
/27 for every non Basic SKU, /29 only for Basic |
Gateway VMs and services need addresses, and coexist configurations need more | Other resources in the subnet, or an NSG on it |
AzureFirewallSubnet |
/26 |
The firewall provisions extra instances as it scales | Sharing the subnet with workloads |
AzureBastionSubnet |
/26 for resources deployed after November 2, 2021 |
Host scaling and service addresses | Treating an old /27 as a template for a new deployment |
| SQL Managed Instance delegation | At least 32 addresses, so /27 or larger |
The service needs a dedicated delegated subnet and management addresses | Reusing the subnet for anything else |
| General application subnet | /24 is a comfortable default |
Room for scale out, load balancer probes, and address churn | A /29 because the first deployment only needed three addresses |
| Private endpoint subnet | One address per endpoint, plus growth | Each private endpoint consumes a private IP | Assuming the endpoints share an address |
Two rules matter more than the table. First, check the service documentation at design time, because minimums and recommendations change. Second, leave room for the service to scale inside the subnet. A firewall that starts with two instances and a /27 can run out of addresses during an incident, which is the worst possible time to discover that the subnet cannot grow while the firewall is deployed.
Create the VNet With the Address Plan in Hand
Create the virtual network from the plan, not from the portal’s default. The command below creates a production VNet with a /16, one application subnet, and the existing nsg-app-prod group, and it uses the names from the example plan.
az network vnet create \
--resource-group rg-net-prod-weu \
--name vnet-prod-weu-01 \
--location westeurope \
--address-prefixes 172.21.0.0/16 \
--subnet-name snet-app \
--subnet-prefixes 172.21.1.0/24 \
--network-security-group nsg-app-prod
Add the service subnets next. The names GatewaySubnet, AzureFirewallSubnet, and AzureBastionSubnet are not cosmetic; Azure looks for those exact names when it deploys the service. The firewall and Bastion subnets also need enough space before the service is created, because resizing a subnet with a deployed service is not always possible.
az network vnet subnet create \
--resource-group rg-net-prod-weu \
--vnet-name vnet-prod-weu-01 \
--name GatewaySubnet \
--address-prefixes 172.21.0.0/27
az network vnet subnet create \
--resource-group rg-net-prod-weu \
--vnet-name vnet-prod-weu-01 \
--name AzureFirewallSubnet \
--address-prefixes 172.21.0.64/26
az network vnet subnet create \
--resource-group rg-net-prod-weu \
--vnet-name vnet-prod-weu-01 \
--name AzureBastionSubnet \
--address-prefixes 172.21.0.128/26
Attach the NSG at subnet creation time when you already know which policy applies, as the snet-app command above does. Attaching it later is possible, but the gap between creation and attachment is a window where the subnet has no NSG at all, and that window is easy to forget during a busy deployment.
Verify the result as a table rather than trusting the command output. The subnet list gives you the name, the prefix, and the NSG ID, which is enough to spot a missing policy or a subnet that landed in the wrong block.
az network vnet subnet list \
--resource-group rg-net-prod-weu \
--vnet-name vnet-prod-weu-01 \
--output json \
| jq -r '.[] | [.name, .addressPrefix, (.networkSecurityGroup.id // "none")] | @tsv'
The output should look like this, with none in the NSG column for the service subnets that do not take one.
snet-app 172.21.1.0/24 /subscriptions/.../networkSecurityGroups/nsg-app-prod
GatewaySubnet 172.21.0.0/27 none
AzureFirewallSubnet 172.21.0.64/26 none
AzureBastionSubnet 172.21.0.128/26 none
Before you hand a specific address to a workload, confirm it is free with az network vnet check-ip-address. The command checks the VNet, not the subnet, so an address can be free in the VNet and still be outside the subnet you intended to use. Read the plan first, then use the check as a confirmation.
Write NSGs You Can Still Read in a Year
An NSG is a list of rules evaluated in priority order. Lower numbers are processed first, the first match stops evaluation, and the default rules sit at the bottom with the highest priority numbers. The default inbound rules allow traffic from the virtual network and from the Azure load balancer, then deny everything else. The default outbound rules allow the virtual network and the internet, then deny everything else. You cannot delete the defaults, but you can override them with higher priority rules.
The rule properties that matter in a review are source, destination, protocol, port, direction, action, and priority. A rule that uses Any for all four of source, destination, protocol, and port is not a policy, it is an accident waiting for a name. Service tags and application security groups let you write rules that survive an address change, and they make the intent readable without a lookup table.
| Priority | Direction | Source | Destination | Port | Action | Purpose |
|---|---|---|---|---|---|---|
| 100 | Inbound | Internet | 172.21.1.0/24 |
443 | Allow | Public HTTPS through the load balancer |
| 110 | Inbound | AzureLoadBalancer |
172.21.1.0/24 |
Any | Allow | Health probes from the platform |
| 120 | Inbound | 172.21.1.0/24 |
172.21.2.0/24 |
5432 | Allow | Application to PostgreSQL |
| 130 | Inbound | 172.21.0.128/26 |
172.21.4.0/24 |
22 | Allow | Operator access through Bastion |
| 4096 | Inbound | Any | Any | Any | Deny | Documentation of the intended default |
Priority 4096 is optional because the platform already denies at 65500. It is still useful when a reviewer opens the NSG and wants to see the intended end state without reading the default rules. The more important habit is naming the rule after the flow and the owner, not after the ticket that created it.
The table uses CIDRs so the example is concrete. In a real NSG, application security groups are usually a better unit than a subnet prefix, because a workload can move to another subnet without a rule change, and the rule keeps saying “web tier to database tier” instead of naming an address range that will eventually be wrong.
Inbound traffic is evaluated by the subnet NSG first and then the NIC NSG. Outbound traffic is evaluated by the NIC NSG first and then the subnet NSG. That order matters when you troubleshoot: a denied connection can be blocked at either layer, and the effective rules are the only way to see the combined result. The platform is stateful, so an allowed outbound connection does not need a matching inbound rule for the return traffic.
Two Azure specific traps are worth writing into the design. An NSG on GatewaySubnet is not supported, and a user defined route with a 0.0.0.0/0 destination on that subnet is also not supported, because the gateway needs a management path that those controls would break. The AzureFirewallSubnet is managed by the service, and a subnet level NSG on it is disabled to prevent interruptions. Do not design a policy that assumes either subnet behaves like a workload subnet.
Read the rules back with the CLI before you call the policy done. The list gives you the priority order, and the effective rules on a NIC give you what the platform will actually apply after combining the subnet and NIC groups.
az network nsg rule list \
--resource-group rg-net-prod-weu \
--nsg-name nsg-app-prod \
--query "[].[priority,direction,access,protocol,sourceAddressPrefix,destinationAddressPrefix,destinationPortRange]" \
--output tsv
az network nic list-effective-nsg \
--resource-group rg-net-prod-weu \
--name vm-app-01-nic
The effective rule response nests the rules under value[].effectiveSecurityRules in current CLI versions, but confirm the wrapper for your version before you parse it. The important number is not the rule count, it is the number of rules that a new engineer has to read before they can explain why a connection is allowed. If that number is above a few dozen, the policy is probably expressing addresses where it should be expressing services.
Peer VNets Without Creating an Overlap
Peering connects two VNets and keeps the traffic on the Microsoft backbone. It requires nonoverlapping address spaces, it is not transitive, and it must be configured in both directions before the state becomes Connected. A peering that is Initiated is a one sided link, and a peering that is Disconnected is a link where one side was deleted. Both are common causes of a connectivity ticket that looks like a routing problem.
A hub and spoke design puts shared services, the gateway, the firewall, and Bastion in the hub, then peers each spoke to the hub. Spokes do not talk to each other through the peering itself. If they need to, you route through a network virtual appliance or Azure Firewall in the hub with a user defined route, or you add a direct peering between the two spokes. The first option is usually the one that keeps policy in one place.
Create the peering from each side with the full remote VNet ID when the two VNets are in different subscriptions or resource groups. Add the gateway transit flags only when the spoke is meant to use the hub gateway, and remember that only one peering can use a remote gateway from a given VNet.
az network vnet peering create \
--resource-group rg-net-hub-weu \
--vnet-name vnet-hub-weu-01 \
--name hub-to-prod \
--remote-vnet /subscriptions/<sub>/resourceGroups/rg-net-prod-weu/providers/Microsoft.Network/virtualNetworks/vnet-prod-weu-01 \
--allow-vnet-access \
--allow-forwarded-traffic
Check the state with az network vnet peering list and confirm both sides show Connected before you move on. The limits are worth knowing before the topology grows. Azure lists 650 peerings per virtual network, 65,536 private IP addresses per VNet, and 128,000 private addresses for a group of peered VNets. If the design needs more spokes than direct peering can comfortably manage, Azure Virtual Network Manager connectivity configurations can push the hub and spoke model further, with published support for 1,000 spokes per hub and 3,000 VNets in a mesh. Verify those numbers against the current documentation before you commit a design to them.
Audit the VNet Before It Grows
An Azure network accumulates drift in the same way a physical one does. A subnet gets a new NSG, a peering is created in one direction and never completed, a /29 is added for a test and then used for a service, and nobody updates the address plan. The audit is a dated snapshot of the objects that define the network, followed by a short list of findings.
export STAMP=2026-10-29
mkdir -p "audit/${STAMP}"
az network vnet list --output json > "audit/${STAMP}/vnets.json"
az network nsg list --output json > "audit/${STAMP}/nsgs.json"
az network vnet list \
--query "[].[name,resourceGroup,join(',',addressSpace.addressPrefixes),length(subnets)]" \
--output tsv > "audit/${STAMP}/vnets.tsv"
az network vnet list \
--query "[].[name,resourceGroup]" \
--output tsv \
| while IFS=$'\t' read -r name rg; do
az network vnet peering list \
--resource-group "$rg" \
--vnet-name "$name" \
--output json > "audit/${STAMP}/peering-${name}.json"
done
The TSV file is the flat inventory: one row per VNet with the address space joined into a single field and the subnet count at the end. It is the shape you want for a diff between two audits. Then list the subnets and flag the ones without an NSG. A service subnet may legitimately have no NSG, but a workload subnet without one is a finding until the owner explains why.
az network vnet list --output json \
| jq -r '.[] | .subnets[]?
| select(.networkSecurityGroup == null)
| [.name, .addressPrefix] | @tsv'
Overlap is the check that matters most before a peering. Two VNets can coexist with the same range as long as they are not connected, so the audit should report the overlap as a potential blocker rather than as an automatic failure.
python3 - <<'PY'
import ipaddress, json, os
nets = [(ipaddress.ip_network(p), v["name"])
for v in json.load(open(f"audit/{os.environ['STAMP']}/vnets.json"))
for p in v["addressSpace"]["addressPrefixes"]]
for i, (a, an) in enumerate(nets):
for b, bn in nets[i + 1:]:
if a.overlaps(b):
print(an, bn, a, b, sep="\t")
PY
The output is a worklist, not a verdict. A pair of overlapping VNets that will never be peered may be fine. A pair that is already peered and overlapping is a routing incident waiting to happen. The same list is the input to the next peer request, because the request should be rejected before it reaches the portal if the ranges collide.
Finally, compare the Azure inventory with the IP address management plan your team maintains. The point is to catch a subnet that exists in the cloud but not in the plan, or a planned subnet that was never created. A short comm over the CIDRs is enough to start the conversation. The Obelinf subnet list returns the documented CIDRs, and the Azure query returns what is actually deployed.
export STAMP=2026-10-29
export OBELINF_ORG="acme-netops"
export OBELINF_API_KEY="your_read_only_key"
curl --fail --silent --show-error \
-H "Authorization: Bearer ${OBELINF_API_KEY}" \
"https://api.obelinf.com/${OBELINF_ORG}/subnets?all=true" \
| jq -r '.subnets[].cidr' | sort -u > "audit/${STAMP}/documented-cidrs.txt"
az network vnet list --output json \
| jq -r '.[] | .subnets[]?.addressPrefix' | sort -u > "audit/${STAMP}/azure-cidrs.txt"
comm -3 "audit/${STAMP}/documented-cidrs.txt" "audit/${STAMP}/azure-cidrs.txt"
The left column is documented but missing from Azure. The right column is in Azure but missing from the plan. Neither column is automatically wrong, but every line needs an owner and a decision. That is the difference between a cloud network that is documented and one that is merely deployed.
The First Step
Before creating the next VNet, write down the block it will use and the block it will never overlap. Then check the existing VNets against that block with the az network vnet list query, not with memory. If the range is clear, create the VNet with the /16 and the service subnets in one pass, attach the NSGs at creation time, and add the peerings in both directions on the same day.
The design will still change. Regions get added, services get replaced, and a subnet that was sized for a proof of concept becomes production. The plan survives those changes when it is written down, when the NSGs describe flows rather than addresses, and when the audit is a scheduled diff instead of a scramble after an outage. Azure gives you the limits and the CLI; the discipline of checking them before the first deployment is the part that keeps the network readable.
Frequently Asked Questions
What is the smallest subnet Azure supports?
How many IP addresses does Azure reserve in a subnet?
Can two Azure VNets have overlapping address spaces?
What is the maximum number of private IP addresses in an Azure VNet?
Do Azure NSGs apply to subnets or network interfaces?
What size should the GatewaySubnet be?
Stop reaching for a spreadsheet
Obelinf keeps every subnet, device, circuit, and rack in one live source of truth, with audit logs and a topology view. Free for personal use.
Related Articles

Reverse DNS and PTR Hygiene: Keeping DNS in Sync with IPAM
Build reverse zones that match your address plan, prove forward confirmed reverse DNS, and run a PTR audit that keeps DNS and IPAM from drifting apart.
Read more
ASN Planning for Multi-Site Networks
How to decide between one ASN and many, allocate prefixes that summarize cleanly, build the internal control plane, and verify a site's announcements before it leaks a route.
Read more
How to Register an ASN: RIR Application Walkthrough
A step by step ASN application walkthrough for ARIN, RIPE NCC, APNIC, LACNIC, and AFRINIC: the dossier to build, the fees and turnaround, and the commands that prove the assignment is live.
Read more