Home / Cloud Networking
Multi-Cloud & DevOps Guide

Universal Cloud Networking Flows: CIDR, Subnets & NAT Across AWS, Azure, and GCP 🌐

A deep dive into IPv4 CIDR allocation, regional vs. global virtual networks, and outbound NAT routing architectures across the big three cloud providers.

Published by AHP • cicdclouds.com

1. Universal Foundation: CIDR (Classless Inter-Domain Routing)

Before diving into how AWS, Azure, and Google Cloud route traffic, every cloud network relies on CIDR (Classless Inter-Domain Routing). CIDR is the universal method for allocating IP addresses and IP routing, developed to replace the older, wasteful class-based network addressing system (Class A, B, and C).

At its core, CIDR uses Variable-Length Subnet Masking (VLSM). Instead of fixed network sizes, CIDR allows a cloud virtual network to be divided into smaller, right-sized subnets.

CIDR Block Breakdown (192.168.1.0/24)

  • 192.168.1.0: The network address or base IP address of the block.
  • /24: The CIDR suffix (prefix length), indicating how many bits out of the 32-bit IPv4 address are locked for the Network ID.
IPv4 Total Length            : 32 bits (4 Octets / 4 Bytes)
Network Bits (First 24 bits) : 11000000.10101000.00000001
Host Bits (32 - 24 = 8 bits) : .00000000

Total Possible IPs           : 2^8 = 256 IP addresses
Standard Usable Hosts        : 256 - 2 = 254 usable IPs (Network .0 and Broadcast .255 reserved)
*Note: Cloud providers reserve additional IPs per subnet (AWS & Azure reserve 5 IPs; GCP reserves 4 IPs).

Benefits of CIDR in Cloud Environments

  • Efficient IP Allocation: Cloud architects can carve out /24, /26, or /28 subnets matching exact microservice or Kubernetes node requirements.
  • Reduced Routing Table Size: Route aggregation summarizes multiple smaller subnets into a single supernet route entry.
  • Hierarchical Multi-Cloud Routing: Prevents overlapping IP ranges when connecting on-premises data centers to AWS, Azure, and GCP via VPN or Dedicated Interconnects.

2. Types of Network IPs: Public vs. Private (RFC 1918)

Across all cloud providers, IP addresses are split into two scopes:

  • Public IP Addresses: Globally unique, assigned by IANA/RIRs, and directly routable over the public internet (assigned to Internet Gateways, Load Balancers, and NAT Gateways).
  • Private IP Addresses (RFC 1918): Reserved exclusively for internal virtual networks (VPCs/VNets). They are not routable on the public internet and require NAT (Network Address Translation) to reach external APIs or software repositories.

🌐 IPv4 Address Class Ranges

Class Starting Address Ending Address Default Mask Purpose
Class A 1.0.0.0 126.255.255.255 /8 (N.H.H.H) Unicast (Large Networks)
Class B 128.0.0.0 191.255.255.255 /16 (N.N.H.H) Unicast (Medium Networks)
Class C 192.0.0.0 223.255.255.255 /24 (N.N.N.H) Unicast (Small Networks)
Class D 224.0.0.0 239.255.255.255 N/A Multicast
Class E 240.0.0.0 255.255.255.255 N/A Experimental / Reserved

Note: 127.0.0.0/8 (typically 127.0.0.1) is reserved for host Loopback testing.

🔒 Private IPv4 Address Ranges (Used for Cloud VPCs & VNets)

RFC 1918 Range Classful Equivalent CIDR Block Cloud Usage
10.0.0.0 – 10.255.255.255 1 Class A Network 10.0.0.0/8 Standard choice for Enterprise AWS VPCs, Azure VNets, and GCP Subnets.
172.16.0.0 – 172.31.255.255 16 Class B Networks 172.16.0.0/12 Used by default VPCs and Docker bridge networks.
192.168.0.0 – 192.168.255.255 256 Class C Networks 192.168.0.0/16 Commonly used in small clouds, home labs, or on-prem branches to avoid overlapping with 10.x.x.x.

Binary Representation: Network ID (1) vs. Host ID (0)

# 32 Bits Total -> 8 Bits = 1 Byte -> 32 / 8 = 4 Octets
Class A (N.H.H.H) : 11111111 . 00000000 . 00000000 . 00000000  (255.0.0.0)
Class B (N.N.H.H) : 11111111 . 11111111 . 00000000 . 00000000  (255.255.0.0)
Class C (N.N.N.H) : 11111111 . 11111111 . 11111111 . 00000000  (255.255.255.0)

3. Cloud Networking Architecture: AWS & Azure (Regional) vs. GCP (Global)

While CIDR and Private IPs work the same everywhere, the logical boundary of a Virtual Network differs dramatically between AWS/Azure and Google Cloud:

  • AWS & Microsoft Azure are Regional: A Virtual Network (AWS VPC or Azure VNet) lives inside a single Region. To connect resources across different regions, you must explicitly link separate networks using VPC/VNet Peering, AWS Transit Gateway, or Azure Virtual WAN.
  • Google Cloud (GCP) is Global: A GCP VPC is a global, universal network spanning all regions across the world simultaneously. The VPC itself has no CIDR range; instead, each Subnet is Regional and holds its own CIDR range. VMs in different continents inside the same GCP VPC communicate privately by default over Google's backbone without peering!

🟠 AWS VPC (Regional)

  • VPC Scope: Regional (e.g., ap-south-1)
  • Subnet Scope: Zonal (Tied to 1 Availability Zone)
  • Cross-Region Flow: Requires VPC Peering or Transit Gateway.

🔵 Azure VNet (Regional)

  • VNet Scope: Regional (e.g., Central India)
  • Subnet Scope: Regional (Spans all AZs in that Region)
  • Cross-Region Flow: Requires Global VNet Peering or Virtual WAN.

🟢 GCP VPC (Global)

  • VPC Scope: Global (Universal across all regions)
  • Subnet Scope: Regional (Spans all Zones in a Region)
  • Cross-Region Flow: Built-in! Subnets in US and India route privately out-of-the-box.

Multi-Cloud Virtual Network Comparison Matrix

Networking Feature AWS (Amazon Web Services) Microsoft Azure Google Cloud (GCP)
Virtual Network Name Amazon VPC Virtual Network (VNet) Google Cloud VPC
Network Boundary Scope Regional Regional Global (Universal)
Subnet Boundary Scope 1 Availability Zone (Zonal) Regional (Spans AZs) Regional (Spans Zones)
Reserved IPs per Subnet 5 IPs (First 4 + Last 1) 5 IPs (First 4 + Last 1) 4 IPs (First 2 + Second-to-last + Last 1)
Static Public IP Name Elastic IP (EIP) Standard Public IP Address Reserved External Static IP
Managed NAT Service AWS NAT Gateway Azure NAT Gateway Cloud NAT (via Cloud Router)
Stateful Firewall Security Groups (NIC level) + NACLs (Subnet) Network Security Groups (NSG) VPC Firewall Rules / Policies (Global/Regional)
Hybrid VPN / Dedicated Link Site-to-Site VPN / Direct Connect VPN Gateway / ExpressRoute Cloud VPN / Cloud Interconnect

4. Private Subnet to Internet Flow: How NAT Gateways Work

Across all clouds, production databases and application servers are placed in Private Subnets (no public IPs assigned to VMs). To download OS patches or call external APIs without exposing the servers to inbound internet attacks, traffic flows out through a NAT (Network Address Translation) Gateway.

Visualizing the Outbound NAT Flow Across Clouds

[1] AWS Outbound Flow (Public Subnet Proxy Model):
Private Subnet VM (10.0.2.15) 
  ──► Private Route Table (0.0.0.0/0 -> nat-gw-id) 
  ──► NAT Gateway (Lives in Public Subnet + Uses Elastic IP) 
  ──► Public Route Table (0.0.0.0/0 -> igw-id) 
  ──► Internet Gateway (IGW) ──► Public Internet

[2] Azure Outbound Flow (Direct Subnet Attachment Model):
Private Subnet VM (10.1.1.10) 
  ──► Azure NAT Gateway (Directly attached to Private Subnet + Uses Standard Public IP) 
  ──► Azure Internet Backbone (No Public Subnet or manual Route Table required!)

[3] GCP Outbound Flow (Software-Defined Global VPC Model):
Regional Subnet VM (10.2.0.5 - No External IP) 
  ──► Cloud NAT + Cloud Router (Control-Plane Software Defined + External Static IP) 
  ──► Default Internet Gateway ──► Public Internet

Deep Dive: AWS NAT Gateway & Elastic IP Rules

Because AWS uses a strict subnet-routing model, setting up a NAT Gateway in AWS requires understanding seven critical rules:

Aspect Core Rule Architectural Explanation
Primary Goal Private subnet connects to the internet. Allows private instances to initiate outbound connections (patches, updates, webhooks) while staying hidden from the public internet.
Inbound Security Blocks unsolicited inbound traffic. NAT Gateways are stateful and one-way. External attackers cannot initiate inbound connections through a NAT Gateway to reach private VMs.
Cost Chargeable service (in AWS, Azure, and GCP). Incurs costs based on: 1) Hourly provisioning charge, and 2) Per-GB data processing charge for all traffic flowing through it.
Deployment Location AWS: Must reside in a Public Subnet. In AWS, the NAT Gateway itself must sit in a Public Subnet so it has a direct route to the Internet Gateway (IGW). (In Azure and GCP, no public subnet is needed for NAT).
IP Requirement Requires an Elastic IP (EIP). Requires a dedicated static public IPv4 address (EIP in AWS, Standard Public IP in Azure, External IP in GCP) to masquerade outbound traffic.
Routing Configuration Services the Private Subnet via Route Table. In AWS, the Private Subnet's Route Table must have a route sending 0.0.0.0/0 to the nat-gateway-id.
Association Summary Associated with Private Subnet(s). Multiple private subnets can route their internet-bound traffic through a NAT Gateway. For high availability in AWS, deploy one NAT Gateway per Availability Zone.

💡 Critical Prerequisite: Elastic IP (EIP) Allocation Rules

In AWS, before creating a Public NAT Gateway, an Elastic IP (EIP) must be allocated, and the Private Subnet's Route Table must be edited to route 0.0.0.0/0 traffic to the NAT Gateway.

Crucially, in AWS an Elastic IP can only be associated with ONE resource at a time:

  • An EC2 Instance
  • An Elastic Network Interface (ENI)
  • A NAT Gateway

Note: In Azure and GCP, a single NAT Gateway can have multiple Public IPs (up to 16 in Azure) attached simultaneously to scale out SNAT ports for heavy outbound workloads.