Manage IP Addressing in Azure Virtual Network Subnets

Address Space in Azure Virtual Network

Use Case: Calculating IP addresses range to assign private IPs to Azure VMs

Example: Assigning 9 IPs to 9 VMs

Taking IP address range from 10.0.0.0

In Azure 5 IPs are reserved by default. So now the total required IPs are 9+5 = 14 IPs

So, if we take address space 10.0.0.0/28. There are 4 host bits. Using 4 host bits we will get 16 IPs (2 power 4 = 16).

Then IP Address range will be from 10.0.0.0 to 10.0.0.15

In this 10.0.0.0, 10.0.0.1, 10.0.0.2, 10.0.0.3 and 10.0.0.15 IP address are used for Azure

Remaining IPs from 10.0.0.4 to 10.0.0.12 are assigned to VMs

There will be 2 IPs left. 10.0.0.13 and 10.0.0.14 used for further if necessary.


Use Case: Calculating IP addresses ranges to assign to a different group

Example: Assigning 9 IPs to 3 different departments where each department has 3 VMs

Taking IP address from 10.0.0.0

In Azure 5 IPs are reserved.

So for 3 different departments I will take 3 subnets. Now each subnet should have 5 Azure reserved IPs and 3 VM IPs.

So, for this 10.0.0.0/29 is best where we get 8 IP address.

1st subnet – 10.0.0.0/29

  • Address range : 10.0.0.0 to 10.0.0.7
  • Azure reserved: 10.0.0.0, 10.0.0.1, 10.0.0.2, 10.0.0.3 and 10.0.0.7
  • Usable IPs: 10.0.0.4, 10.0.0.5, 10.0.0.6
  • Usable IPs Count: 3

2nd subnet – 10.0.0.8/29

  • Address range : 10.0.0.8 to 10.0.0.15
  • Azure reserved: 10.0.0.8, 10.0.0.9, 10.0.0.10, 10.0.0.11 and 10.0.0.15
  • Usable IPs: 10.0.0.12, 10.0.0.13, 10.0.0.14
  • Usable IPs Count: 3

3rd subnet – 10.0.0.16/29

  • Address range : 10.0.0.16 to 10.0.0.23
  • Azure reserved: 10.0.0.16, 10.0.0.17, 10.0.0.18, 10.0.0.19 and 10.0.0.23
  • Usable IPs: 10.0.0.20, 10.0.0.21, 10.0.0.22
  • Usable IPs Count: 3

Note: The following address ranges you cannot add into azure virtual network

  • 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)
  • 168.63.129.16/32 (Internal DNS)

Important Point : Subnet ranges cannot be updated or deleted when the azure subnets services are in use.

Example: Failed to delete subnet 'AzureBastionSubnet'. Error: Subnet AzureBastionSubnet is in use by CloudRG/providers/Microsoft.Network/bastionHosts/CloudRG-vnet-bastion/bastionHostIpConfigurations/IpConf'>CloudRG-vnet-bastion/IpConf and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet.