Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 32 of 47
❮Prev Next❯

Virtual Networks, Subnets and Public IP Addresses

Module 4: Networking ⏱ 11 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    30-second answer

    An Azure virtual network (VNet) is a private IP address space (for example 10.0.0.0/16) in one region and subscription, split into subnets. Azure reserves 5 addresses in every subnet (network, default gateway, two for Azure DNS and broadcast), so a /29 leaves 3 usable and a /24 leaves 251. Address spaces must not overlap anything you'll connect to. A public IP address today is the Standard SKU: always static, zone-redundant where the region has zones, and closed to inbound traffic until an NSG allows it. Basic SKU public IPs were retired on 30 September 2025.

    Simulate it » No Azure account needed

    Exam objective: 4.1.1 Create and configure virtual networks and subnets. 4.1.3 Configure public IP addresses. (Skills measured as of April 17, 2026)

    Simulations

    Feel it before you read it. No account needed, nothing leaves this page.

    Azure portal: Create a VNet with subnets and a Standard static public IP Plan a VNet with subnets and create a Standard static public IP.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    Search for <strong>virtual networks</strong> to plan the hub.

    👆 Click the glowing item in the portal to continue

    Read the steps as text
    1. Search for virtual networks to plan the hub.
    2. Type virtual networks in the search bar and pick Virtual networks under Services.
    3. Select + Create.
    4. A VNet lives in one region and one subscription. Pick the resource group and name it.
    5. You can add Bastion or Firewall here, but we'll do Bastion separately so you see its subnet rules.
    6. Plan ranges that don't overlap the spokes or on-premises. Azure keeps 5 addresses in every subnet, so a /29 leaves you only 3.
    7. Review and Create.
    8. Deployment done. Now the public IP for the hub's VPN gateway.
    9. Search Public IP addresses and select + Create.
    10. Standard SKU, Static, Zone-redundant. A Standard IP is closed to inbound traffic until an NSG allows it.
    11. The address never changes while the resource exists, so firewalls and partners can allow it. Associate it later to a VPN gateway, load balancer, Bastion or NIC.

    🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.

    😟 THE PROBLEM

    The new subnet ran out of addresses after 10 VMs and the IP ranges clash with the office.

    😊 THE SOLUTION

    Plan non-overlapping address spaces, size subnets for growth and use Standard static public IPs.

    • Subnet too small✓ Remember the 5 reserved addresses
    • Ranges overlap on-premises✓ Plan the address space first
    • Public IP changes after a restart✓ Standard SKU, always static
    🛠️ Solved with: VNets, subnets and public IPs

    Start with a question

    Why does a new office building get its floor plan before anyone moves in?

    Before the furniture arrives, someone decides which floor is sales, which is finance, and how many desks each gets. Move in first and plan later, and you end up knocking down walls.

    An Azure virtual network is that building and its subnets are the floors. You pick the address ranges up front, size each subnet for what will live there, and keep the ranges clear of every other building you’ll ever connect to. The public IP address is the street address on the front door: fixed, so visitors and firewalls can find you.

    Explain it like I’m 10

    The technical explanation

    Virtual networks

    A VNet has one or more address spaces in CIDR notation, usually private ranges from RFC 1918 (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16). It belongs to one region and one subscription, and it’s free. Resources inside it talk to each other privately by default, and they can reach the internet outbound.

    Plan the ranges first. Peered VNets and on-premises networks you connect over VPN or ExpressRoute can’t overlap, and fixing an overlap later means rebuilding peerings and gateways.

    Subnets and the 5 reserved addresses

    Each subnet takes a slice of the address space. Azure keeps 5 addresses in every one:

    Address in 10.0.1.0/24Used for
    10.0.1.0Network address
    10.0.1.1Default gateway
    10.0.1.2 and 10.0.1.3Azure DNS mapping
    10.0.1.255Broadcast
    PrefixAddressesUsable
    /29 (smallest)83
    /281611
    /273227
    /266459
    /24256251

    Some services need their own subnet with a fixed name or size: GatewaySubnet for VPN and ExpressRoute gateways (/27 or bigger recommended), AzureBastionSubnet (/26 or bigger), AzureFirewallSubnet (/26). Others delegate a subnet, such as App Service VNet integration or Container Instances. Subnets are where you attach NSGs, route tables and service endpoints.

    You can change a subnet’s range only when nothing is using the addresses being removed. You can add address spaces to a VNet later, and peerings then need a sync.

    Public IP addresses

    SettingWhat to pick
    SKUStandard. Basic was retired on 30 September 2025.
    AssignmentStatic (the only option for Standard). The address stays until you delete the resource.
    Availability zoneZone-redundant (default in zone regions), a single zone, or no zone.
    TierRegional, or Global for a cross-region load balancer.
    Routing preferenceMicrosoft network (default) or Internet.
    DNS name labelOptional, gives label.region.cloudapp.azure.com.

    A Standard public IP is secure by default: inbound traffic is blocked until an NSG on the subnet or NIC allows it. You attach it to a VM’s NIC, a Standard load balancer frontend, a VPN gateway, Bastion, NAT gateway or Azure Firewall. Price feel: about $3.65 a month (illustrative).

    Portal and CLI

    Portal: Virtual networks → + Create → Basics → Security → IP addresses (address space and subnets) → Review + create. Then Public IP addresses → + Create.

    az network vnet create -g rg-net-hub -n vnet-hub \
      --address-prefixes 10.0.0.0/16 --subnet-name snet-shared --subnet-prefixes 10.0.1.0/24
    az network vnet subnet create -g rg-net-hub --vnet-name vnet-hub -n snet-tiny --address-prefixes 10.0.9.0/29
    az network vnet subnet list-available-ips -g rg-net-hub --vnet-name vnet-hub -n snet-tiny
    
    az network public-ip create -g rg-net-hub -n pip-hub-vpn \
      --sku Standard --allocation-method Static --zone 1 2 3
    $sub = New-AzVirtualNetworkSubnetConfig -Name snet-shared -AddressPrefix 10.0.1.0/24
    New-AzVirtualNetwork -Name vnet-hub -ResourceGroupName rg-net-hub -Location eastus -AddressPrefix 10.0.0.0/16 -Subnet $sub
    New-AzPublicIpAddress -Name pip-hub-vpn -ResourceGroupName rg-net-hub -Location eastus -Sku Standard -AllocationMethod Static -Zone 1,2,3
    Architect level Why a VNet can't span regions

    A VNet is tied to one region’s network fabric. To join regions you use global VNet peering, which still keeps traffic on Microsoft’s backbone. Subnets, though, span every availability zone in their region, so zone-redundant designs don’t need one subnet per zone.

    Real-world business scenario

    Retail

    Contoso Retail (fictional)

    The problem
    Teams created VNets on the fly with 10.0.0.0/16 everywhere. When the company tried to peer them and connect the stores' VPN, every range collided, and a /28 subnet for checkout VMs ran out of addresses on a busy weekend.
    What they used
    A central address plan: hub 10.0.0.0/16, spokes 10.1.0.0/16 to 10.9.0.0/16, stores in 192.168.0.0/16. Subnets sized as /24 for app tiers, GatewaySubnet /27, AzureBastionSubnet /26. A zone-redundant Standard static public IP for the VPN gateway.
    Why that choice
    No overlaps means peering and VPN just work, and sizing with the 5 reserved addresses in mind stops scale-out failures.
    The result
    The network team connected 9 spokes and 140 stores with no re-addressing, and checkout scaled to 40 VMs without hitting the subnet limit.

    When to use it and when not to

    ✓ Use it when…

    • Any Azure workload that needs private addresses, from a single VM to a hub and spoke estate.
    • A Standard static public IP whenever partners or firewalls must allow a fixed address.
    • Separate subnets per tier so NSGs and route tables can treat them differently.

    ✕ Think twice when…

    • Address spaces that overlap on-premises or other VNets you might peer later.
    • Tiny subnets for anything that scales out.
    • Public IPs on every VM. Use a load balancer, NAT gateway or Bastion instead.

    ↔ Alternatives to consider

    • NAT gateway for outbound internet from a subnet with a few fixed IPs.
    • Azure Bastion for admin access without public IPs on VMs.
    • Azure Virtual Network Manager to manage many VNets and their connectivity centrally.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    Test yourself with exercises

    5 original practice questions in the AZ-104 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.

    Question 1

    Question 1 of 5

    You create a subnet that uses the address range 10.10.4.0/27. How many IP addresses in the subnet can be assigned to virtual machines?

    Question 2

    Question 2 of 5

    You plan to peer VNet1 and VNet2 and to connect both to an on-premises network that uses 192.168.0.0/16. VNet1 uses 10.1.0.0/16. Which address space can you use for VNet2?

    Question 3

    Question 3 of 5

    You need to create a public IP address for a VPN gateway. The address must not change and must remain available if one availability zone fails. Which configuration should you use?

    Question 4

    Question 4 of 5

    A virtual machine has a Standard SKU public IP address associated with its network interface. Neither the network interface nor its subnet has a network security group. Users cannot connect to the VM on TCP port 443. What should you do?

    Question 5

    Question 5 of 5 · Select 2

    Which two statements about Azure virtual networks are true? Each correct answer presents a complete solution.

    Interview preparation

    Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.

    Beginner Why can't I use all 256 addresses in a /24 subnet?

    Model answer

    Azure keeps five of them in every subnet. The first is the network address, .1 is the default gateway, .2 and .3 map to Azure DNS, and the last one is the broadcast address. So a /24 gives me 251 usable addresses and a /29 gives me just 3.

    Intermediate What changes when you pick a Standard public IP instead of the old Basic one?

    Model answer

    Standard is always static, it's zone-redundant by default in regions with availability zones, and it's secure by default: nothing comes in until an NSG allows it. It also works with Standard Load Balancer, NAT gateway and Bastion. Basic was retired in September 2025, so in practice every new public IP is Standard.

    Experienced developer How do you plan address spaces for a hub and spoke design?

    Model answer

    I get the on-premises ranges first, then give the hub and each spoke its own block that doesn't overlap anything, for example 10.0.0.0/16 for the hub and 10.1.0.0/16, 10.2.0.0/16 for spokes. I leave room for growth, because peered VNets can't overlap and resizing later means coordinating peerings. Inside each VNet I size subnets for the biggest thing that'll live there, remembering services like Bastion need a /26 and the gateway subnet should be /27 or bigger.

    Scenario A team created a subnet of 10.5.1.0/28 for a VM scale set that needs 14 instances. What happens?

    Model answer

    A /28 has 16 addresses, minus 5 reserved, so only 11 are usable. The scale set will fail to place the last instances. I'd move to a bigger subnet, such as a /27 (27 usable) or a /26, and I'd check nothing else shares it.

    Quick revision

    Key points

    • A VNet is one region, one subscription, one or more CIDR ranges. VNets are free.
    • Every subnet loses 5 addresses. /29 is the smallest IPv4 subnet (3 usable).
    • Address spaces must not overlap VNets or on-premises networks you'll connect to.
    • Standard public IP = static, zone-redundant in zone regions, closed until an NSG allows traffic.
    • Basic SKU public IPs were retired on 30 September 2025.

    Important terminology

    Virtual network (VNet)
    A private, isolated network in one Azure region and subscription, defined by one or more address ranges in CIDR notation.
    Subnet
    A range inside a VNet's address space where you place resources. NSGs, route tables and service endpoints attach to subnets.
    Reserved addresses
    The 5 IPs Azure keeps in every subnet - the network address, .1 for the default gateway, .2 and .3 for Azure DNS, and the broadcast address.
    Standard public IP
    The current public IP SKU. Static only, zone-redundant by default in zone regions, secure by default (inbound needs an NSG).
    Routing preference
    A public IP setting that picks Microsoft network (traffic stays on Microsoft's backbone as long as possible) or Internet (cheaper, hands off to ISPs sooner).
    Delegated subnet
    A subnet handed to one Azure service, such as Azure Container Instances or App Service VNet integration, which then manages it.

    Common mistakes

    • Forgetting the 5 reserved addresses when sizing a subnet.
    • Expecting a Standard public IP to accept traffic with no NSG.
    • Choosing overlapping ranges and discovering it only when peering fails.

    Exam tips

    • "How many VMs fit in a /27?" = 32 - 5 = 27.
    • "Public IP must never change" = Static (Standard is always static).
    • "Public IP must survive a zone failure" = Standard, zone-redundant.

    Five quick revision questions

    1. 1.How many addresses does Azure reserve per subnet?Show

      Five.

    2. 2.What is the smallest IPv4 subnet Azure allows?Show

      A /29, with 3 usable addresses.

    3. 3.Which allocation methods does a Standard public IP support?Show

      Static only.

    4. 4.Can a VNet span two regions?Show

      No. A VNet lives in one region; connect regions with global peering.

    5. 5.Which CLI command creates a public IP?Show

      az network public-ip create --sku Standard --allocation-method Static.

    Official references

    Finished this lesson? Tick it off. Your progress is saved in this browser.

    Next up: Configure Virtual Network Peering and Gateway Transit

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.