Overview and What You Will Learn
An Azure Virtual Network (VNet) is your own private network in Azure, defined by one or more CIDR address ranges and divided into subnets, typically one per application tier. In this lab, you will build a three-tier VNet, see Azure's reserved addresses in action, trigger an overlap error on purpose, and add extra address space to an existing VNet.
Why This Matters in Production
The ranges you pick on day one are hard to change once other networks depend on them. Imagine a platform team at a company like Cloudflare that creates a VNet with 10.0.0.0/16 because it was the first range that came to mind. A year later it needs to peer that VNet with another team's VNet and connect it to an on-premises network that uses the same range. Overlapping ranges cannot be peered or joined by VPN, so fixing it means re-addressing every resource.
Core Principles
A VNet is regional, and its subnets span every availability zone in that region. Each subnet is its own boundary for Network Security Group rules and routing, so putting web, application, and data tiers in separate subnets is what lets you apply different security rules to each.
10.0.1.0/24] -->|API calls| A[subnet-app
10.0.2.0/24] A -->|SQL| D[(subnet-data
10.0.3.0/24)] end classDef user fill:#8B5CF6,color:#FFFFFF classDef web fill:#326CE5,color:#FFFFFF classDef app fill:#F97316,color:#FFFFFF classDef data fill:#10B981,color:#FFFFFF class U user class W web class A app class D data
Azure reserves five addresses in every subnet, so the usable count is always the total minus five:
- x.0 is the network address.
- x.1 is the default gateway.
- x.2 and x.3 are mapped to Azure DNS.
- The last address is the broadcast address.
| Subnet size | Total addresses | Usable addresses |
|---|---|---|
| /29 (smallest allowed) | 8 | 3 |
| /27 | 32 | 27 |
| /24 | 256 | 251 |
Plan address space as one organization-wide table, not VNet by VNet. Use the private ranges 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16, and give every network a range that overlaps with no other.
| Network | Range | Purpose |
|---|---|---|
| Production VNet | 10.10.0.0/16 | Live workloads |
| Development VNet | 10.20.0.0/16 | Test workloads |
| On-premises | 192.168.0.0/16 | Office and datacenter |
RememberSome subnets must use a fixed name and a minimum size, such as
GatewaySubnetfor VPN gateways andAzureBastionSubnetwith a /26 or larger for Bastion. Leave room in your plan for them.
Detailed Step-by-Step Practical Lab
How to Create a VNet With a First Subnet
export RG="rg-vnet-lab-mumbai" az group create --name $RG --location centralindia az network vnet create \ --resource-group $RG \ --name vnet-lab \ --address-prefixes 10.0.0.0/16 \ --subnet-name subnet-web \ --subnet-prefixes 10.0.1.0/24How to Add Application and Data Subnets
az network vnet subnet create \ --resource-group $RG \ --vnet-name vnet-lab \ --name subnet-app \ --address-prefixes 10.0.2.0/24 az network vnet subnet create \ --resource-group $RG \ --vnet-name vnet-lab \ --name subnet-data \ --address-prefixes 10.0.3.0/24How to List Subnets and Their Ranges
az network vnet subnet list \ --resource-group $RG \ --vnet-name vnet-lab \ --query "[].[name, addressPrefix]" \ --output tableHow to See Azure's Reserved IP Addresses
Create a network interface in the app subnet and look at the address it receives. It is 10.0.2.4, not 10.0.2.1, because the first four addresses are reserved.
az network nic create \ --resource-group $RG \ --name nic-reserved-demo \ --vnet-name vnet-lab \ --subnet subnet-app az network nic show \ --resource-group $RG \ --name nic-reserved-demo \ --query "ipConfigurations[0].privateIPAddress" --output tsvHow to Trigger an Overlapping Subnet Error
Subnets inside a VNet cannot overlap. This range sits inside the existing web subnet, so Azure rejects it.
az network vnet subnet create \ --resource-group $RG \ --vnet-name vnet-lab \ --name subnet-overlap \ --address-prefixes 10.0.1.128/25# Expected: fails with a subnet range overlap errorHow to Add More Address Space to an Existing VNet
A VNet's address space is not frozen. You can add ranges and create new subnets in them. Pass the full list of prefixes, including the existing one, because the command replaces the list.
az network vnet update \ --resource-group $RG \ --name vnet-lab \ --address-prefixes 10.0.0.0/16 10.1.0.0/16 az network vnet subnet create \ --resource-group $RG \ --vnet-name vnet-lab \ --name subnet-new \ --address-prefixes 10.1.0.0/24 az network vnet show \ --resource-group $RG \ --name vnet-lab \ --query "addressSpace.addressPrefixes" --output tsvRememberIf the VNet is peered with another VNet, sync the peering after changing its address space. Use
az network vnet peering syncso the peer learns about the new range.
How to Clean Up
az group delete --name $RG --yes --no-waitProduction Best Practices & Common Pitfalls
Common MistakeChoosing a range without checking it against every other network you will ever connect. Overlapping ranges block VNet peering and VPN or ExpressRoute connections, and the only fix is moving resources to new addresses.
TipSize generously, but allocate from one central plan. Unused address space in a VNet costs nothing, yet 10.0.0.0/8 holds only 256 /16 ranges, so giving every VNet a /16 runs out quickly in a large organization.
- Add address space instead of rebuilding. If a VNet runs short, add another range and new subnets, as in this lab. You do not need to rebuild the VNet.
- Be careful resizing subnets that hold resources. Changing the range of a subnet with deployed resources is restricted, so size each subnet for its future needs.
- Separate subnets by tier, not by convenience. Web, application, and data tiers in separate subnets let you apply different Network Security Group rules to each.
- Account for the five reserved addresses. A /29 gives only three usable addresses, which is too small for most services.
- Give hungry services large subnets. Kubernetes with Azure CNI assigns a VNet IP to every pod, so a node subnet can need far more addresses than the VM count suggests.
- Plan for outbound access. Newer subnets may have no default internet access, so use a NAT gateway or explicit public IPs for VMs that must reach the internet.
Quick Reference & Troubleshooting Commands
| Command | Description |
|---|---|
az network vnet create |
Create a Virtual Network with an initial subnet |
az network vnet subnet create |
Add another subnet to an existing VNet |
az network vnet subnet list |
List subnets and their ranges |
az network vnet update --address-prefixes |
Set the full list of address ranges |
az network vnet show --query "addressSpace" |
Check a VNet's configured address space |
az network vnet peering sync |
Refresh a peering after an address space change |