Virtual networks, subnets and public IPs

AZ-104 Azure AdministratorNetworkingAbout 20 minutesBy Cloud Hands On

Build a VNet the way an administrator does: address space, subnets, NICs, private and public IPs, and outbound access.

In this lesson you'll learn

1. The building blocks

New to Azure networking? Start here

A virtual network (VNet) is your own private network inside an Azure region. Think of it as the office building. Subnets are the floors, used to separate things like web servers from databases. Every VM plugs in through a network interface (NIC), which is the network card that holds its IP addresses.

A VNet lives in one region and one subscription. Resources in the same VNet can talk to each other by default, even across subnets.

A VNet in UK South with a web subnet and an app subnet, VMs with NICs, a public IP on the web VM and a NAT gateway on the app subnet Region: UK South VNet sskaiser-vnet 10.20.0.0/16 Subnet web 10.20.0.0/25 Subnet app 10.20.0.128/25 web-vm1NIC 10.20.0.4 web-vm2NIC 10.20.0.5 Public IP app-vm1NIC 10.20.0.132 NAT gatewayoutbound only app-vm1 has no public IP.It reaches the internet through NAT.
Note the first VM in each subnet gets the .4 address, because Azure reserves the first four.

2. Create a VNet

In the portal: Virtual networks > Create. The Basics tab sets subscription, resource group, name and region. The IP addresses tab sets the address space and subnets. The Security tab can add Bastion, Azure Firewall and DDoS protection at the same time.

az network vnet create \\
  --resource-group rg-sskaiser \\
  --name sskaiser-vnet \\
  --address-prefixes 10.20.0.0/16 \\
  --subnet-name web --subnet-prefixes 10.20.0.0/25

az network vnet subnet create -g rg-sskaiser \\
  --vnet-name sskaiser-vnet -n app --address-prefixes 10.20.0.128/25

Exam focus

Use private ranges from RFC 1918: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. You can add more address ranges to a VNet later. A subnet's range can only be changed if nothing in it would end up outside the new range.

3. Private IP addresses

Azure assigns private IPs from the subnet through its own DHCP. By default the assignment is dynamic, but in practice the address only changes if the VM is deleted or moved. For servers that others reach by IP, such as DNS servers or domain controllers, set the assignment to static.

Golden rule: set a static private IP on the NIC's IP configuration in Azure (portal, CLI or PowerShell). Never type a static IP inside the guest operating system. If you do, the VM can lose connectivity.
az network nic ip-config update -g rg-sskaiser \\
  --nic-name web-vm1-nic -n ipconfig1 \\
  --private-ip-address 10.20.0.10

Example

SS Kaiser's legacy order service calls its stock service by a hard-coded IP. After migration, the stock VM was restarted and kept its IP. Months later it was redeployed from backup and came up on a new address, and orders failed for an hour. A static assignment on the NIC would have prevented this.

4. Public IP addresses

A public IP is a separate Azure resource that you attach to a NIC, a load balancer, a VPN gateway, Bastion, a NAT gateway or Application Gateway.

ItemStandard SKUBasic SKU
StatusCurrentRetired 30 September 2025
AllocationAlways staticStatic or dynamic
SecurityClosed by default, needs an NSG to allow trafficOpen by default
ZonesZonal or zone-redundantNo zone support
Works withStandard load balancerBasic load balancer only
  • DNS name label: gives the IP a name like sskaiser.uksouth.cloudapp.azure.com.
  • Public IP prefix: reserves a contiguous block of static public IPs, useful when partners allow-list your addresses.
  • Load balancer and public IP SKUs must match. A Standard load balancer needs Standard IPs.

5. Getting out to the internet

Historically, VMs without a public IP could still reach the internet through a hidden "default outbound access" address. Microsoft is retiring this for new deployments, so plan an explicit outbound method:

OptionBest for
NAT gateway on the subnetThe recommended choice. It gives scalable outbound connections for a whole subnet, with no inbound exposure.
Load balancer outbound rulesVMs already behind a Standard public load balancer.
Public IP on the NICA single VM that also needs inbound access.
Azure Firewall or an NVA with a UDROrganisations that must inspect and log all outbound traffic.

Exam traps to remember

  • A VM's NICs must all be in the same VNet. To move a VM to another VNet, recreate it from its disks.
  • A NIC can be in a different subnet of the same VNet, and you can change its subnet while the VM is stopped.
  • Standard public IPs are always static and deny inbound traffic until an NSG allows it.
  • The number of NICs a VM can have depends on its size.

Test yourself: 3 check questions and exam-style practice questions on this topic are in the AZ-104 Azure Administrator app.

Practise in the app

Keep going