Hub-and-spoke network design

A hub-and-spoke network puts the shared services (firewall, VPN or ExpressRoute gateway, Bastion, DNS) in one central VNet called the hub, and gives each application or team its own VNet, a spoke, connected to that hub. Most enterprises lay out Azure this way, and Phase 3 builds on it one lesson at a time.

You make the design decisions once and then live with them for years: the IP plan, what goes in the hub, and how spokes talk to each other and to on-premises. If you get the IP plan wrong, you could be renumbering production networks two years down the line.

In this lesson you’ll plan the address space and check it for overlaps with a script, then deploy the hub and two spokes with Bicep, and catch the two mistakes that break hub-and-spoke designs before anything is even connected.

TimeYou needCostBy the end you can
About 40 minutesThe CLI, Bicep, PowerShellNo cost: virtual networks and subnets are free; you pay for what you put in them laterPlan a hub-and-spoke IP space, check it for overlaps, and deploy it as code

What it is, in one line

In a hub-and-spoke network, shared network services live in a central hub VNet and every workload VNet connects only to that hub.

In Simple Words

A city bus station

Picture a city with one central bus station that has the ticket office, the security check and all the long-distance coaches. Each neighbourhood has its own little bus stop, linked to the station by its own road.

To get from one neighbourhood to another you go through the station, where security can check you. The station is the hub and the neighbourhoods are the spokes.

If two neighbourhoods use the same street names, the buses get confused. That’s an overlapping address range, and it’s the first thing you have to avoid.

Engineer's View

Hub-and-spoke design rules

  • Hub: holds the GatewaySubnet (VPN or ExpressRoute gateway, /27 or larger), AzureFirewallSubnet (/26) and AzureBastionSubnet (/26), plus subnets for shared services such as DNS resolvers or domain controllers.
  • Spokes: one per app, environment or team, each peered to the hub (Lesson 46). Spokes don’t peer with each other, so their traffic goes through the hub firewall instead (Lessons 47 and 48).
  • IP plan: ranges must not overlap anywhere across Azure, on-premises and partners, because peering and VPN routing fail when they do. Leave room to grow; a /16 per hub or spoke is common in labs, while enterprises often carve smaller spokes out of a larger block.
  • Reserved addresses: Azure holds back 5 addresses in each subnet (the first four and the last one), which leaves 27 usable in a /27, 59 in a /26 and 251 in a /24.
  • Alternatives: Azure Virtual WAN gives you Microsoft-managed hubs for lots of branches and regions, and Azure Virtual Network Manager can create and manage hub-and-spoke connectivity and security rules at scale.
  • Course plan: the hub is 10.40.0.0/16, the spokes are 10.41.0.0/16 and 10.42.0.0/16, vnet-saat stays on 10.30.0.0/16, and the simulated on-premises network uses 10.80.0.0/16.

How it works, step by step

Here’s how a packet from spoke 1 gets to spoke 2 once the design is finished (you’ll build it over the next few lessons):

Hub-and-spoke network: spoke to spoke traffic through the hub firewall
  1. A VM in vnet-spoke1 (10.41.1.4) sends to 10.42.1.4 in vnet-spoke2.
  2. A route table on its subnet sends 10.42.0.0/16 to the private IP of the hub firewall (Lesson 47).
  3. The packet crosses the peering into the hub and arrives at Azure Firewall.
  4. The firewall checks its rules (Lesson 48) and, if the traffic is allowed, forwards it over the hub-to-spoke2 peering.
  5. The reply comes back along the same path, so the firewall sees both directions.

Traffic to on-premises takes the same route through the hub’s gateway (Lesson 49), and internet traffic goes out through the firewall, which gives you one place to inspect, log and control it all.

Hub-and-spoke network hub subnets and their usable addresses

Peering isn’t transitive. Spoke 1 being peered to the hub and spoke 2 being peered to the hub doesn’t mean spoke 1 can reach spoke 2, and that’s by design.

Hands-on lab: build a hub-and-spoke network with Bicep

Before you run any command, double-check it

Read every command twice before you press Enter. Check the target: the system or account, the IDs, the names and the sizes. These commands are for learning and were tested in our lab, not on your system. At work, run the read-only list commands first, follow your change process, make sure a backup exists, and ask a second person to check anything that changes or deletes data. You run them at your own risk.

Make a folder and save the IP plan checker in it:

New-Item -ItemType Directory -Path C:\azure-lab\hub -Force | Out-Null
Set-Location C:\azure-lab\hub
$t = @'
param([Parameter(Mandatory)][hashtable]$Plan)
function ConvertTo-Range([string]$Cidr) {
    $ip, $bits = $Cidr.Split('/')
    $b = ([Net.IPAddress]::Parse($ip)).GetAddressBytes(); [Array]::Reverse($b)
    $start = [BitConverter]::ToUInt32($b, 0)
    $size = [int64][math]::Pow(2, 32 - [int]$bits)
    [pscustomobject]@{ Start = [double]$start; End = [double]$start + $size - 1; Size = $size }
}
function ConvertTo-Ip([double]$n) {
    $b = [BitConverter]::GetBytes([uint32]$n); [Array]::Reverse($b); ([Net.IPAddress]::new($b)).ToString()
}
$rows = foreach ($name in ($Plan.Keys | Sort-Object)) {
    $r = ConvertTo-Range $Plan[$name]
    [pscustomobject]@{ Network = $name; Prefix = $Plan[$name]; First = ConvertTo-Ip $r.Start; Last = ConvertTo-Ip $r.End; Addresses = $r.Size; S = $r.Start; E = $r.End }
}
$rows | Select-Object Network, Prefix, First, Last, Addresses | Format-Table -AutoSize | Out-String -Width 150 | ForEach-Object { $_.Trim() }
$clash = for ($i = 0; $i -lt $rows.Count; $i++) { for ($j = $i + 1; $j -lt $rows.Count; $j++) {
    if ($rows[$i].S -le $rows[$j].E -and $rows[$j].S -le $rows[$i].E) { "OVERLAP: $($rows[$i].Network) $($rows[$i].Prefix) and $($rows[$j].Network) $($rows[$j].Prefix)" } } }
if ($clash) { $clash } else { 'No overlaps.' }
'@
Set-Content -Path C:\azure-lab\Test-IpPlan.ps1 -Value $t

1Check the course IP plan

Run the checker against every network the course is going to use:

C:\azure-lab\Test-IpPlan.ps1 -Plan @{ 'vnet-saat'='10.30.0.0/16'; 'vnet-hub'='10.40.0.0/16'; 'vnet-spoke1'='10.41.0.0/16'; 'vnet-spoke2'='10.42.0.0/16'; 'vnet-onprem'='10.80.0.0/16' }

You should see this:

Network     Prefix       First     Last          Addresses
-------     ------       -----     ----          ---------
vnet-hub    10.40.0.0/16 10.40.0.0 10.40.255.255     65536
vnet-onprem 10.80.0.0/16 10.80.0.0 10.80.255.255     65536
vnet-saat   10.30.0.0/16 10.30.0.0 10.30.255.255     65536
vnet-spoke1 10.41.0.0/16 10.41.0.0 10.41.255.255     65536
vnet-spoke2 10.42.0.0/16 10.42.0.0 10.42.255.255     65536
No overlaps.

2Check the hub’s subnets

You can use the same script for the subnets inside one VNet:

C:\azure-lab\Test-IpPlan.ps1 -Plan @{ 'GatewaySubnet'='10.40.0.0/27'; 'AzureFirewallSubnet'='10.40.1.0/26'; 'AzureBastionSubnet'='10.40.2.0/26'; 'snet-shared'='10.40.10.0/24' }

You should see this:

Network             Prefix        First      Last         Addresses
-------             ------        -----      ----         ---------
AzureBastionSubnet  10.40.2.0/26  10.40.2.0  10.40.2.63          64
AzureFirewallSubnet 10.40.1.0/26  10.40.1.0  10.40.1.63          64
GatewaySubnet       10.40.0.0/27  10.40.0.0  10.40.0.31          32
snet-shared         10.40.10.0/24 10.40.10.0 10.40.10.255       256
No overlaps.

Subtract 5 from each for Azure’s reserved addresses, which leaves 59, 59, 27 and 251 usable. The gaps between them (10.40.3.0 to 10.40.9.255) give you room to grow.

3Write the hub and spokes in Bicep

Save hub.bicep and build it:

$b = @'
@description('Azure region for all networks')
param location string = resourceGroup().location

@description('Spoke networks: name, address space and app subnet')
param spokes array = [
  {
    name: 'vnet-spoke1'
    prefix: '10.41.0.0/16'
    appSubnet: '10.41.1.0/24'
  }
  {
    name: 'vnet-spoke2'
    prefix: '10.42.0.0/16'
    appSubnet: '10.42.1.0/24'
  }
]

var tags = {
  course: 'saatvedha-azure'
  lesson: '45'
  keep: 'true'
}

resource hub 'Microsoft.Network/virtualNetworks@2024-05-01' = {
  name: 'vnet-hub'
  location: location
  tags: tags
  properties: {
    addressSpace: {
      addressPrefixes: [
        '10.40.0.0/16'
      ]
    }
    subnets: [
      {
        name: 'GatewaySubnet'
        properties: {
          addressPrefix: '10.40.0.0/27'
        }
      }
      {
        name: 'AzureFirewallSubnet'
        properties: {
          addressPrefix: '10.40.1.0/26'
        }
      }
      {
        name: 'AzureBastionSubnet'
        properties: {
          addressPrefix: '10.40.2.0/26'
        }
      }
      {
        name: 'snet-shared'
        properties: {
          addressPrefix: '10.40.10.0/24'
          defaultOutboundAccess: false
        }
      }
    ]
  }
}

resource spokeVnets 'Microsoft.Network/virtualNetworks@2024-05-01' = [for s in spokes: {
  name: s.name
  location: location
  tags: tags
  properties: {
    addressSpace: {
      addressPrefixes: [
        s.prefix
      ]
    }
    subnets: [
      {
        name: 'snet-app'
        properties: {
          addressPrefix: s.appSubnet
          defaultOutboundAccess: false
        }
      }
    ]
  }
}]

output hubId string = hub.id
output spokeIds array = [for (s, i) in spokes: spokeVnets[i].id]
'@
Set-Content -Path hub.bicep -Value $b
az bicep build --file hub.bicep
(Get-Content hub.bicep).Count

You should see this (no errors, no warnings):

87

The spokes come from a loop over an array parameter, so adding another spoke later means adding one more entry rather than another copy of the VNet code.

4Deploy it

The hub group stays in place for the rest of Phase 3:

az group create --name rg-saat-hub --location centralindia --tags course=saatvedha-azure lesson=45 keep=true -o none
az deployment group create --resource-group rg-saat-hub --name hub-spokes --template-file hub.bicep -o none
az network vnet list --resource-group rg-saat-hub --query "[].{name:name, space:addressSpace.addressPrefixes[0], subnets:length(subnets)}" -o table

You should see this:

Name         Space         Subnets
-----------  ------------  ---------
vnet-hub     10.40.0.0/16  4
vnet-spoke1  10.41.0.0/16  1
vnet-spoke2  10.42.0.0/16  1

You have three VNets with no connections between them yet, and you’ll peer them in Lesson 46.

Hub-and-spoke network resource group with three VNets
rg-saat-hub: the hub and two spokes, not connected yet.

Write the plan down somewhere the whole team can see it, as one table with every range, its owner and its purpose, including the ranges you haven’t used yet. In a real hub-and-spoke network that table gets checked before any new VNet, VPN or partner connection is approved, and it’s the first thing an engineer opens when a route looks wrong.

Hub-and-spoke network lab: IP plan check and deployed VNets
A clean IP plan and three VNets deployed from Bicep.

✅ Checkpoint: The IP plan has no overlaps, and vnet-hub, vnet-spoke1 and vnet-spoke2 exist in rg-saat-hub, deployed from Bicep.

Break It, Then Fix It

Both of these mistakes are cheap to fix now and expensive to fix later.

1Break it: a new spoke that overlaps

A new team asks for “a /17 somewhere in 10.30” for their app. Check it before anybody builds it:

C:\azure-lab\Test-IpPlan.ps1 -Plan @{ 'vnet-saat'='10.30.0.0/16'; 'vnet-hub'='10.40.0.0/16'; 'vnet-spoke1'='10.41.0.0/16'; 'vnet-spoke2'='10.42.0.0/16'; 'vnet-onprem'='10.80.0.0/16'; 'vnet-spoke3'='10.30.128.0/17' }

You should see this at the end:

vnet-spoke3 10.30.128.0/17 10.30.128.0 10.30.255.255     32768
OVERLAP: vnet-saat 10.30.0.0/16 and vnet-spoke3 10.30.128.0/17

Azure would quite happily create that VNet, because an overlap only gets rejected when you try to peer or route between the two. By that time the team has built servers in it, and fixing it means moving them.

To fix it, give the team the next free range in the plan, 10.43.0.0/16, and run the check again, which should finish with No overlaps. Keep the plan in one place (a spreadsheet, an IPAM tool or Azure Virtual Network Manager IPAM) so that each request gets checked against it.

2Break it: a subnet outside its VNet

Add a third spoke using a parameters file, with a typo in its subnet:

Set-Content -Path bad.bicepparam -Value "using 'hub.bicep'`n`nparam spokes = [`n  { name: 'vnet-spoke3', prefix: '10.43.0.0/16', appSubnet: '10.44.1.0/24' }`n]"
az deployment group create --resource-group rg-saat-hub --name spoke3 --template-file hub.bicep --parameters bad.bicepparam

You’ll get an error like this:

(NetcfgSubnetRangeOutsideVnet) Subnet 'snet-app' is not valid because its IP address range is outside the IP address range of virtual network 'vnet-spoke3'.

Bicep has no way of knowing that 10.44.1.0/24 isn’t inside 10.43.0.0/16, so it’s Resource Manager that catches it. Notice too that this parameters file lists only spoke3. In a normal deployment that doesn’t delete spoke1 and spoke2, but in a deployment stack with deleteResources it would, so always pass the full list.

To fix it, correct the subnet to 10.43.1.0/24, or for this lab just delete the bad file. Then check that the hub hasn’t changed:

Remove-Item bad.bicepparam
az network vnet list --resource-group rg-saat-hub --query "[].name" -o tsv

You should see this:

vnet-hub
vnet-spoke1
vnet-spoke2
Hub-and-spoke network errors: overlapping range and subnet outside its VNet
The checker caught an overlap, and Resource Manager rejected a subnet.

✅ Checkpoint: You caught an overlap before it was built and a subnet outside its VNet. rg-saat-hub stays for Lesson 46.

This happened at work

The acquisition that used the same 10.0.0.0/16

A retail group bought a smaller online shop and planned to connect the shop’s Azure VNets to its hub within a month. The trouble was that both companies had started out on Azure with the portal’s default VNet range, 10.0.0.0/16.

Peering was refused because of overlapping address space, and the VPN to the shop’s office ran into the same problem. In the end the integration took nine months, because the shop’s networks had to be renumbered, servers rebuilt, firewall rules rewritten and partners told about the new IPs.

What they changed: the group now keeps a central IP plan in Azure Virtual Network Manager IPAM, with a block for each company and region. Each new VNet request goes through a check like Test-IpPlan.ps1 in the pipeline, and policy blocks the portal’s default range.

Common mistakes and troubleshooting

MistakeWhat you seeWhat to do
Overlapping rangesPeering or VPN refused laterCheck each new range against a central plan.
Using portal defaults (10.0.0.0/16)Clashes after mergers and partnershipsAllocate from a planned block.
Hub subnets too smallGateway or Bastion can’t be createdGatewaySubnet /27+, Firewall and Bastion /26.
Spoke-to-spoke peering everywhereMesh nobody can auditSend spoke traffic through the hub firewall.
Subnet outside the VNet rangeNetcfgSubnetRangeOutsideVnetKeep subnets inside the address space.
No room to growRenumbering laterLeave gaps in the hub and keep spare ranges in the plan.

Interview questions

Click a question to open it. Each one is worded the way an interviewer would ask it, and underneath you’ll find why they ask it and one way you could answer in your own words.

Fresher level

1. What is a hub-and-spoke network?

Why they ask this: To check the basic concept.

How you might answer: It’s a design where a central hub VNet holds the shared services like firewalls and gateways, and the workload VNets, the spokes, connect only to the hub, usually through peering.

2. Why must VNet address ranges not overlap?

Why they ask this: A fundamentals check.

How you might answer: Routing needs every address to be unique. Azure won’t peer VNets that overlap, and VPN or ExpressRoute routing breaks as well.

3. How many addresses does Azure reserve in a subnet?

Why they ask this: A classic detail.

How you might answer: Five of them: the network address, three for Azure services (the default gateway and DNS), and the broadcast address. So a /24 gives you 251 usable addresses.

2–5 years experience

4. How do spokes talk to each other in hub-and-spoke?

Why they ask this: They want the routing idea.

How you might answer: Not directly, because peering isn’t transitive. Route tables on the spoke subnets send the other spokes’ ranges to a firewall or router in the hub, and that forwards the traffic on.

5. What goes in the hub?

Why they ask this: They want design sense.

How you might answer: The shared connectivity and security pieces: VPN or ExpressRoute gateways, Azure Firewall, Bastion, DNS Private Resolver, and sometimes domain controllers or jump hosts. The workloads themselves stay in the spokes.

6. Hub-and-spoke or Virtual WAN?

Why they ask this: They want trade-offs.

How you might answer: A hub-and-spoke you manage yourself gives you full control and suits a handful of regions. Virtual WAN gives you Microsoft-managed hubs with routing built in between lots of branches, regions and VPNs, but it costs more to start with and you get less low-level control.

Senior level

7. How would you design IP addressing for a large Azure estate?

Why they ask this: They want a plan.

How you might answer: I’d reserve a large block for Azure that doesn’t overlap on-premises or partner ranges, split it by region and then by environment and spoke, and leave room to grow. Then I’d manage it in an IPAM tool, check every request against it, and use policy to block default ranges.

8. How do you manage hub-and-spoke for hundreds of spokes?

Why they ask this: They want scale.

How you might answer: I’d use Azure Virtual Network Manager to group the VNets and create hub connectivity and security admin rules automatically, Bicep modules for the spokes, and Azure Policy to make sure new subnets get their route tables and NSGs.

9. What are the risks of a single hub?

Why they ask this: They want resilience thinking.

How you might answer: It’s a shared dependency, so a problem with the firewall or gateway hits every spoke at once. I’d use zone-redundant firewalls and gateways, a hub in each region, failover between regions that we’ve tested, and careful change control on anything in the hub.

Quick quiz

Q1. Where do the firewall and VPN gateway usually live?

  1. In each spoke
  2. In the hub
  3. On-premises only
  4. Nowhere
Show answer

B — Shared services sit in the hub.

Q2. How many usable addresses does a /26 subnet have in Azure?

  1. 64
  2. 62
  3. 59
  4. 32
Show answer

C — 64 minus 5 reserved.

Q3. Is VNet peering transitive?

  1. Yes
  2. No
  3. Only in the same region
  4. Only with ExpressRoute
Show answer

B — Spoke to spoke needs routing through the hub.

Q4. 10.30.128.0/17 and 10.30.0.0/16:

  1. Don’t overlap
  2. Overlap
  3. Are the same size
  4. Can be peered
Show answer

B — The /17 sits inside the /16.

Q5. Minimum size for GatewaySubnet in this course?

  1. /29
  2. /28
  3. /27
  4. /24
Show answer

C — A /27 or larger is recommended.

Quick recap

Your hub-and-spoke foundation is in place, with a clean IP plan behind it.

  • The hub holds the shared services, and the spokes hold the workloads.
  • Plan non-overlapping ranges before building anything.
  • Azure reserves 5 addresses per subnet.
  • Peering isn’t transitive, so spokes talk through the hub.
  • Deploy networks as code, with spokes in a loop.

Next lesson

Lesson 46: VNet peering and gateway transit → You peer the spokes to the hub, see why spoke-to-spoke fails, and set up gateway transit.

Further reading: hub-and-spoke network

Want to go deeper into hub-and-spoke network? See Microsoft’s Hub-spoke network topology in Azure and Azure Virtual Network FAQ. You can also see the full plan for this course on the Azure Cloud Administration course page.

Scroll to Top

This website uses cookies

We use a few cookies to keep this site working. If you allow it, we also use Google Analytics to count visits so we can improve our lessons. You can accept all, deny the optional ones, or choose what to allow.