Understanding Azure Virtual Networks and Subnets
This lesson explains Azure virtual networks, how subnets segment them, and the capabilities they provide for communication, routing and filtering. It is the foundation for the rest of the networking module.
Learning outcomes
After completing this lesson, you will be able to:
- Describe the purpose of an Azure virtual network and its address space.
- Explain how subnets segment a virtual network.
- Describe the capabilities of Azure virtual networking, including filtering with NSGs.
What a virtual network is
An Azure virtual network (VNet) is a logically isolated network in Azure, similar to a network in a traditional datacentre but with the benefits of Azure's scale and availability. Each virtual network belongs to one region and one subscription, and has an address space of private IP addresses, written in Classless Inter-Domain Routing (CIDR) notation such as 10.0.0.0/16. Resources such as virtual machines connect to a virtual network and receive private IP addresses from it.
Virtual networks are free to create; charges apply to resources in them and to some traffic, such as data transferred through peering or out to the internet.
Subnets
A virtual network is divided into one or more subnets, each with a range of addresses from the virtual network's address space, such as 10.0.1.0/24 for web servers and 10.0.2.0/24 for databases. Subnets let you segment the network: resources with different roles or security requirements are placed in different subnets, and traffic between them can be filtered and routed. Azure reserves five IP addresses in each subnet for its own use.
Some services require their own dedicated subnet, such as Azure VPN Gateway (a subnet named GatewaySubnet) and Azure Bastion. New virtual networks use private subnets by default, which means VMs do not get automatic outbound internet access; outbound connectivity is provided explicitly, for example with a NAT gateway, a public IP address or a load balancer.
No way out
Capabilities of Azure virtual networks
Azure virtual networking provides the following key capabilities, which together let you design networks in Azure as you would on-premises.
- Isolation and segmentation: several virtual networks and subnets keep workloads apart. Name resolution between resources is provided by Azure's internal DNS or by your own DNS servers.
- Internet communications: resources can receive inbound traffic through a public IP address or a public load balancer, and send outbound traffic through explicit outbound methods.
- Communication between Azure resources: through the virtual network itself, through virtual network peering, and through service endpoints or private endpoints for PaaS services.
- Communication with on-premises resources: through point-to-site and site-to-site VPN connections with Azure VPN Gateway, or through Azure ExpressRoute.
- Routing: Azure routes traffic between subnets, connected networks and the internet by default; route tables and the Border Gateway Protocol (BGP) customize routing.
- Filtering: network security groups (NSGs) contain inbound and outbound security rules that allow or deny traffic by source and destination IP address, port and protocol, and Azure Firewall or network virtual appliances provide more advanced filtering.
Virtual network capabilities
Segmenting a network
A company deploys a two-tier application in Azure with web servers and database servers. The security team requires that the database servers accept connections only from the web servers on port 1433 and are not reachable from the internet. How should the network be designed?
Create one virtual network with two subnets, one for the web tier and one for the database tier. Associate a network security group with the database subnet that allows inbound TCP port 1433 only from the web subnet's address range and denies other inbound traffic, and give the database servers no public IP addresses. Subnets provide the segmentation, and the NSG provides the filtering.
What filters traffic to and from subnets and network interfaces by IP address, port and protocol?
Show answer
A network security group (NSG), which contains inbound and outbound security rules.
Exam Tips
Remember for the exam
- A virtual network is an isolated private network in one region, with an address space divided into subnets.
- Subnets segment resources; NSGs filter traffic by IP address, port and protocol.
- Virtual networks connect to the internet, to other VNets (peering) and to on-premises (VPN Gateway, ExpressRoute).