Skip to main content

Designing Azure Virtual Networks and Subnets

Plan Azure VNet and subnet CIDR ranges that avoid overlaps, size subnets after Azure's 5 reserved IPs, and add address space later. CLI lab included.

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.

flowchart TD U([Users]) -->|HTTPS| W subgraph VNET["vnet-lab 10.0.0.0/16"] W[subnet-web
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:

  1. x.0 is the network address.
  2. x.1 is the default gateway.
  3. x.2 and x.3 are mapped to Azure DNS.
  4. 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
Remember

Some subnets must use a fixed name and a minimum size, such as GatewaySubnet for VPN gateways and AzureBastionSubnet with 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
Bash
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/24
How to Add Application and Data Subnets
Bash
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/24
How to List Subnets and Their Ranges
Bash
az network vnet subnet list \
--resource-group $RG \
--vnet-name vnet-lab \
--query "[].[name, addressPrefix]" \
--output table
How 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.

Bash
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 tsv
How to Trigger an Overlapping Subnet Error

Subnets inside a VNet cannot overlap. This range sits inside the existing web subnet, so Azure rejects it.

Bash
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 error
How 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.

Bash
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 tsv
Remember

If the VNet is peered with another VNet, sync the peering after changing its address space. Use az network vnet peering sync so the peer learns about the new range.

How to Clean Up
Bash
az group delete --name $RG --yes --no-wait

Production Best Practices & Common Pitfalls

Common Mistake

Choosing 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.

Tip

Size 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

Explore More in Azure Networking and Traffic Management

All 6 Topics

Frequently Asked Questions

Is Designing Azure Virtual Networks and Subnets free to learn on DevOps Network?

Yes - this topic, like everything on DevOps Network, is 100% free with no paywall or sign-up gate.

What does the Designing Azure Virtual Networks and Subnets topic cover?

Plan Azure VNet and subnet CIDR ranges that avoid overlaps, size subnets after Azure's 5 reserved IPs, and add address space later. CLI lab included.

Found a mistake, an outdated step or a broken link?