Gateway Subnet in Azure Virtual Networks

The Gateway Subnet is a special subnet in your virtual network (VNet) that you dedicate to host your VPN gateways and ExpressRoute gateways. When you deploy a gateway, you must specify this subnet. Azure uses this subnet to manage the gateway resources.

Purpose and Requirements

The Gateway Subnet serves a critical role in enabling connectivity to your Azure VNet from on-premises networks or other Azure VNets. Here are the key requirements and considerations:

Creating a Gateway Subnet

You can create the Gateway Subnet either during VNet creation or by adding it to an existing VNet. Here's a general outline:

Using Azure Portal

  1. Navigate to your virtual network in the Azure portal.
  2. Under "Settings", select "Subnets".
  3. Click "+ Gateway subnet".
  4. Azure will pre-populate the name as GatewaySubnet.
  5. Define the address range for the Gateway Subnet (e.g., 10.0.4.0/27).
  6. Click "Save".

Using Azure CLI


az network vnet subnet create \
  --address-prefixes <your-gateway-subnet-cidr> \
  --name GatewaySubnet \
  --resource-group <your-resource-group-name> \
  --vnet-name <your-vnet-name>
        

Using Azure PowerShell


$vnet = Get-AzVirtualNetwork -Name <your-vnet-name> -ResourceGroupName <your-resource-group-name>
Add-AzVirtualNetworkSubnetConfig -Name "GatewaySubnet" -AddressPrefix <your-gateway-subnet-cidr> -VirtualNetwork $vnet
Set-AzVirtualNetwork -VirtualNetwork $vnet
        

Gateway Subnet Size Recommendations

The required size of the Gateway Subnet depends on the type of gateway you deploy and its configuration. Here are general recommendations:

Gateway Type Minimum Recommended CIDR Notes
VPN Gateway (Basic, VpnGw1-VpnGw5, VpnGw1AZ-VpnGw5AZ) /27 A /27 provides 32 IP addresses.
ExpressRoute Gateway /28 A /28 provides 16 IP addresses. For larger configurations or potential future scaling, consider /27.
VNet-to-VNet Gateway /27 Similar to VPN Gateways.
Note: Always refer to the latest Azure documentation for the most up-to-date sizing recommendations, as these can change with new service updates.

Common Pitfalls and Best Practices

Tip: When planning your VNet address space, reserve a contiguous block for the Gateway Subnet and other critical infrastructure subnets early in the design process.

Understanding and correctly configuring the Gateway Subnet is fundamental to successfully implementing VPN or ExpressRoute connectivity for your Azure resources.