Networking Fundamentals
This chapter will teach you everything about networking in Azure, starting from absolute basics. We’ll explain what networking actually is, why it matters, and how to build secure, scalable network architectures from scratch.What You’ll Learn
By the end of this chapter, you’ll understand:- What networking is and why applications need it (from scratch)
- IP addresses, subnets, and CIDR notation explained simply
- Virtual Networks (VNets) and how they work
- Network Security Groups (NSGs) and firewall rules
- Private vs Public networking (when to use each)
- How to design secure network architectures
- Common networking patterns and best practices
What is Networking? (Start Here if You’re New)
Let’s start with the absolute basics.The Simple Explanation
Networking = How computers talk to each other When you:- Visit a website → Your computer talks to a web server
- Send an email → Your email app talks to an email server
- Watch a video → Your device talks to a video streaming server
Real-World Analogy: Postal System
Think of networking like the postal system: Postal System:- Every house has an address (123 Main Street)
- Mail is delivered based on address
- Post office routes mail to correct destination
- Can send letters anywhere in the world
- Every computer has an IP address (192.168.1.10)
- Data is delivered based on IP address
- Routers route data to correct destination
- Can send data anywhere on the internet
Why Do Applications Need Networking?
Without Networking:What is an IP Address?
IP Address = The unique address of a computer on a network Just like your home address (123 Main Street, New York, NY 10001), every computer needs an address so others can find it. Two Types of IP Addresses: IPv4 (What we’ll use):Public vs Private IP Addresses
This is CRITICAL to understand: Public IP Addresses:What is a Virtual Network (VNet)?
VNet = Your private network in Azure’s datacenter Real-World Analogy: Office BuildingUnderstanding CIDR Notation (The /16, /24 Numbers)
CIDR (Classless Inter-Domain Routing) is just a way to specify how many IP addresses you have. The Simple Rule:| CIDR | Addresses | Typical Use |
|---|---|---|
| /8 | 16.7 million | Entire cloud provider |
| /16 | 65,536 | VNet address space |
| /20 | 4,096 | Large subnet (Kubernetes) |
| /24 | 256 | Standard subnet |
| /26 | 64 | Small subnet |
| /28 | 16 | Tiny subnet (gateways) |
| /32 | 1 | Single IP address |
Under the Hood: The “Magic” of SDN
How does Azure move billions of packets per second between virtual machines without a physical router for every customer? This is the power of Software Defined Networking (SDN).The Virtual Filter (Host Agent)
When your VM sends a packet, it doesn’t just hit a wire. It hits the Azure Virtual Filtering Platform (VFP), which is an extension of the Hyper-V switch in the physical host.- Stateful Inspection: The Host Agent checks if this packet matches your NSG rules.
- Encapsulation: If allowed, the packet is wrapped (encapsulated) in a VXLAN/NVGRE tunnel.
- The Global Backbone: The packet travels over the physical datacenter network.
- Decapsulation: The destination host unwraps the packet and delivers it to the target VM.
The WireServer (168.63.129.16)
You will see this IP address in your network logs frequently. It is the Azure WireServer. It is a “magic” IP that exists in every subnet but doesn’t live on any specific machine. It provides:- DNS: Resolving internal Azure names.
- DHCP: Assigning IP addresses to your VMs.
- Health Probes: Checking if your VMs are alive for the Load Balancer.
[!IMPORTANT]
Pro Tip: Don’t Block the Magic
If you create a custom NSG that blocks 168.63.129.16, your VM’s health probes will fail, it will lose its IP address, and it will effectively “disappear” from the network. Always allow this IP in your custom configurations.
Network Security: How to Control Traffic
Now that you understand IP addresses and VNets, let’s learn how to SECURE them.What is a Firewall?
Firewall = A security guard that controls what traffic is allowed Real-World Analogy: Building SecurityNetwork Security Groups (NSGs)
NSG = Azure’s firewall for VNets and VMs How NSGs Work:Real-World Example: 3-Tier Web Application
Let’s design a complete network architecture:1. IP Addressing & Subnetting Strategy
Correctly planning your IP address space is the single most critical step. You cannot easily change a VNet’s address space after peering it.CIDR Deep Dive
Azure uses Classless Inter-Domain Routing (CIDR) notation.
[!TIP]
Jargon Alert: CIDR Block
A way to state “IP Address + Network Size”.
10.0.0.0/16 means “Start at 10.0.0.0, and the first 16 bits are fixed.” The remaining 16 bits are for your devices.
Subnet Calculation Cheat Sheet
| CIDR | Total IPs | Usable IPs (Azure) | Use Case |
|---|---|---|---|
/16 | 65,536 | 65,531 | VNet Address Space (Standard enterprise size) |
/20 | 4,096 | 4,091 | Large Subnet (AKS Clusters) |
/24 | 256 | 251 | Standard Subnet (Web tier, App tier) |
/26 | 64 | 59 | Gateway Subnet (VPN/ExpressRoute) |
/27 | 32 | 27 | Azure Bastion (Required size) |
/29 | 8 | 3 | Tiny Subnet (Azure Firewall management) |
[!WARNING] Gotcha: Azure’s 5 Reserved IPs In every subnet, Azure reserves 5 IP addresses:Implication: A
x.x.x.0: Network addressx.x.x.1: Default gatewayx.x.x.2: Azure DNS mappingx.x.x.3: Azure DNS mappingx.x.x.255: Broadcast address (Azure doesn’t support broadcast)/29subnet only has 3 usable IPs!
2. Network Security Groups (NSG) vs Application Security Groups (ASG)
Network Security Groups (NSG)
The firewall for your subnet or network interface (NIC). It contains a list of Allow/Deny rules. Key Rules:- Priority: Lower number = Higher priority (100 overrides 200).
- 5-Tuple: Source IP, Source Port, Dest IP, Dest Port, Protocol.
- Stateful: If you allow traffic IN, the response OUT is automatically allowed.
Application Security Groups (ASG)
ASGs allow you to group VMs by their function rather than their IP address. The Problem: You have 10 web servers. You want to allow Port 80 to all of them. Traditional Way: Create an NSG rule for each IP, or put them all in one tidy subnet. ASG Way: Tag the NICs with “WebASG”. Create ONE NSG rule: “Allow Internet to WebASG”.[!NOTE] Deep Dive: When to use ASGs? Use ASGs when you have multiple fast-changing workloads in a single subnet and need granular micro-segmentation. If you just have tiered subnets (Web, App, DB), standard subnet-level NSGs are usually cleaner.
3. Secure Access: Service Endpoints vs Private Link
This is a favorite interview topic. Both secure access to PaaS (SQL, Storage), but differently.| Feature | Service Endpoints | Private Link (Private Endpoint) |
|---|---|---|
| Traffic Path | Optimized route over Azure backbone | Private IP inside your VNet |
| PaaS IP | Public IP | Private IP (e.g., 10.0.1.5) |
| On-Prem Access | No (unless forced tunneling) | Yes (via VPN/ExpressRoute) |
| Data Exfiltration | Harder to block | protected (maps to specific instance) |
| Cost | Free | $/hour + Data processing charge |
Service Endpoints
“leaves” your VNet to talk to the Public PaaS resource, but Azure recognizes the traffic is coming from your subnet.Packet Path Analysis: Service Endpoints vs. Private Link
To truly master this, you must understand where the packet goes. Service Endpoint Packet Path:- VM (10.0.1.5) → Next Hop: “VirtualNetwork”
- Traffic hits the Azure Backbone.
- Source IP is changed (Internal SNAT) to a Microsoft-owned Public IP.
- Destination is the Regional Public IP of the Storage/SQL service.
- Security: The PaaS resource must have its firewall configured to “Allow access from Virtual Network X”.
- VM (10.0.1.5) → Next Hop: 10.0.1.10 (The Private Endpoint IP)
- Traffic never leaves your VNet.
- Destination is a Local Private IP sitting inside your subnet.
- Security: The PaaS resource’s public network access can be set to DISABLED. It is literally invisible to the internet.
[!IMPORTANT] Pro Tip: DNS is the Hard Part When you use Private Link, your app still wants to talk tomystorage.blob.core.windows.net. You need a Private DNS Zone linked to your VNet so thatmystorage.blob.core.windows.netresolves to10.0.1.10instead of the public IP.
4. Subnet Delegation
Some Azure services require a “Delegated Subnet”. This means they take full control of that subnet—you cannot put anything else in it. Services requiring delegation:- Azure NetApp Files
- Azure SQL Managed Instance
- App Service VNet Integration (Standard)
- Azure Databricks
[!WARNING] Gotcha: Subnet Delegation sizing Once delegated, resizing is painful. Azure SQL Managed Instance requires a minimum/27, but Microsoft recommends/26or/25for scaling. If you start too small, you have to rebuild the cluster.
Hub-and-Spoke Topology
This is the standard architecture for enterprise Azure environments. Instead of peering every VNet to every other VNet (which creates a “Spaghetti Network”), you use a Central Hub. Why professionals use Hub-and-Spoke:- Shared Services: Place your Firewall, VPN Gateway, and Domain Controllers in the Hub to save money and simplify management.
- Security: All traffic between Spokes (Spoke A to Spoke B) must pass through the Hub’s Firewall (“East-West” traffic filtering).
- No Transitivity: By default, Spoke A cannot talk to Spoke B. This provides excellent isolation for Dev/Test vs Production.
Troubleshooting: “My VM Can’t Talk to XXX”
Networking is the most common cause of deployment failures. Use this checklist to debug like a pro.1. The NSG Check
- Inbound vs. Outbound: Did you allow port 80 Inbound? Great. Did you also allow port 80 Outbound from the source?
- Priority: Is there a higher priority rule (e.g., Priority 100 Deny All) blocking your rule (Priority 200 Allow HTTP)?
- Effective Rules: Using the portal, go to the VM → Networking → Effective security rules. This shows the final result of ALL NSGs combined.
2. The Next Hop Check
- UDRs (User Defined Routes): Is there a routing table sending your traffic to a Firewall (NVA) that is dropping it?
- VNet Peering: Is the peering status
Connected? If it’sInitiated, you forgot to create the peering link on the other side. - Transitivity: Are you trying to talk to Spoke B from Spoke A through a Hub? Remember, peering is NOT transitive. You need a device in the Hub to route the traffic.
3. The PaaS Connectivity Check
- NSG vs. Firewall: If using Service Endpoints, did you add the Subnet to the SQL/Storage firewall?
- Private DNS: If using Private Link, does
ping mystorage.blob.core.windows.netreturn a private IP or a public IP? If public, your DNS is broken.
[!TIP] Pro Tool: Connection Troubleshoot In Azure Network Watcher, use the “Connection Troubleshoot” tool. It will tell you exactly where the packet is being dropped—is it an NSG, a Route, or the OS firewall inside the VM?