Azure Networking Fundamentals: IP Addresses, IPv4, Subnetting, CIDR and IP Address Classes — Complete Guide
Azure Networking | Beginner to Intermediate | AZ-900 & AZ-104 | Networking Fundamentals
What You'll Learn
In this article, we'll explore the networking concepts you need before configuring Azure Virtual Networks (VNets), subnets, Network Security Groups (NSGs), and virtual machines.
By the end of this guide, you'll understand:
-
What an IP address is and how devices communicate over networks.
-
IPv4 and IPv6 addressing, including their differences.
-
Binary numbers, bits, bytes, and octets.
-
How IPv4 addresses are represented using 32 bits.
-
Public IP addresses, private IP addresses, and NAT.
-
Private IPv4 address ranges defined by RFC 1918.
-
IP address classes A, B, C, D, and E.
-
CIDR notation and subnet masks.
-
How to calculate network addresses, broadcast addresses, and usable host addresses.
-
How to divide a large network into smaller subnets.
-
How Azure reserves IP addresses within each subnet.
-
How to calculate IP ranges using online subnet calculators.
-
How Azure VNets use address spaces and subnets.
-
Common subnetting mistakes and networking best practices.
-
Important Azure networking interview questions and answers.
Part 1: Understanding IP Addresses
1.1 What Is an IP Address?
An IP address (Internet Protocol address) is a numerical address assigned to a network interface to identify it and enable communication over an IP network.
Every device communicating over an IP network needs an appropriate IP address.
Examples include:
-
Laptops and desktop computers
-
Mobile phones
-
Web servers
-
Database servers
-
Azure Virtual Machines
-
Routers and network interfaces
An IP address performs two important functions:
-
Identification: Identifies a network interface within an addressing context.
-
Routing: Helps network devices determine where to deliver IP packets.
Real-world example
Consider sending a letter through a postal service.
|
Postal system |
Computer network |
|---|---|
|
House address |
IP address |
|
Letter |
Data packet |
|
Postal sorting center |
Router |
|
Destination house |
Destination device |
|
Postal delivery route |
Network route |
Without an appropriate destination address, the network cannot route a packet to the intended device.
Example network communication
Home Network
|
+----------------+
| Wi-Fi Router |
| 192.168.1.1 |
+----------------+
|
+---------+---------+
| |
v v
+---------------+ +---------------+
| Laptop | | Mobile Phone |
| 192.168.1.10 | | 192.168.1.11 |
+---------------+ +---------------+
Both devices have different private IP addresses within the same local network.
Key points
-
IP addresses operate at Layer 3 (Network Layer) of the OSI model.
-
IPv4 uses 32-bit addresses.
-
IPv6 uses 128-bit addresses.
-
A device can have multiple IP addresses.
-
An IP address identifies a network interface, not necessarily an entire physical device.
Part 2: IPv4 and IPv6
2.1 What Is IPv4?
IPv4 stands for Internet Protocol version 4.
It uses a 32-bit address represented by four decimal numbers separated by dots.
Example:
192.168.1.10
192 . 168 . 1 . 10
| | | |
Octet1 Octet2 Octet3 Octet4
Each octet contains 8 bits.
Therefore:
8 + 8 + 8 + 8 = 32 bits
The theoretical number of IPv4 addresses is:
Approximately 4.3 billion addresses exist in the complete IPv4 address space, although many are reserved or unavailable for ordinary public allocation.
2.2 What Is IPv6?
IPv6 stands for Internet Protocol version 6.
It was developed to provide a much larger address space and improve various aspects of IP networking.
Example:
2001:0db8:0000:0000:0000:ff00:0042:8329
IPv6 uses 128-bit addresses.
IPv6 addresses use hexadecimal notation, with eight groups of 16 bits.
Consecutive zero groups can be compressed using :: once per address.
Example:
Full:
2001:0db8:0000:0000:0000:ff00:0042:8329
Compressed:
2001:db8::ff00:42:8329
IPv4 vs IPv6
|
Feature |
IPv4 |
IPv6 |
|---|---|---|
|
Address length |
32 bits |
128 bits |
|
Format |
Decimal |
Hexadecimal |
|
Example |
192.168.1.10 |
2001:db8::1 |
|
Address count |
~4.3 billion |
~3.4 × 10³⁸ |
|
Broadcast |
Supported |
Not supported |
|
Multicast |
Supported |
Supported |
|
NAT |
Common |
Generally not required for address conservation |
|
Azure support |
Supported |
Supported |
Azure note: Azure VNets support IPv4 and IPv4/IPv6 dual-stack configurations. IPv4 is frequently used in introductory networking labs, but IPv6 is also relevant to modern Azure architectures.
Part 3: Bits, Bytes, Binary and Octets
3.1 What Is a Bit?
A bit is the smallest unit of binary information.
A bit can contain only two values:
0 or 1
These values are used to represent information in binary form.
3.2 What Is a Byte?
A byte contains 8 bits.
1 bit = 0 or 1
1 byte = 8 bits
Example:
01010101
In IPv4 addressing, an 8-bit group is called an octet.
IPv4 Address: 10.0.1.5
+----------+----------+----------+----------+
| Octet 1 | Octet 2 | Octet 3 | Octet 4 |
+----------+----------+----------+----------+
| 8 bits | 8 bits | 8 bits | 8 bits |
+----------+----------+----------+----------+
Total = 32 bits
3.3 Understanding Binary Numbers
Computers use binary numbers, which are based on powers of 2.
|
Bit position |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
|---|---|---|---|---|---|---|---|---|
|
Decimal value |
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
Let's convert binary 00001010 to decimal.
Bit Value: 128 64 32 16 8 4 2 1
Binary: 0 0 0 0 1 0 1 0
Calculation:
8 + 2 = 10
Result:
00001010 = 10
3.4 Why Does an IPv4 Octet Range from 0 to 255?
One octet contains 8 bits.
The number of possible combinations is:
Since counting starts at zero:
Minimum: 00000000 = 0
Maximum: 11111111 = 255
Therefore, the valid range of each IPv4 octet is 0–255.
Valid IP:
192.168.1.100
Invalid IP:
192.168.1.300
The value 300 cannot fit into an 8-bit octet.
3.5 Converting an IPv4 Address into Binary
Example:
IPv4 Address:
10.0.1.5
Decimal Binary
------- --------
10 00001010
0 00000000
1 00000001
5 00000101
Complete representation:
00001010.00000000.00000001.00000101
Why is binary important for networking?
Subnet masks, CIDR prefixes, and network address calculations depend on binary arithmetic.
Understanding binary makes subnetting much easier.
Part 4: Public IP Addresses and Private IP Addresses
4.1 What Is a Public IP Address?
A public IP address is an address intended for routing over the public internet.
Public IP addresses are allocated through the global internet address allocation system.
Example:
20.50.10.25
A public IP address may be used for:
-
Public websites
-
Internet-facing APIs
-
VPN gateways
-
Public load balancers
-
Azure Virtual Machines requiring direct internet connectivity
A public IP does not automatically mean that all incoming traffic is permitted. Firewalls, NSGs, routing, and application configuration still control access.
4.2 What Is a Private IP Address?
A private IP address is used within a private network.
Private IPv4 addresses are not globally routed over the public internet.
Examples:
192.168.1.10
10.0.0.4
172.16.5.20
Private IP addresses are commonly assigned to:
-
Home computers
-
Office workstations
-
Internal application servers
-
Database servers
-
Azure VMs inside VNets
4.3 Private IPv4 Address Ranges
RFC 1918 defines three private IPv4 address blocks.
|
Private range |
CIDR |
Total addresses |
|---|---|---|
|
10.0.0.0 – 10.255.255.255 |
10.0.0.0/8 |
16,777,216 |
|
172.16.0.0 – 172.31.255.255 |
172.16.0.0/12 |
1,048,576 |
|
192.168.0.0 – 192.168.255.255 |
192.168.0.0/16 |
65,536 |
These addresses can be reused across separate private networks.
For example, two unrelated organizations can both use 10.0.0.4 internally.
However, overlapping address spaces can create routing problems when networks are connected using VPNs or VNet peering.
Important Azure clarification: Azure VNet address spaces are not strictly limited to the three RFC 1918 blocks. Azure supports additional permitted address ranges, subject to platform restrictions. RFC 1918 ranges are nevertheless the recommended conventional choice for most private VNet designs.
Public vs Private IP
|
Feature |
Public IP |
Private IP |
|---|---|---|
|
Scope |
Public internet |
Private network |
|
Global uniqueness |
Required for globally routed addresses |
Not required |
|
Internet routing |
Routable when advertised |
Not directly routed |
|
Common Azure use |
Public endpoints |
Internal communication |
|
Can be reused independently? |
Not as the same globally routed address |
Yes |
|
Example |
20.50.10.25 |
10.0.0.4 |
Part 5: Network Address Translation (NAT)
5.1 What Is NAT?
NAT stands for Network Address Translation.
It translates IP address information as traffic passes through a network device or service.
A common use is allowing multiple private devices to access the internet through one public IPv4 address.
Example: Home network
+-------------------+
| Laptop |
| 192.168.1.50 |
+-------------------+
|
v
+-------------------+
| Home Router |
| NAT / PAT |
| Public IP |
| 203.0.113.10 |
+-------------------+
|
v
+-------------------+
| Internet |
+-------------------+
|
v
+-------------------+
| Public Web Server |
+-------------------+
5.2 How NAT Works
-
The laptop sends a request to an internet server.
-
The router receives the packet.
-
NAT translates the private source address to a public address.
-
The request travels across the internet.
-
The response returns to the public address.
-
The router uses its translation table to forward the response to the original private device.
When multiple devices share one public IPv4 address, the router typically uses Port Address Translation (PAT), also called NAT overload.
5.3 NAT in Azure
Azure provides several ways to support outbound connectivity.
Examples include:
-
Azure NAT Gateway
-
Public IP addresses attached to VM network interfaces
-
Outbound configurations associated with Azure Load Balancer
-
Azure Firewall
For predictable outbound internet connectivity from private subnets, Azure NAT Gateway is a common recommended solution.
Azure Virtual Network
10.0.0.0/16
|
v
Application Subnet
10.0.1.0/24
|
v
Virtual Machine
10.0.1.4
|
v
Azure NAT Gateway
|
v
Public IP
|
v
Internet
Important: Do not assume that every Azure VM automatically receives unrestricted outbound internet access. Explicit outbound connectivity should be configured where required, particularly for new production deployments.
Part 6: IP Address Classes (Classful Addressing)
6.1 What Is Classful Addressing?
Classful addressing was an older IPv4 allocation system that divided addresses into fixed classes based on their leading bits.
There were five classes:
-
Class A
-
Class B
-
Class C
-
Class D
-
Class E
Modern networking uses CIDR instead of classful allocation.
6.2 IP Address Classes
|
Class |
First octet |
Default mask |
Prefix |
Purpose |
|---|---|---|---|---|
|
A |
1–126 |
255.0.0.0 |
/8 |
Large networks |
|
B |
128–191 |
255.255.0.0 |
/16 |
Medium networks |
|
C |
192–223 |
255.255.255.0 |
/24 |
Small networks |
|
D |
224–239 |
N/A |
N/A |
Multicast |
|
E |
240–255 |
N/A |
N/A |
Reserved/experimental |
The table reflects conventional historical host-network classifications. The 0.0.0.0/8 range has special uses, and 127.0.0.0/8 is reserved for loopback.
6.3 Class A
Historically used for very large networks.
Example:
10.0.0.1
Default Mask:
255.0.0.0
Default Prefix:
/8
6.4 Class B
Historically used for medium-sized networks.
Example:
172.16.1.10
Default Mask:
255.255.0.0
Default Prefix:
/16
6.5 Class C
Historically used for smaller networks.
Example:
192.168.1.10
Default Mask:
255.255.255.0
Default Prefix:
/24
6.6 Class D
Class D addresses are used for IPv4 multicast.
Example:
224.0.0.1
Multicast allows one sender to deliver traffic to multiple subscribed receivers.
6.7 Class E
Class E covers 240.0.0.0/4 and is traditionally reserved for experimental or special purposes.
6.8 Why Was Classful Addressing Replaced?
Classful addressing caused inefficient address allocation.
Suppose an organization needed 300 host addresses.
A traditional Class C network provided only 254 usable host addresses.
A Class B network provided 65,534 conventional usable host addresses.
That would waste a large portion of the allocated address block.
CIDR solves this by allowing more flexible network sizes.
Key points
-
Classful addressing is historical.
-
CIDR replaced class-based routing and allocation.
-
Class A, B, and C terminology still appears in networking interviews.
-
A
/24is not inherently a Class C network; it is simply a 24-bit prefix.
Part 7: Understanding CIDR Notation
7.1 What Is CIDR?
CIDR stands for Classless Inter-Domain Routing.
CIDR represents a network using an IP address and a prefix length.
Example:
10.0.1.0/24
Here:
-
10.0.1.0is the network address. -
/24is the prefix length. -
24 bits represent the network portion.
-
The remaining 8 bits represent the host portion.
7.2 Network Bits and Host Bits
IPv4 contains 32 bits.
IPv4 Address = 32 Bits
/24 Network
+------------------------+--------+
| Network Bits | Host |
| 24 Bits | 8 Bits |
+------------------------+--------+
Network Bits = 24
Host Bits = 32 - 24 = 8
7.3 CIDR Address Calculation Formula
The total number of addresses in an IPv4 CIDR block is:
Example for /24:
Example for /28:
7.4 Common CIDR Reference Table
|
CIDR |
Subnet mask |
Total IPs |
Traditional usable hosts |
Azure usable IPs* |
|---|---|---|---|---|
|
/16 |
255.255.0.0 |
65,536 |
65,534 |
65,531 |
|
/20 |
255.255.240.0 |
4,096 |
4,094 |
4,091 |
|
/24 |
255.255.255.0 |
256 |
254 |
251 |
|
/25 |
255.255.255.128 |
128 |
126 |
123 |
|
/26 |
255.255.255.192 |
64 |
62 |
59 |
|
/27 |
255.255.255.224 |
32 |
30 |
27 |
|
/28 |
255.255.255.240 |
16 |
14 |
11 |
|
/29 |
255.255.255.248 |
8 |
6 |
3 |
7.5 Why Does Increasing the Prefix Reduce Available Addresses?
Compare:
/24 = 256 addresses
/25 = 128 addresses
/26 = 64 addresses
/27 = 32 addresses
/28 = 16 addresses
/29 = 8 addresses
Each time the prefix increases by one bit, the number of addresses is divided by two.
Part 8: Understanding Subnet Masks
8.1 What Is a Subnet Mask?
A subnet mask is a 32-bit value used to distinguish the network portion of an IPv4 address from the host portion.
Example:
IP Address:
192.168.1.10
Subnet Mask:
255.255.255.0
CIDR:
/24
Binary subnet mask:
11111111.11111111.11111111.00000000
The binary 1 bits indicate the network prefix.
The binary 0 bits indicate the remaining host portion.
8.2 Common Subnet Masks
|
CIDR |
Subnet mask |
|---|---|
|
/8 |
255.0.0.0 |
|
/12 |
255.240.0.0 |
|
/16 |
255.255.0.0 |
|
/20 |
255.255.240.0 |
|
/22 |
255.255.252.0 |
|
/24 |
255.255.255.0 |
|
/25 |
255.255.255.128 |
|
/26 |
255.255.255.192 |
|
/27 |
255.255.255.224 |
|
/28 |
255.255.255.240 |
|
/29 |
255.255.255.248 |
|
/30 |
255.255.255.252 |
|
/32 |
255.255.255.255 |
8.3 Calculating a Network Address Using Binary AND
Example:
IP Address:
192.168.1.130
Subnet Mask:
255.255.255.192
CIDR:
/26
The last octet is:
IP Address: 10000010 (130)
Subnet Mask: 11000000 (192)
--------
AND Result: 10000000 (128)
Therefore:
Network Address:
192.168.1.128
Network Prefix:
192.168.1.128/26
A bitwise AND operation produces 1 only when both corresponding input bits are 1.
Part 9: Network Address, Broadcast Address and Usable Hosts
9.1 Network Address
The network address identifies the subnet.
For:
192.168.1.0/24
The network address is:
192.168.1.0
9.2 Broadcast Address
The broadcast address is the last address in a traditional IPv4 subnet.
For:
192.168.1.0/24
The broadcast address is:
192.168.1.255
9.3 Usable Host Addresses
For an ordinary traditional /24 subnet:
Network Address: 192.168.1.0
First Host: 192.168.1.1
Last Host: 192.168.1.254
Broadcast Address: 192.168.1.255
Traditional usable hosts:
The two-address reservation rule is a useful convention for ordinary IPv4 LANs, although /31 point-to-point networks and /32 host routes are important exceptions.
9.4 Azure Reserves Five IP Addresses per Subnet
Azure reserves the first four addresses and the last address of each ordinary IPv4 VNet subnet.
Example:
Azure Subnet:
10.0.1.0/24
Total IP Addresses:
256
Reserved by Azure:
10.0.1.0 - Network address
10.0.1.1 - Default gateway
10.0.1.2 - Azure DNS mapping
10.0.1.3 - Azure DNS mapping
10.0.1.255 - Reserved final address
Usable:
10.0.1.4 through 10.0.1.254
Total Usable:
251
The DNS mapping addresses are reserved by Azure even when custom DNS servers are configured.
Traditional Network vs Azure Subnet
|
Property |
Traditional /24 |
Azure /24 |
|---|---|---|
|
Total addresses |
256 |
256 |
|
Reserved addresses |
2 |
5 |
|
Usable addresses |
254 |
251 |
Interview tip: If asked how many usable IP addresses exist in an Azure /24 subnet, the answer is 251, not 254.
Part 10: The 256 Minus the Subnet Mask Trick
This is a useful shortcut for identifying IPv4 subnet boundaries.
Formula
The interesting octet is the rightmost octet of the subnet mask that is not 255.
Example 1: /26 Subnet
Subnet mask:
255.255.255.192
Calculation:
256 - 192 = 64
Therefore, the subnet boundaries in the last octet are:
0
64
128
192
|
Subnet |
Address range |
|---|---|
|
10.0.1.0/26 |
10.0.1.0 – 10.0.1.63 |
|
10.0.1.64/26 |
10.0.1.64 – 10.0.1.127 |
|
10.0.1.128/26 |
10.0.1.128 – 10.0.1.191 |
|
10.0.1.192/26 |
10.0.1.192 – 10.0.1.255 |
Example 2: /28 Subnet
Subnet mask:
255.255.255.240
Calculation:
256 - 240 = 16
Subnet boundaries:
0, 16, 32, 48, 64, 80, 96, 112,
128, 144, 160, 176, 192, 208, 224, 240
Example:
Subnet:
10.0.1.32/28
Network Address:
10.0.1.32
Last Address:
10.0.1.47
Total Addresses:
16
Azure Usable Addresses:
11
Example 3: /20 Subnet
Subnet mask:
255.255.240.0
Calculation:
256 - 240 = 16
Here, the interesting octet is the third octet.
Therefore:
10.0.0.0/20
10.0.16.0/20
10.0.32.0/20
10.0.48.0/20
For example:
Network:
10.0.16.0/20
First Address:
10.0.16.0
Last Address:
10.0.31.255
Total Addresses:
4096
Key point: The block-size trick works beyond /24–/30. You must apply it to the correct octet.
Part 11: Subnetting — Dividing a Network into Smaller Networks
11.1 What Is Subnetting?
Subnetting is the process of dividing a larger IP network into smaller networks.
It helps with:
-
Logical separation of workloads
-
Efficient IP address allocation
-
Network management
-
Security policy design
-
Routing and network segmentation
11.2 Example: Dividing a /24 into Four /26 Subnets
Suppose we have:
10.0.1.0/24
Total Addresses:
256
We want four equal-sized subnets.
Each subnet needs:
256 / 4 = 64 addresses
A /26 contains 64 addresses.
Parent Network
10.0.1.0/24
|
+---------------------+
| |
v v
10.0.1.0/25 10.0.1.128/25
| |
+--+--+ +--+--+
| | | |
v v v v
/26 /26 /26 /26
.0 .64 .128 .192
Result:
|
Subnet |
Network address |
Last address |
Total IPs |
Azure usable |
|---|---|---|---|---|
|
Subnet 1 |
10.0.1.0/26 |
10.0.1.63 |
64 |
59 |
|
Subnet 2 |
10.0.1.64/26 |
10.0.1.127 |
64 |
59 |
|
Subnet 3 |
10.0.1.128/26 |
10.0.1.191 |
64 |
59 |
|
Subnet 4 |
10.0.1.192/26 |
10.0.1.255 |
64 |
59 |
11.3 Example: Azure Application Architecture
Suppose you're deploying an application with three tiers:
-
Frontend
-
Backend API
-
Database
A simple address plan could be:
Azure Virtual Network
10.0.0.0/16
|
+-------------------------+
| |
v v
Frontend Subnet Backend Subnet
10.0.1.0/24 10.0.2.0/24
| |
v v
Web Servers API Servers
|
v
Database Subnet
10.0.3.0/24
|
v
Database VM
This is a logical subnet design, not a requirement that each application tier must have its own subnet.
NSGs and other network controls can be configured to restrict traffic between tiers.
For example:
Internet
|
v
Frontend
|
| Allow HTTPS / Application Port
v
Backend API
|
| Allow Database Port
v
Database
In a production environment, the exact controls depend on whether you're using Azure VMs, App Service, Azure SQL Database, private endpoints, or other managed services.
Part 12: Variable Length Subnet Masking (VLSM)
12.1 What Is VLSM?
VLSM stands for Variable Length Subnet Masking.
It allows a network to be divided into subnets of different sizes.
Instead of giving every workload a /24, you can allocate address blocks according to actual requirements.
Example
Suppose you have:
Parent Network:
10.0.0.0/24
Total Addresses:
256
Requirements:
|
Workload |
Required usable IPs |
|---|---|
|
Application servers |
100 |
|
Backend servers |
50 |
|
Database servers |
20 |
|
Management servers |
10 |
Allocate the largest subnet first.
|
Workload |
Allocated subnet |
Total IPs |
Azure usable |
|---|---|---|---|
|
Application |
10.0.0.0/25 |
128 |
123 |
|
Backend |
10.0.0.128/26 |
64 |
59 |
|
Database |
10.0.0.192/27 |
32 |
27 |
|
Management |
10.0.0.224/28 |
16 |
11 |
Remaining unallocated block:
10.0.0.240/28
This provides another 16-address block for future use.
VLSM Address Plan
10.0.0.0/24
|
+-- 10.0.0.0/25 Application
| 128 IPs
|
+-- 10.0.0.128/26 Backend
| 64 IPs
|
+-- 10.0.0.192/27 Database
| 32 IPs
|
+-- 10.0.0.224/28 Management
| 16 IPs
|
+-- 10.0.0.240/28 Reserved
16 IPs
Advantages of VLSM
-
Reduces unused address capacity.
-
Supports workloads with different address requirements.
-
Improves long-term network planning.
-
Makes address allocation more flexible.
Part 13: IP Addressing in Azure Virtual Networks
13.1 What Is an Azure Virtual Network?
An Azure Virtual Network (VNet) is a logically isolated network environment in Azure.
It allows Azure resources to communicate securely with each other and, when configured, with on-premises networks and the internet.
13.2 What Is a VNet Address Space?
A VNet address space defines the IP address ranges available to that VNet.
Example:
VNet Name:
production-vnet
Address Space:
10.0.0.0/16
Total IPv4 Addresses:
65,536
You can divide this address space into multiple subnets.
13.3 What Is a Subnet in Azure?
A subnet is a smaller IP address range created inside a VNet address space.
Example:
Virtual Network
10.0.0.0/16
|
+------------------------+
| |
v v
Web Subnet API Subnet
10.0.1.0/24 10.0.2.0/24
| |
v v
Web VM API VM
10.0.1.4 10.0.2.4
Azure assigns private IP addresses from the relevant subnet to eligible network interfaces and services.
13.4 Can a VNet Have Multiple Address Spaces?
Yes.
For example:
VNet: production-vnet
Address Space 1:
10.0.0.0/16
Address Space 2:
10.1.0.0/16
These ranges must not overlap within the same VNet.
When designing connected networks, you should also avoid overlapping address ranges across the connected environments.
13.5 Can Two Azure VNets Use the Same Address Range?
Yes, two isolated VNets can use identical address spaces.
However, overlapping ranges generally prevent straightforward VNet peering between those networks.
For example:
VNet-A:
10.0.0.0/16
VNet-B:
10.0.0.0/16
The two VNets can exist independently, but their overlapping address ranges create connectivity challenges.
Best practice: Plan address allocation across VNets, on-premises networks, VPN connections, and future environments before deployment.
Part 14: Azure Portal Hands-On — Understanding Address Spaces
This exercise is observational. You can inspect the configuration without deploying billable resources.
Step 1: Open Azure Portal
Navigate to:
Open Microsoft Azure PortalSign in using your Azure account.
Step 2: Open Virtual Networks
Search for:
Virtual networks
Select Create.
Step 3: Configure Basic Details
Provide sample values:
|
Field |
Value |
|---|---|
|
Resource group |
networking-demo-rg |
|
VNet name |
demo-vnet |
|
Region |
Your preferred Azure region |
You do not need to finish creating the resource.
Step 4: Open the IP Addresses Tab
Locate the VNet address-space configuration.
For example:
10.0.0.0/16
The address count is:
65,536
Step 5: Experiment with Subnet Sizes
Try different prefixes:
|
Prefix |
Total addresses |
Azure usable addresses |
|---|---|---|
|
/24 |
256 |
251 |
|
/25 |
128 |
123 |
|
/26 |
64 |
59 |
|
/27 |
32 |
27 |
|
/28 |
16 |
11 |
|
/29 |
8 |
3 |
Observe how the address ranges and counts change.
Azure Portal labels and available subnet options can change over time, and certain services require larger subnets.
Step 6: Cancel
After experimenting, select Cancel or navigate away without submitting the deployment.
No VNet resources need to be created for this exercise.
Part 15: Online IP Address and Subnet Calculators
You don't need to calculate every subnet manually. Several online tools can calculate CIDR ranges, split networks, and validate subnet allocations.
A visual tool for dividing a parent network into smaller subnets. Particularly useful for planning multiple Azure subnets and seeing their boundaries.
Calculate network addresses, subnet masks, host ranges, broadcast addresses, and binary representations from an IP address and CIDR prefix.
3. IP Subnet Calculator — Calculator.net
Useful for beginners learning IPv4 subnet masks, subnet classes, address ranges, and CIDR calculations.
4. MXToolbox Subnet Calculator
A quick tool for inspecting subnet details and validating network address calculations.
Example: Calculate 192.168.10.0/26
Enter the following into an IP subnet calculator:
IP Address: 192.168.10.0
CIDR: /26
Expected results:
|
Property |
Result |
|---|---|
|
Network address |
192.168.10.0 |
|
Subnet mask |
255.255.255.192 |
|
Broadcast address |
192.168.10.63 |
|
First traditional host |
192.168.10.1 |
|
Last traditional host |
192.168.10.62 |
|
Total addresses |
64 |
|
Traditional usable hosts |
62 |
|
Azure usable IPs |
59 |
Note: Most general-purpose subnet calculators display the traditional usable host count. For an ordinary Azure IPv4 subnet, subtract five from the total address count instead.
Interactive CIDR Calculator
Use this calculator to explore how changing the prefix affects the network address, address range, and Azure-usable IP count.
/26
64
59
| Network |
10.0.1.64/26 |
| Subnet mask | 255.255.255.192 |
| Last address | 10.0.1.127 |
| First Azure usable | 10.0.1.68 |
| Last Azure usable | 10.0.1.126 |
Part 16: Common IP Addressing and Subnetting Mistakes
16.1 Using Overlapping Subnets
Incorrect:
Subnet A: 10.0.1.0/24
Subnet B: 10.0.1.128/25
Subnet B falls inside Subnet A's address range.
Azure does not allow overlapping subnet address ranges within the same VNet.
Correct:
Subnet A: 10.0.1.0/25
Subnet B: 10.0.1.128/25
16.2 Forgetting Azure-Reserved IP Addresses
Incorrect calculation:
/28 = 16 IP addresses
Assumption:
16 usable IPs
Correct calculation:
/28 = 16 total addresses
Azure Reserved = 5
Azure Usable = 11
16.3 Using an Incorrect Subnet Boundary
Consider:
10.0.1.20/28
This is an IP address inside a /28 block, not the canonical network address.
The corresponding network is:
10.0.1.16/28
Its complete range is:
10.0.1.16 - 10.0.1.31
Always use the correctly aligned network address when defining a subnet.
16.4 Confusing Public IPs with Private IPs
A private IP address does not automatically provide internet access.
Similarly, a public IP resource does not automatically permit inbound traffic.
Actual connectivity depends on routing, NAT, NSGs, firewalls, and the relevant service configuration.
16.5 Creating Subnets That Are Too Small
Suppose you need 15 Azure-usable addresses.
A /28 subnet provides only 11 usable addresses.
Therefore, /28 is insufficient.
A /27 provides 27 usable addresses and would satisfy that requirement.
16.6 Ignoring Future Growth
If your application currently requires 50 addresses, a /26 subnet provides 59 usable addresses.
However, it may not provide enough capacity for future expansion.
A /25 offers 123 usable addresses and more growth headroom.
16.7 Ignoring Azure Service-Specific Subnet Requirements
Certain Azure services require dedicated subnets with specific names or minimum sizes.
|
Azure service |
Common requirement |
|---|---|
|
Azure Bastion |
|
|
Azure Firewall |
|
|
VPN Gateway |
|
|
Azure Route Server |
|
|
Azure Application Gateway v2 |
Dedicated subnet; /24 recommended |
These requirements should be checked against the specific service and SKU before deployment.
Part 17: Azure IP Addressing Best Practices
1. Plan your VNet address space in advance. Allocate sufficient address capacity for current and future applications.
2. Avoid overlapping networks. Consider other VNets, on-premises environments, VPNs, and future VNet peering.
3. Use private addressing for internal workloads. Avoid assigning public IP addresses to database servers and internal-only services unless necessary.
4. Calculate Azure-usable IPs correctly. Azure reserves five IPv4 addresses per subnet.
5. Use appropriately sized subnets. Consider the number of resources, scale-out requirements, and service-specific subnet constraints.
6. Separate workloads when useful. Dedicated subnets make routing and security policy management easier.
7. Use NSGs and firewalls. Subnetting provides logical separation, but it does not automatically enforce security isolation.
8. Prefer explicit outbound connectivity. Use a suitable outbound solution, such as NAT Gateway, when private resources require internet access.
9. Document your IP allocations. Maintain a network address plan or use Azure Virtual Network Manager IPAM.
10. Reserve address space for future Azure services. Services such as Azure Firewall, Bastion, and VPN Gateway may need dedicated subnets.
Microsoft provides additional design guidance in its Azure IP Address Planning documentation.
Part 18: Important Interview Questions and Answers
These questions focus specifically on the concepts covered in this article, including IPv4, IPv6, IP address classes, subnetting, CIDR, NAT, and Azure IP allocation.
Group 1: IP Address Fundamentals
Q1. What is an IP address?
An IP address is a logical network address used to identify a network interface and route data packets between devices.
Key point: IP addressing operates at Layer 3 of the OSI model.
Q2. What is the difference between IPv4 and IPv6?
IPv4 uses 32-bit addresses, while IPv6 uses 128-bit addresses. IPv6 provides a much larger address space and uses hexadecimal notation.
Key point: IPv4 supports approximately 4.3 billion addresses.
Q3. Why does an IPv4 address contain four octets?
IPv4 contains 32 bits, divided into four groups of 8 bits.
32 Bits = 4 x 8 Bits
Q4. Why can an IPv4 octet contain only values from 0 to 255?
An octet contains 8 bits, which represent \(2^8=256\) possible values, numbered 0 through 255.
Q5. What is the difference between a public IP and a private IP?
A public IP is intended for routing over the internet, while a private IP is used within private networks and is not directly routed across the public internet.
Q6. What are the three private IPv4 address ranges?
10.0.0.0/8
172.16.0.0/12
192.168.0.0/16
Q7. What is a loopback IP address?
A loopback address allows a computer to communicate with itself. The commonly used IPv4 loopback address is 127.0.0.1.
Q8. What is NAT, and why is it required?
NAT translates IP address information between networks. It commonly allows multiple private devices to share public IPv4 addresses for internet access.
Group 2: IP Address Classes
Q9. What are the five IP address classes?
Class A, B, and C were historically used for different-sized unicast networks. Class D is used for multicast, while Class E is reserved for special or experimental purposes.
Q10. What is the difference between Class A, B, and C?
|
Class |
Historical default mask |
Prefix |
|---|---|---|
|
A |
255.0.0.0 |
/8 |
|
B |
255.255.0.0 |
/16 |
|
C |
255.255.255.0 |
/24 |
Q11. Why was classful addressing replaced?
Classful addressing allocated networks in rigid sizes, wasting IPv4 addresses. CIDR introduced more flexible network allocation.
Group 3: CIDR and Subnetting
Q12. What is CIDR?
CIDR stands for Classless Inter-Domain Routing. It uses a prefix length to identify the network portion of an IP address.
Example:
10.0.1.0/24
Q13. What does /24 mean in CIDR notation?
It means 24 bits are used for the network prefix and 8 bits remain for host addressing.
A /24 contains 256 total IPv4 addresses.
Q14. What is a subnet mask?
A subnet mask identifies the network and host portions of an IPv4 address.
Example:
/24 = 255.255.255.0
Q15. What is the formula for calculating total IPv4 addresses in a CIDR block?
Here, n is the prefix length.
Q16. How many IP addresses are available in a /26 subnet?
A /26 contains 64 total addresses, 62 traditionally usable host addresses, and 59 Azure-usable addresses.
Q17. What is the difference between /24 and /28?
A /24 provides 256 total addresses, while a /28 provides 16.
In Azure, they provide 251 and 11 usable addresses, respectively.
Q18. What is the network address?
The network address is the first address in a subnet and identifies the network.
Example:
192.168.1.0/24
Network:
192.168.1.0
Q19. What is the broadcast address?
It is the last address of a traditional IPv4 subnet, used for directed broadcast within the relevant network context.
Example:
192.168.1.255
Q20. What is VLSM?
VLSM stands for Variable Length Subnet Masking. It allows a parent network to be divided into smaller subnets of different sizes.
Q21. How do you divide a /24 network into four equal subnets?
Borrow two host bits, changing the prefix from /24 to /26.
Each resulting subnet contains 64 total addresses.
Q22. What is the 256 minus the mask method?
It is a shortcut for calculating subnet block sizes.
Example:
/27 Mask: 255.255.255.224
256 - 224 = 32
Block Size = 32
Group 4: Azure Networking
Q23. How many IP addresses does Azure reserve in each IPv4 subnet?
Azure reserves five addresses: the first four and the last address of the subnet.
Q24. How many usable IP addresses are available in an Azure /24 subnet?
Total: 256
Reserved: 5
Usable: 251
Q25. What is the minimum supported IPv4 subnet size in Azure VNet?
The general minimum IPv4 subnet size is /29, providing eight total addresses and three Azure-usable addresses. Individual services can require larger subnets.
Q26. Can two Azure VNets use the same address space?
Yes, when they remain isolated. However, overlapping address spaces generally prevent direct VNet peering.
Q27. Can one Azure VNet have multiple address spaces?
Yes. A VNet can contain multiple non-overlapping address ranges, subject to Azure configuration limits.
Q28. What is the difference between a VNet address space and a subnet?
A VNet address space defines the available IP ranges for the virtual network. A subnet is a smaller address range allocated within that space.
Q29. How does an Azure VM receive its private IP address?
Azure allocates a private IP address to a VM network interface from its subnet. The allocation can be dynamic or static.
Q30. How can a private Azure VM access the internet without a public IP?
It can use an outbound connectivity solution such as Azure NAT Gateway, Azure Firewall, or an appropriately configured load balancer.
Group 5: Scenario-Based Questions
Q31. You need 50 usable IP addresses in Azure. Which subnet would you choose?
A /26 provides 59 Azure-usable IP addresses, so it meets the requirement. Choose a larger subnet if additional growth capacity is required.
Q32. You need 100 usable IP addresses in Azure. Which subnet should you choose?
A /25 provides 123 Azure-usable IP addresses.
Q33. Can you create 10.0.1.0/24 and 10.0.1.128/25 as separate Azure subnets?
No. The second range overlaps with the first. Azure requires non-overlapping subnet ranges within the same VNet.
Q34. A VM has a private IP but no public IP. Can you connect to it from the internet?
Not directly using that private address. You need a suitable connectivity mechanism such as VPN, Azure Bastion, or a controlled public-facing entry point.
Q35. Why should database servers normally use private IP addresses?
Private addressing allows databases to remain inaccessible through direct public IP routing, reducing unnecessary internet exposure. Access must still be controlled through network security policies.
Q36. What happens if your Azure subnet runs out of available IP addresses?
New resources requiring private IP allocations may fail to deploy or scale. You may need to resize the subnet, where supported, or allocate additional address space.
Q37. How would you design subnets for a three-tier application?
Create separate frontend, backend, and database subnets with non-overlapping CIDR ranges. Apply appropriate NSG rules and routing policies to control communication between tiers.
Part 19: Quick Revision — Key Takeaways
|
Concept |
Remember |
|---|---|
|
IPv4 |
32-bit address |
|
IPv6 |
128-bit address |
|
Octet |
8 bits |
|
Maximum octet value |
255 |
|
Private Class A block |
10.0.0.0/8 |
|
Private Class B-derived block |
172.16.0.0/12 |
|
Private Class C-derived block |
192.168.0.0/16 |
|
CIDR |
Classless Inter-Domain Routing |
|
/16 |
65,536 total IPs |
|
/24 |
256 total IPs |
|
/26 |
64 total IPs |
|
/28 |
16 total IPs |
|
Azure reserved addresses |
5 per IPv4 subnet |
|
Azure /24 usable |
251 |
|
Azure /28 usable |
11 |
|
NAT |
Network Address Translation |
|
VLSM |
Variable Length Subnet Masking |
|
NSG |
Network Security Group |
Conclusion
Understanding IP addressing and subnetting is essential before working with Azure Virtual Networks.
IPv4, binary numbers, subnet masks, and CIDR notation form the foundation for designing reliable network architectures.
By learning how to calculate network boundaries, determine usable IP addresses, and allocate non-overlapping subnets, you can make better decisions when deploying Azure virtual machines, application servers, databases, and networking services.
The most important Azure-specific rule to remember is that Azure reserves five IPv4 addresses in every ordinary VNet subnet. Always account for these reservations when planning your network capacity.
What's Next?
Azure Virtual Network (VNet): Address Spaces, Subnets and Network Security Groups
In the next article, we'll apply these concepts by creating a VNet, dividing its address space into subnets, deploying resources, and configuring NSG rules to control network traffic.
Official References
Decimal to Binary Converter - https://www.binaryhexconverter.com/decimal-to-binary-converter
CIDR to IPv4 Conversion - https://www.ipaddressguide.com/cidr
Visual Subnet Calculator - https://www.davidc.net/sites/default/subnets/subnets.html
Tags: Azure Networking, IP Addressing, IPv4, IPv6, Public IP, Private IP, IP Address Classes, CIDR, Subnetting, Subnet Mask, VLSM, NAT, Azure Virtual Network, Azure Subnets, Azure IP Address Planning, Subnet Calculator, Azure Interview Questions, AZ-900, AZ-104