VNets & Subnets
address space · subnets · reserved IPs · DNS · delegation · default outbound access
By the tools4free.dev team · Last reviewed November 13, 2026
Practice questions for this topic →
Virtual network basics
- A virtual network lives in one region and one subscription. It does span the availability zones of its region. To connect to another subscription's vnet, use peering.
- Anything you connect to a vnet must be in the same region and the same subscription as the vnet.
- The vnet name and the subnet name can't be changed after creation. A vnet name is unique in its resource group; a subnet name is unique in its vnet.
- The address space is one or more non-overlapping CIDR ranges, public or private (RFC 1918). Overlapping ranges between a vnet and another vnet or an on-premises network mean the two can't be connected.
- You can't add these ranges: 224.0.0.0/4 (multicast), 255.255.255.255/32 (broadcast), 127.0.0.0/8 (loopback), 169.254.0.0/16 (link-local) and 168.63.129.16/32 (internal DNS, DHCP and Load Balancer health probe).
- Azure routes between subnets automatically. You don't need route tables or gateways for subnet-to-subnet traffic.
- Multicast, broadcast, IP-in-IP and GRE packets are blocked. Unicast works.
Subnets and addresses
| Item | Value |
|---|---|
| Smallest / largest IPv4 subnet | /29 / /2 |
| IPv6 subnet size | Exactly /64 |
| Reserved addresses per subnet | 5: the first four and the last |
| Example for 192.168.1.0/24 | .0 network address, .1 default gateway, .2 and .3 Azure DNS mapping, .255 broadcast |
| Usable addresses in a /29 | 3 |
| Virtual networks per subscription (per region) | 1,000 |
| Subnets per virtual network | 3,000 |
| Private IP addresses per virtual network | 65,536 |
| DNS servers per virtual network | 20 |
Subnet ranges must sit inside the vnet address space and can't overlap each other. Classic subnetting removes 2 addresses; Azure removes 5.
- A vnet isn't required to have subnets, but a vnet created in the portal needs at least one.
- You can't reserve a private IP for a VM you haven't created yet. You can change the private IP of an existing VM to any available address.
Changing a virtual network
- You can add, extend or shrink address ranges later. You can shrink a range only while it still contains all the subnets in it.
- You can't delete an address range that still contains a subnet. Delete the subnets (and the resources in them) first.
- If the vnet is peered or connected to on-premises, a new range can't overlap the peered vnets' or the on-premises address space. After you resize a peered vnet, sync the peerings.
- You can delete a vnet only when no resources are connected to it (check Connected devices).
- Move (resource group, location or subscription) needs every resource connected to the vnet to move with it. A vnet that's in a peering can't be moved: delete the peering, move, recreate it.
- Permissions: Network Contributor, or a custom role with
Microsoft.Network/virtualNetworks/read,writeanddelete.
DNS
- Azure-provided DNS resolves names only within one vnet. To resolve names across vnets, use a custom DNS server or Azure Private DNS.
- A NIC's own DNS settings override the vnet's.
- Custom DNS servers are an ordered list. Servers are tried in the listed order, not round-robin.
- After you change DNS servers, restart VMs and other resources (for example Azure Firewall and Application Gateway). Running resources keep the old DNS until restarted.
Subnet delegation
- Delegation gives a service permission to create its own resources in the subnet. Example: delegate to
Microsoft.Sql/managedInstances. - Portal: vnet › Subnets › select the subnet › Delegate subnet to a service › Save. Choose None to remove it.
- The delegation action is
Microsoft.Network/virtualNetworks/subnets/join/action. Delegating a subnet you didn't create needsMicrosoft.Network/virtualNetworks/subnets/write, which the built-in Network Contributor role contains. - Delegation is not a service endpoint: a service endpoint only changes how traffic reaches a PaaS service.
Default outbound access
- Default outbound access: a VM with no explicit outbound method gets an outbound public IP automatically. The IP is owned by Microsoft, can change without notice, and doesn't support fragmented packets or ICMP pings.
- The change: for the API released after March 31, 2026, new virtual networks default to private subnets (
defaultOutboundAccess= false). VMs in them need an explicit outbound method to reach public endpoints. Existing vnets aren't changed. Older API versions (for example older ARM templates) keep the earlier default. - Explicit methods: NAT gateway on the subnet (Microsoft's recommended method for most scenarios), a Standard load balancer with outbound rules, a Standard public IP on the VM's NIC, or a firewall or NVA with a UDR. Flexible-orchestration scale set instances always need an explicit method.
- Precedence: 1 NAT gateway, 2 public IP on the VM, 3 load balancer outbound rules, 4 load balancer frontend without outbound rules, 5 default outbound access.
- Make a subnet private: portal Subnets › Default outbound access = Disabled, or CLI
--default-outbound false. Existing VMs must be stopped and deallocated for the change (either direction) to take effect. - Private subnet limits: Windows activation and updates need an explicit egress method. UDR routes with next hop type Internet break. Private subnets don't apply to delegated or managed PaaS subnets. A load balancer backend pool configured by IP address still uses default outbound access (a known issue; use a NAT gateway).
CLI and PowerShell
| Task | Azure CLI | PowerShell |
|---|---|---|
| Create vnet | az network vnet create -g myRG -n myVNet (default space 10.0.0.0/16) | New-AzVirtualNetwork -ResourceGroupName myRG -Name myVNet -Location eastus -AddressPrefix 10.0.0.0/16 |
| Create vnet with first subnet | az network vnet create ... --address-prefix 10.0.0.0/16 --subnet-name subnet-1 --subnet-prefix 10.0.0.0/24 | New-AzVirtualNetworkSubnetConfig, then New-AzVirtualNetwork -Subnet |
| Replace address space | az network vnet update -g myRG -n myVNet --address-prefixes 10.1.0.0/16 (replaces any previous ranges) | Edit $vnet.AddressSpace.AddressPrefixes, then Set-AzVirtualNetwork |
| Set custom DNS | az network vnet update ... --dns-servers 10.0.0.10 | $vnet.DhcpOptions.DnsServers.Add("10.0.0.10"), then Set-AzVirtualNetwork |
| Delegate a subnet | az network vnet subnet update -g rg --vnet-name vnet-1 -n subnet-1 --delegations Microsoft.Sql/managedInstances | Add-AzDelegation, then Set-AzVirtualNetwork |
| Remove delegation | az network vnet subnet update ... --remove delegations | Remove-AzDelegation, then Set-AzVirtualNetwork |
| Make subnet private | az network vnet subnet update --resource-group rgname --name subnetname --vnet-name vnetname --default-outbound false | Set $subnet.DefaultOutboundAccess = $false, then Set-AzVirtualNetwork |
| Delete vnet | az network vnet delete | Remove-AzVirtualNetwork |
Exam Tips
Tick each tip once you can answer it without looking.
“Smallest subnet you can create” → /29 (IPv4). Trap: /30 or /32. Azure's minimum is /29, and 5 of its 8 addresses are reserved.
“Usable IP addresses in a /28 subnet” → 11 (16 minus 5 reserved). Trap: 14, from classic subnetting that removes only 2.
“Which address in a subnet is the default gateway” → The first host address (.1). Trap: Assuming the gateway is .254. The last address is reserved as broadcast, and .2 and .3 map Azure DNS.
“Rename an existing virtual network or subnet” → Not possible: names can't change after creation. Trap: Looking for an edit-name option in the portal Properties.
“Add 10.1.0.0/16 to a vnet that already has a subnet in 10.0.0.0/16” → Add a second address range to the address space. Trap: Recreating the vnet. Nothing needs to be deleted.
“Can't delete an address range from the vnet” → A subnet still exists in that range: delete the subnets (and their resources) first. Trap: Dissociating the NSG. The subnet is what blocks the deletion.
“Add 168.63.129.16/32 or 169.254.0.0/16 as a vnet range” → Not allowed. Trap: Thinking it's allowed because it's a private-looking address.
“NIC of a VM must attach to a vnet in a different region” → Impossible: connected resources must be in the vnet's region and subscription. Trap: Peering lets a NIC use the remote vnet.
“VMs in two vnets must resolve each other's names with Azure-provided DNS” → Not supported: use a custom DNS server or an Azure Private DNS zone. Trap: Assuming peering gives built-in name resolution.
“Changed the vnet's custom DNS, but VMs still use the old servers” → Restart the VMs (or other resources). Trap: Waiting for DHCP to refresh it. The page documents only a restart.
“Two custom DNS servers are listed; the first one is broken” → Clients still try them in listed order, not round-robin. Trap: Assuming automatic failover to the second server.
“Deploy SQL Managed Instance into an existing subnet” → Delegate the subnet to Microsoft.Sql/managedInstances. Trap: Enabling a service endpoint. An endpoint only changes how traffic reaches a PaaS service.
“Delegate a subnet that someone else created” → Microsoft.Network/virtualNetworks/subnets/write (in Network Contributor). Trap: Looking for a role on the service. The permission needed is on the subnet.
“Run a DHCP server or multicast application in a vnet” → Not supported: multicast and broadcast are blocked, unicast only. Trap: Looking for a multicast setting on the vnet.
“New vnet created with an API version after March 31, 2026; VM can't reach the internet” → Subnets are private by default: add an explicit outbound method (NAT gateway is recommended). Trap: Waiting for Azure to assign a default outbound IP, or adding an outbound NSG rule.
“Turn an existing subnet private” → Set Default outbound access to Disabled, then stop and deallocate the VMs. Trap: Restarting the VMs. They must be stopped and deallocated.
“Best outbound method for most scenarios” → NAT gateway on the subnet. Trap: Relying on the default outbound IP, which Microsoft owns and can change without notice.
Sources
- Create, change, or delete an Azure virtual network
- Azure Virtual Network FAQ
- Add or remove subnet delegation
- Default outbound access in Azure
- SNAT for outbound connections
- Azure subscription and service limits
Checked against Microsoft Learn on November 13, 2026.