Cloud NetworkingCloud Networking
Thuộc bộ kiến thức Network Engineer Roadmap.
Tổng quan
Cloud networking là việc thiết kế, xây dựng và vận hành network bên trong một public cloud provider (AWS, Azure, GCP) hoặc trên edge của một provider như Cloudflare. Lớp vật lý — cáp, switch, router, optic, data-center fabric — vẫn tồn tại, nhưng bạn không bao giờ đụng tới. Thay vào đó, bạn mô tả network mình muốn qua API hoặc Infrastructure-as-Code, và software-defined networking (SDN) của provider sẽ lập trình phần cứng bên dưới cho khớp với ý định của bạn.
Với một network engineer đến từ thế giới on-prem, tin vui là phần nền tảng không thay đổi: vẫn là IP addressing (./05-ip-addressing-and-subnetting.md), CIDR, subnet, route table (./07-routing.md), NAT, firewall/ACL (./11-network-security.md), DNS, VPN/tunnel (./12-vpn-and-tunneling.md), và load balancing. Cái thay đổi là mức trừu tượng và mô hình vận hành: bạn cấu hình bằng resource khai báo (declarative) thay vì gõ CLI trên một hộp vật lý, bạn trả tiền theo mức dùng (pay-per-use), và trách nhiệm về bảo mật lẫn tính sẵn sàng được chia sẻ giữa bạn và provider.
Note này bao gồm:
- Cloud networking khác on-prem thế nào — software-defined, API-driven, co giãn (elastic), pay-per-use, và shared responsibility model.
- Virtual network — VPC/VNet, public vs private subnet, quy hoạch CIDR, route table, internet gateway, NAT gateway, và kiểm soát egress.
- Kết nối giữa và vào cloud — VPC peering, transit gateway / hub-and-spoke, VPN gateway, dedicated interconnect (Direct Connect / ExpressRoute / Cloud Interconnect), và PrivateLink / private endpoint.
- Security control trên cloud — security group (stateful) vs network ACL (stateless), cloud firewall, và WAF.
- Routing & DNS trên cloud — route propagation, Route 53 / Cloud DNS / Azure DNS, và private hosted zone.
- Load balancing & CDN — cloud load balancer L4/L7, global vs regional, CDN và anycast.
- Cloudflare — như một provider edge, bảo mật và DNS, cùng các public resolver như
1.1.1.1. - Một bảng so sánh thuật ngữ giữa các provider (AWS vs Azure vs GCP).
Các note sâu hơn theo từng provider nằm trong ../../cloud/README.md — xem ../../cloud/aws/README.md và ../../cloud/gcp/README.md.
Kiến thức nền tảng
Cloud networking khác on-prem thế nào
| Khía cạnh | On-premises | Cloud |
|---|---|---|
| Cấp phát | Gắn phần cứng, đi cáp, cấu hình CLI từng thiết bị | API / IaC khai báo (Terraform, CloudFormation) |
| Thời gian triển khai | Vài ngày đến vài tuần | Vài giây đến vài phút |
| Mở rộng | Mua trước năng lực theo dự báo | Co giãn; scale up/out theo nhu cầu |
| Mô hình chi phí | CapEx trả trước | OpEx, pay-per-use (theo giờ, theo GB egress) |
| Control plane | Bạn sở hữu switch/router | SDN của provider; bạn sở hữu ý định, không phải phần cứng |
| Data plane | Fabric vật lý của bạn | Overlay của provider trên phần cứng dùng chung |
| Failure domain | Tòa nhà/phòng của bạn | Region và Availability Zone (AZ) |
| Trách nhiệm | Bạn lo tất cả | Shared responsibility model |
Ý tưởng cốt lõi là software-defined networking. VPC, subnet và route table của bạn không phải thiết bị vật lý — chúng là các entry trong control plane phân tán của provider, được đẩy xuống các host ảo hóa. Đó là lý do một thay đổi route table hay một firewall rule mới có hiệu lực trong vài giây, và vì sao không có “spanning tree”, không có lỗi đấu cáp, cũng không có config drift theo từng switch như kiểu truyền thống.
Shared responsibility model
Bảo mật và tính sẵn sàng được chia đôi:
- Provider chịu trách nhiệm về “the cloud” — network vật lý, hypervisor, backbone SDN, DDoS protection ở tầng hạ tầng, và dự phòng vật lý/theo region.
- Bạn chịu trách nhiệm về “in the cloud” — thiết kế VPC, cách đặt subnet, route table, security group/NACL, mã hóa dữ liệu on the wire, quản lý key, IAM cho network resource, và cách bạn expose service ra internet.
Một security group cấu hình sai hay một route quá rộng là lỗi của bạn, không phải của provider. Đây là nguồn gốc số một của các vụ rò rỉ trên cloud. Xem ./11-network-security.md cho các nguyên tắc bảo mật vẫn còn áp dụng.
Region, Availability Zone, và edge
- Region — một khu vực địa lý (ví dụ
us-east-1,europe-west1). Mỗi region được cô lập để chịu lỗi (fault tolerance) và đáp ứng data residency. - Availability Zone (AZ) — một hoặc nhiều data center riêng biệt trong một region, độc lập về điện/làm mát/network. Trải subnet qua nhiều AZ là cách bạn xây kiến trúc high availability.
- Edge / Point of Presence (PoP) — các vị trí nhỏ hơn khắp thế giới, dùng bởi CDN, DNS và global load balancer để terminate kết nối gần người dùng.
Một VPC là regional (trải qua tất cả AZ trong region), còn subnet gắn với một AZ duy nhất trong AWS (ở Azure và GCP subnet là regional). Điều này ảnh hưởng trực tiếp đến cách bạn bố trí dải CIDR cho high availability.
Khái niệm chính
Virtual network: VPC / VNet
Một VPC (Virtual Private Cloud, AWS/GCP) hoặc VNet (Virtual Network, Azure) là lát cắt riêng tư, cô lập về mặt logic của bạn trong network của provider. Bạn định nghĩa không gian địa chỉ tổng thể bằng một hay nhiều CIDR block (ví dụ 10.0.0.0/16), và mọi thứ khác nằm bên trong nó.
Tính chất quan trọng:
- Dùng dải private RFC 1918 (
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16). Chọn dải sẽ không trùng (overlap) với network on-prem hay các VPC khác mà sau này bạn có thể peer — CIDR trùng nhau thì không thể peer được. - VPC mặc định bị cô lập; không có gì route vào hay ra cho tới khi bạn thêm gateway và route một cách tường minh.
- Bạn có thể gắn nhiều CIDR block để mở rộng một VPC đã hết chỗ.
Subnet: public vs private
Một subnet là một lát của VPC CIDR, và đó là nơi resource của bạn (VM, container, load balancer, database) thực sự nhận IP.
- Public subnet — route table của nó có default route (
0.0.0.0/0) trỏ tới một internet gateway (IGW). Resource ở đây có thể có public IP và được truy cập từ internet. - Private subnet — không có route trực tiếp tới IGW. Resource chỉ có private IP và ra internet (để update, gọi API) qua một NAT gateway, hoặc không ra được.
Sự phân biệt public/private thuần túy là một quyết định routing — một subnet là “public” vì route table gửi 0.0.0.0/0 tới IGW, chỉ vậy thôi. Best practice là giữ application server và database trong private subnet, và chỉ expose load balancer / bastion host trong public subnet.
VPC 10.0.0.0/16
├── Public subnet 10.0.0.0/24 (AZ-a) -> route 0.0.0.0/0 tới IGW [ALB, NAT GW]
├── Public subnet 10.0.1.0/24 (AZ-b) -> route 0.0.0.0/0 tới IGW
├── Private subnet 10.0.10.0/24 (AZ-a) -> route 0.0.0.0/0 tới NAT GW [app server]
├── Private subnet 10.0.11.0/24 (AZ-b) -> route 0.0.0.0/0 tới NAT GW
├── Data subnet 10.0.20.0/24 (AZ-a) -> không có route 0.0.0.0/0 [database]
└── Data subnet 10.0.21.0/24 (AZ-b) -> không có route 0.0.0.0/0
Quy hoạch CIDR
Quy hoạch CIDR trên cloud dùng đúng phép toán subnetting như on-prem (./05-ip-addressing-and-subnetting.md), kèm vài quy tắc riêng của cloud:
- Chừa chỗ để lớn. Một pattern phổ biến là VPC
/16chia thành các subnet/24(256 subnet, mỗi subnet 251 host dùng được sau khi provider reserve). - Provider reserve địa chỉ trong mọi subnet. AWS reserve 4 địa chỉ đầu và 1 địa chỉ cuối của mỗi subnet (network, VPC router, DNS, dành cho tương lai, broadcast). Nên một
/24cho 251 host dùng được, không phải 254. - Đừng bao giờ overlap CIDR giữa các VPC bạn định peer, hay với dải on-prem.
- Dành các tier riêng cho từng AZ (public/private/data × 2-3 AZ) để dựng high availability đa AZ.
Route table, internet gateway, NAT gateway, egress
- Route table — tập hợp route gắn vào một hay nhiều subnet. Mỗi route map một destination CIDR tới một target (IGW, NAT GW, peering connection, transit gateway, VPN gateway, VPC endpoint). Match cụ thể nhất (longest-prefix) thắng, y hệt routing truyền thống (./07-routing.md).
- Internet gateway (IGW) — một thành phần scale ngang, high availability, cho phép VPC gửi/nhận traffic với internet. Nó cũng thực hiện NAT 1:1 cho instance có public IP.
- NAT gateway — một thiết bị source NAT (PAT) được quản lý, đặt trong public subnet. Instance ở private subnet route
0.0.0.0/0tới nó để có thể tạo kết nối outbound (patch, pull image, gọi API) trong khi vẫn không thể bị truy cập từ internet. Nó một chiều: không có inbound tự phát. - Chi phí & kiểm soát egress — dữ liệu ra internet (egress) bị tính tiền theo GB, và traffic cross-AZ / cross-region thường cũng tốn tiền. NAT gateway tính tiền theo giờ và theo GB xử lý. Điều này khiến egress trở thành mối bận tâm về thiết kế lẫn chi phí: dùng VPC endpoint để giữ traffic khỏi đường NAT/internet, và cân nhắc kỹ lượng “chatter” cross-AZ. Một egress-only internet gateway là tương đương IPv6 của NAT gateway (chỉ outbound).
Các lựa chọn kết nối trên cloud
Kết nối VPC với nhau, với on-prem, và với service là một trong những mảng phong phú nhất của cloud networking.
VPC peering
Một kết nối private 1:1 giữa hai VPC. Traffic dùng private IP và không bao giờ chạm internet. Peering:
- Không bắc cầu (non-transitive) — nếu A peer B và B peer C, A không thể tới C qua B. Đây là hạn chế then chốt đẩy các thiết kế lớn về hướng dùng hub.
- Bị chặn khi CIDR overlap.
- Đơn giản và rẻ cho vài VPC, nhưng mesh bùng nổ (N×(N-1)/2 link) khi thêm nhiều VPC.
Transit gateway / hub-and-spoke
Một transit gateway (AWS Transit Gateway, Azure Virtual WAN / VNet peering qua hub, GCP Network Connectivity Center) là một cloud router nối nhiều VPC, VPN, và link Direct Connect/Interconnect theo topology hub-and-spoke. Nó bắc cầu (transitive), nên mọi VPC đính kèm đều tới được nhau qua hub, thay thế cho một full mesh peering không thể quản nổi. Bạn kiểm soát khả năng tiếp cận bằng route table trên transit gateway và có thể phân đoạn môi trường (prod/dev) thành các route domain riêng.
VPN gateway
Một site-to-site IPsec VPN qua public internet giữa network on-prem của bạn (hoặc một cloud khác) và một VPN gateway trong VPC. Được mã hóa, dựng nhanh, và rẻ — nhưng throughput và latency phụ thuộc internet. Thường triển khai làm backup cho một link dedicated, và dùng BGP để trao đổi route động. Xem ./12-vpn-and-tunneling.md cho nền tảng IPsec/tunneling.
Dedicated interconnect (đường riêng)
Một kết nối vật lý riêng, dedicated từ data center của bạn tới provider, bỏ qua public internet để có băng thông ổn định, latency thấp hơn, và chi phí egress thấp hơn ở quy mô lớn:
- AWS Direct Connect
- Azure ExpressRoute
- GCP Cloud Interconnect (Dedicated hoặc Partner)
Đây là lựa chọn cấp doanh nghiệp cho kết nối hybrid ổn định, khối lượng lớn. Chúng thường chạy BGP và được ghép với một VPN để mã hóa/dự phòng.
PrivateLink / private endpoint
PrivateLink (AWS), Private Endpoint / Private Link (Azure), và Private Service Connect (GCP) cho phép bạn dùng một service (managed service như S3/DynamoDB, hoặc một service SaaS/bên thứ ba) qua một private IP bên trong VPC của bạn, để traffic không bao giờ rời backbone của provider hay đi qua internet. Đây là cách hiện đại để tiếp cận cloud service một cách private mà không cần mở egress hay dùng public endpoint, và cũng cho phép một nhà cung cấp SaaS expose app của họ một cách private tới khách hàng.
| Lựa chọn kết nối | Dùng cho | Bắc cầu? | Qua internet? |
|---|---|---|---|
| VPC peering | Vài VPC, link private trực tiếp | Không | Không |
| Transit gateway | Nhiều VPC / hybrid ở quy mô lớn | Có | Không |
| VPN gateway | Hybrid qua internet, link backup | Qua BGP/TGW | Có (mã hóa) |
| Direct Connect / ExpressRoute / Interconnect | Hybrid khối lượng lớn, latency thấp | Qua TGW | Không (đường riêng) |
| PrivateLink / private endpoint | Truy cập private tới một service cụ thể | N/A | Không |
Security control trên cloud
Firewall trên cloud diễn ra ở hai lớp chính; cả hai đều dựa trên các khái niệm ACL/firewall trong ./11-network-security.md.
Security group (stateful) vs network ACL (stateless)
| Security group | Network ACL | |
|---|---|---|
| Gắn vào | Instance/ENI (mức resource) | Subnet |
| Trạng thái | Stateful — traffic trả về tự động được cho phép | Stateless — phải cho phép traffic trả về tường minh |
| Rule | Chỉ allow | Allow và deny |
| Đánh giá | Xét tất cả rule; nếu có rule nào allow thì cho qua | Xét theo thứ tự số, match đầu tiên thắng |
| Mặc định | Deny toàn bộ inbound, allow toàn bộ outbound | NACL mặc định allow tất cả; NACL tùy chỉnh deny tất cả |
| Vai trò điển hình | Control chính (theo tier: web/app/db) | Guardrail thô ở mức subnet, deny tường minh |
Quy tắc ngón tay cái: làm phần lớn công việc với security group (stateful, dễ, theo từng resource). Dùng NACL như một lớp chặn rộng ở mức subnet hoặc để block các bad actor cụ thể. Một pattern mạnh là tham chiếu một security group khác làm source (ví dụ “cho phép SG của app-tier tới SG của db-tier trên cổng 5432”) thay vì hard-code IP.
Tương đương của Azure là Network Security Group (NSG) (stateful, áp cho subnet hoặc NIC); GCP dùng VPC firewall rules (stateful, áp theo target tag/service account ở mức network).
Cloud firewall và WAF
- Managed network firewall — AWS Network Firewall, Azure Firewall, GCP Cloud Firewall / firewall policy — cung cấp inspection tập trung, stateful, L3–L7, thường đặt ở hub, với các tính năng như domain filtering và IDS/IPS.
- Web Application Firewall (WAF) — AWS WAF, Azure WAF, Google Cloud Armor, Cloudflare WAF — inspect HTTP(S) ở L7 để chặn SQLi, XSS, bad bot, và áp rate limit. Triển khai trước load balancer / CDN. DDoS protection (AWS Shield, Azure DDoS Protection, Cloud Armor, Cloudflare) thường đi kèm với WAF/edge.
Routing và DNS trên cloud
Route propagation
Route trong một route table hoặc là static (bạn tự thêm) hoặc là propagated (học động). Một VPN gateway hay transit gateway dùng BGP có thể propagate route on-prem vào route table của VPC một cách tự động, để bạn không phải bảo trì entry static bằng tay. Longest-prefix match vẫn quyết định route nào được chọn (./07-routing.md).
Cloud DNS
Mỗi provider chạy một dịch vụ DNS được quản lý, high availability:
- AWS Route 53, Azure DNS, Google Cloud DNS.
- Public hosted zone phục vụ domain của bạn ra internet (authoritative DNS), với health check và routing policy (latency, geolocation, weighted, failover).
- Private hosted zone phân giải tên chỉ bên trong VPC của bạn — ví dụ
db.internal.example.com→ một private IP — để các service nội bộ tìm thấy nhau mà không lộ record ra công khai. - Provider cũng cấp cho mỗi VPC một resolver tích hợp (ví dụ AWS ở địa chỉ
.2của VPC CIDR, “Amazon-provided DNS”) vừa phân giải tên public vừa phân giải private zone, và có thể forward tới DNS on-prem.
Load balancing và CDN
Cloud load balancer
Cloud load balancer được quản lý, co giãn, và high availability qua nhiều AZ:
- Layer 4 (network) LB — route theo IP/port, throughput rất cao, giữ nguyên source IP, xử lý TCP/UDP. Ví dụ AWS Network Load Balancer (NLB), Azure Load Balancer, GCP passthrough/proxy Network LB.
- Layer 7 (application) LB — route theo HTTP host/path, terminate TLS, hỗ trợ host/path routing, sticky session, WebSocket. Ví dụ AWS Application Load Balancer (ALB), Azure Application Gateway, GCP HTTP(S) Load Balancer.
- Regional vs global — một regional LB phục vụ một region; một global LB (GCP Global HTTP(S) LB, AWS Global Accelerator, Azure Front Door) dùng anycast để đưa người dùng tới region khỏe mạnh gần nhất.
CDN và anycast
Một CDN (Content Delivery Network) cache nội dung ở các edge PoP gần người dùng, giảm latency và tải cho origin, và hấp thụ DDoS. Ví dụ: Amazon CloudFront, Azure CDN / Front Door, Google Cloud CDN, và Cloudflare.
Anycast là kỹ thuật routing đứng sau global LB, CDN, và public DNS: cùng một IP address được quảng bá từ nhiều vị trí, và BGP tự nhiên route mỗi người dùng tới PoP gần nhất về mặt topology. Điều này cho latency thấp và khả năng chống DDoS vốn có (tấn công bị trải ra nhiều PoP).
Cloudflare và public resolver
Cloudflare là một global edge network (một reverse proxy đặt trước origin của bạn) gom nhiều chức năng ở trên vào một nền tảng:
- Authoritative + managed DNS với propagation rất nhanh.
- CDN caching và WAF / DDoS protection ở edge, trên một anycast network.
- Zero Trust / Access, Tunnel (cloudflared) để expose app private mà không cần mở cổng inbound.
- Edge compute (Workers) gần người dùng.
Cloudflare cũng chạy public DNS resolver 1.1.1.1 nổi tiếng (và 1.0.0.1), một recursive resolver chú trọng quyền riêng tư — tương đương Google Public DNS 8.8.8.8 / 8.8.4.4. Đây là các recursive resolver ai cũng có thể trỏ thiết bị của mình tới; chúng không giống với các authoritative hosted zone bạn tự chạy cho domain của mình.
Bảng so sánh thuật ngữ giữa các provider
Khái niệm giống nhau giữa các cloud; chỉ khác tên gọi.
| Khái niệm | AWS | Azure | GCP |
|---|---|---|---|
| Virtual network | VPC | Virtual Network (VNet) | VPC (global) |
| Subnet | Subnet (theo AZ) | Subnet (regional) | Subnet (regional) |
| Truy cập internet | Internet Gateway | (outbound mặc định / NAT GW) | (default internet gateway) |
| Outbound NAT | NAT Gateway | NAT Gateway | Cloud NAT |
| Firewall stateful | Security Group | Network Security Group (NSG) | VPC firewall rules |
| ACL subnet stateless | Network ACL | NSG (dùng như subnet ACL) | (Hierarchical firewall policies) |
| Private VPC-to-VPC | VPC Peering | VNet Peering | VPC Network Peering |
| Cloud router / hub | Transit Gateway | Virtual WAN / Hub | Network Connectivity Center |
| VPN site-to-site | VPN Gateway (VGW) | VPN Gateway | Cloud VPN |
| Đường riêng dedicated | Direct Connect | ExpressRoute | Cloud Interconnect |
| Private service access | PrivateLink / VPC Endpoint | Private Endpoint / Private Link | Private Service Connect |
| L4 load balancer | Network Load Balancer (NLB) | Load Balancer | Network Load Balancer |
| L7 load balancer | Application Load Balancer (ALB) | Application Gateway | HTTP(S) Load Balancer |
| Global L7 / edge | Global Accelerator / CloudFront | Front Door | Global HTTP(S) LB / Cloud CDN |
| Managed DNS | Route 53 | Azure DNS | Cloud DNS |
| CDN | CloudFront | Azure CDN / Front Door | Cloud CDN |
| WAF | AWS WAF | Azure WAF | Cloud Armor |
Best Practices
- Quy hoạch CIDR trước khi xây. Chọn dải RFC 1918 không overlap, chừa chỗ để lớn, và không đụng với on-prem hay các peer tương lai. VPC
/16với subnet/24theo từng tier từng AZ là một mặc định an toàn. - Mặc định dùng private subnet. Đặt app server và database trong private subnet; chỉ expose load balancer và (nếu cần) bastion trong public subnet. Ra internet outbound qua NAT gateway, và tới cloud service qua PrivateLink/VPC endpoint.
- Security group least-privilege. Deny mặc định, chỉ mở đúng cổng cần, và tham chiếu security group khác thay vì dải IP khi có thể. Dùng NACL như lớp chặn thô ở mức subnet, không phải control chính.
- Thiết kế cho nhiều AZ. Trải subnet và target của load balancer qua ít nhất hai AZ. Nhớ rằng một subnet nằm trong một AZ (AWS) — bạn cần một subnet mỗi AZ mỗi tier.
- Ưu tiên hub khi mở rộng. Hai hoặc ba VPC có thể peer trực tiếp; vượt quá thế, dùng transit gateway / hub-and-spoke để tránh mesh peering non-transitive.
- Mã hóa và dual-home link hybrid. Dùng Direct Connect / ExpressRoute / Interconnect cho khối lượng và độ ổn định, kèm một site-to-site VPN làm backup mã hóa, và chạy BGP để failover động.
- Để ý chi phí egress. Data transfer outbound và cross-AZ/cross-region đều bị tính tiền. Dùng VPC endpoint để giữ traffic service khỏi đường NAT/internet, cache bằng CDN, và giữ các thành phần “chatty” trong cùng một AZ.
- Đẩy bảo mật ra edge. Terminate TLS, chạy WAF, và bật DDoS protection ở lớp CDN/global-LB (CloudFront/Cloudflare/Front Door) đặt trước origin của bạn.
- Dùng private DNS zone cho service discovery nội bộ thay vì hard-code IP, và bật DNS resolution/forwarding giữa cloud và on-prem.
- Mọi thứ dưới dạng code. Quản lý VPC, subnet, route, và firewall rule bằng Terraform/CloudFormation/Bicep để network được version, review, và tái tạo được.
- Bật flow log và monitoring. Bật VPC Flow Logs (hay tương đương) để có khả năng quan sát traffic, troubleshoot, và điều tra bảo mật.
Về chiều sâu theo từng provider, xem ../../cloud/README.md, ../../cloud/aws/README.md, và ../../cloud/gcp/README.md.
Tài liệu tham khảo
- AWS — Amazon VPC User Guide
- AWS — Building a Scalable and Secure Multi-VPC Network Infrastructure
- Microsoft Azure — Virtual Network documentation
- Google Cloud — VPC network overview
- Google Cloud — Cloud Load Balancing overview
- Cloudflare — What is a CDN?
- Cloudflare — What is Anycast DNS?
- Cloudflare — 1.1.1.1 public DNS resolver
Part of the Network Engineer Roadmap knowledge base.
Overview
Cloud networking is the practice of designing, building, and operating networks inside a public cloud provider (AWS, Azure, GCP) or across the edge of a provider like Cloudflare. The physical layer — cables, switches, routers, optics, data-center fabric — still exists, but you never touch it. Instead you describe the network you want through an API or Infrastructure-as-Code, and the provider’s software-defined networking (SDN) control plane programs the underlying hardware to match your intent.
For a network engineer coming from the on-prem world, the good news is that the fundamentals do not change: it is still IP addressing (./05-ip-addressing-and-subnetting.md), CIDR, subnets, routing tables (./07-routing.md), NAT, firewalls/ACLs (./11-network-security.md), DNS, VPN/tunnels (./12-vpn-and-tunneling.md), and load balancing. What changes is the abstraction and the operating model: you configure with declarative resources instead of CLI on a physical box, you pay per-use, and responsibility for security and availability is shared between you and the provider.
This note covers:
- How cloud networking differs from on-prem — software-defined, API-driven, elastic, pay-per-use, and the shared responsibility model.
- Virtual networks — VPC/VNet, public vs private subnets, CIDR planning, route tables, internet gateway, NAT gateway, and egress control.
- Connectivity between and into clouds — VPC peering, transit gateway / hub-and-spoke, VPN gateway, dedicated interconnect (Direct Connect / ExpressRoute / Cloud Interconnect), and PrivateLink / private endpoints.
- Cloud security controls — stateful security groups vs stateless network ACLs, cloud firewalls, and WAF.
- Cloud routing & DNS — route propagation, Route 53 / Cloud DNS / Azure DNS, and private hosted zones.
- Load balancing & CDN — L4/L7 cloud load balancers, global vs regional, CDN and anycast.
- Cloudflare — as an edge, security, and DNS provider, plus public resolvers like
1.1.1.1. - A provider terminology comparison (AWS vs Azure vs GCP).
Deeper, provider-specific notes live under ../../cloud/README.md — see ../../cloud/aws/README.md and ../../cloud/gcp/README.md.
Fundamentals
How cloud networking differs from on-prem
| Dimension | On-premises | Cloud |
|---|---|---|
| Provisioning | Rack hardware, cable, configure CLI per device | Declarative API / IaC (Terraform, CloudFormation) |
| Time to deploy | Days to weeks | Seconds to minutes |
| Scaling | Buy capacity ahead of demand | Elastic; scale up/out on demand |
| Cost model | CapEx up front | OpEx, pay-per-use (per hour, per GB egress) |
| Control plane | You own switches/routers | Provider’s SDN; you own intent, not hardware |
| Data plane | Your physical fabric | Provider’s overlay on shared hardware |
| Failure domain | Your building/room | Regions and Availability Zones (AZs) |
| Responsibility | You own everything | Shared responsibility model |
The defining idea is software-defined networking. Your VPC, subnets, and route tables are not physical devices — they are entries in the provider’s distributed control plane that gets pushed to virtualized hosts. This is why a route table change or a new firewall rule takes effect in seconds and why there is no “spanning tree”, no cabling mistakes, and no per-switch config drift in the traditional sense.
The shared responsibility model
Security and availability are split:
- The provider is responsible for the cloud — the physical network, hypervisor, the SDN backbone, DDoS protection at the infrastructure layer, and physical/regional redundancy.
- You are responsible for what is in the cloud — your VPC design, subnet placement, route tables, security groups/NACLs, encryption in transit, key management, IAM for network resources, and how you expose services to the internet.
A misconfigured security group or an over-permissive route is your fault, not the provider’s. This is the number-one source of cloud breaches. See ./11-network-security.md for the security fundamentals that still apply.
Regions, Availability Zones, and edge
- Region — a geographic area (e.g.,
us-east-1,europe-west1). Each region is isolated for fault tolerance and data residency. - Availability Zone (AZ) — one or more discrete data centers within a region, with independent power/cooling/networking. Spreading subnets across AZs is how you build highly available architectures.
- Edge / Point of Presence (PoP) — smaller locations worldwide used by CDNs, DNS, and global load balancers to terminate connections close to users.
A VPC is regional (it spans all AZs in a region), while a subnet is tied to a single AZ in AWS (in Azure and GCP the subnet is regional). This has a direct impact on how you lay out CIDR ranges for high availability.
Key Concepts
Virtual networks: VPC / VNet
A VPC (Virtual Private Cloud, AWS/GCP) or VNet (Virtual Network, Azure) is your private, logically isolated slice of the provider’s network. You define its overall address space as one or more CIDR blocks (e.g., 10.0.0.0/16), and everything else lives inside it.
Key properties:
- Uses RFC 1918 private ranges (
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16). Pick ranges that will not overlap with your on-prem network or other VPCs you may peer with later — overlapping CIDRs cannot be peered. - A VPC is isolated by default; nothing routes in or out until you explicitly add gateways and routes.
- You can attach multiple CIDR blocks to grow a VPC that ran out of space.
Subnets: public vs private
A subnet is a slice of the VPC CIDR, and it is where your resources (VMs, containers, load balancers, databases) actually get IP addresses.
- Public subnet — its route table has a default route (
0.0.0.0/0) pointing to an internet gateway (IGW). Resources here can have public IPs and be reachable from the internet. - Private subnet — no direct route to the IGW. Resources have only private IPs and reach the internet (for updates, API calls) via a NAT gateway, or not at all.
The public/private distinction is purely a routing decision — a subnet is “public” because its route table sends 0.0.0.0/0 to an IGW, nothing more. Best practice is to keep application servers and databases in private subnets and only expose load balancers / bastion hosts in public subnets.
VPC 10.0.0.0/16
├── Public subnet 10.0.0.0/24 (AZ-a) -> route 0.0.0.0/0 to IGW [ALB, NAT GW]
├── Public subnet 10.0.1.0/24 (AZ-b) -> route 0.0.0.0/0 to IGW
├── Private subnet 10.0.10.0/24 (AZ-a) -> route 0.0.0.0/0 to NAT GW [app servers]
├── Private subnet 10.0.11.0/24 (AZ-b) -> route 0.0.0.0/0 to NAT GW
├── Data subnet 10.0.20.0/24 (AZ-a) -> no 0.0.0.0/0 route [databases]
└── Data subnet 10.0.21.0/24 (AZ-b) -> no 0.0.0.0/0 route
CIDR planning
CIDR planning in the cloud follows the same subnetting math as on-prem (./05-ip-addressing-and-subnetting.md), with a few cloud-specific rules:
- Leave room to grow. A common pattern is a
/16VPC carved into/24subnets (256 subnets, 251 usable hosts each after provider reservations). - Providers reserve addresses in every subnet. AWS reserves the first 4 and the last 1 address of each subnet (network, VPC router, DNS, future use, broadcast). So a
/24gives 251 usable, not 254. - Never overlap CIDRs across VPCs you intend to peer, or with your on-prem ranges.
- Reserve separate tiers per AZ (public/private/data × 2-3 AZs) so you can build multi-AZ high availability.
Route tables, internet gateway, NAT gateway, egress
- Route table — a set of routes attached to one or more subnets. Each route maps a destination CIDR to a target (IGW, NAT GW, peering connection, transit gateway, VPN gateway, VPC endpoint). The most specific (longest-prefix) match wins, exactly like traditional routing (./07-routing.md).
- Internet gateway (IGW) — a horizontally-scaled, highly available component that lets a VPC send/receive traffic to the internet. It also performs 1:1 NAT for instances that have a public IP.
- NAT gateway — a managed source NAT (PAT) device placed in a public subnet. Private-subnet instances route
0.0.0.0/0to it so they can make outbound connections (patch, pull images, call APIs) while remaining unreachable from the internet. It is one-way: no unsolicited inbound. - Egress cost & control — outbound data transfer (egress) to the internet is billed per GB, and cross-AZ / cross-region traffic often costs money too. NAT gateways charge per hour and per GB processed. This makes egress a design and cost concern: use VPC endpoints to keep traffic off the NAT/internet path, and be deliberate about cross-AZ chatter. An egress-only internet gateway is the IPv6 equivalent of a NAT gateway (outbound-only).
Cloud connectivity options
Connecting VPCs to each other, to on-prem, and to services is one of the richest areas of cloud networking.
VPC peering
A 1:1 private connection between two VPCs. Traffic uses private IPs and never touches the internet. Peering is:
- Non-transitive — if A peers B and B peers C, A cannot reach C through B. This is the key limitation that pushes larger designs toward a hub.
- Blocked when CIDRs overlap.
- Simple and cheap for a handful of VPCs, but the mesh explodes (N×(N-1)/2 links) as you add more.
Transit gateway / hub-and-spoke
A transit gateway (AWS Transit Gateway, Azure Virtual WAN / VNet peering with a hub, GCP Network Connectivity Center) is a cloud router that connects many VPCs, VPNs, and Direct Connect/Interconnect links in a hub-and-spoke topology. It is transitive, so every attached VPC can reach every other one through the hub, replacing an unmanageable full mesh of peerings. You control reachability with route tables on the transit gateway and can segment environments (prod/dev) into separate route domains.
VPN gateway
A site-to-site IPsec VPN over the public internet between your on-prem network (or another cloud) and a VPN gateway in the VPC. Encrypted, quick to set up, and cheap — but throughput and latency depend on the internet. Often deployed as a backup to a dedicated link, and with BGP for dynamic route exchange. See ./12-vpn-and-tunneling.md for IPsec/tunneling fundamentals.
Dedicated interconnect (private circuit)
A private, dedicated physical connection from your data center to the provider, bypassing the public internet for consistent bandwidth, lower latency, and lower egress cost at scale:
- AWS Direct Connect
- Azure ExpressRoute
- GCP Cloud Interconnect (Dedicated or Partner)
These are the enterprise choice for predictable, high-volume hybrid connectivity. They typically run BGP and are paired with a VPN for encryption/redundancy.
PrivateLink / private endpoints
PrivateLink (AWS), Private Endpoint / Private Link (Azure), and Private Service Connect (GCP) let you consume a service (a managed service like S3/DynamoDB, or a SaaS/third-party service) over a private IP inside your VPC, so traffic never leaves the provider backbone or traverses the internet. This is the modern way to reach cloud services privately without opening egress or using public endpoints, and it also lets a SaaS vendor expose their app privately to customers.
| Connectivity option | Use it for | Transitive? | Over internet? |
|---|---|---|---|
| VPC peering | A few VPCs, direct private links | No | No |
| Transit gateway | Many VPCs / hybrid at scale | Yes | No |
| VPN gateway | Hybrid over internet, backup link | Via BGP/TGW | Yes (encrypted) |
| Direct Connect / ExpressRoute / Interconnect | High-volume, low-latency hybrid | Via TGW | No (private circuit) |
| PrivateLink / private endpoint | Private access to a specific service | N/A | No |
Cloud security controls
Cloud firewalling happens at two main layers; both build on the ACL/firewall concepts in ./11-network-security.md.
Security groups (stateful) vs network ACLs (stateless)
| Security group | Network ACL | |
|---|---|---|
| Attaches to | The instance/ENI (resource level) | The subnet |
| State | Stateful — return traffic auto-allowed | Stateless — must allow return traffic explicitly |
| Rules | Allow only | Allow and deny |
| Evaluation | All rules evaluated; if any allows, permit | Rules processed in numbered order, first match wins |
| Default | Deny all inbound, allow all outbound | Default NACL allows all; custom NACL denies all |
| Typical role | Primary control (per-tier: web/app/db) | Coarse subnet-level guardrail, explicit denies |
Rule of thumb: do most of your work with security groups (stateful, easy, per-resource). Use NACLs as a broad subnet backstop or to block specific bad actors. A powerful pattern is to reference another security group as the source (e.g., “allow the app-tier SG to reach the db-tier SG on 5432”) instead of hard-coding IPs.
Azure’s equivalent is the Network Security Group (NSG) (stateful, applies to subnet or NIC); GCP uses VPC firewall rules (stateful, applied by target tags/service accounts at the network level).
Cloud firewalls and WAF
- Managed network firewalls — AWS Network Firewall, Azure Firewall, GCP Cloud Firewall / firewall policies — provide centralized, stateful, L3–L7 inspection, often at the hub, with features like domain filtering and IDS/IPS.
- Web Application Firewall (WAF) — AWS WAF, Azure WAF, Google Cloud Armor, Cloudflare WAF — inspects HTTP(S) at L7 to block SQLi, XSS, bad bots, and enforce rate limits. Deployed in front of load balancers / CDNs. DDoS protection (AWS Shield, Azure DDoS Protection, Cloud Armor, Cloudflare) usually pairs with the WAF/edge.
Cloud routing and DNS
Route propagation
Routes in a route table are either static (you add them) or propagated (learned dynamically). A VPN gateway or transit gateway using BGP can propagate on-prem routes into the VPC route table automatically, so you do not maintain static entries by hand. Longest-prefix match still governs which route is chosen (./07-routing.md).
Cloud DNS
Each provider runs a managed, highly available DNS service:
- AWS Route 53, Azure DNS, Google Cloud DNS.
- Public hosted zones serve your domain to the internet (authoritative DNS), with health checks and routing policies (latency, geolocation, weighted, failover).
- Private hosted zones resolve names only inside your VPC(s) — e.g.,
db.internal.example.com→ a private IP — so internal services find each other without exposing records publicly. - Providers also give each VPC a built-in resolver (e.g., AWS at the
.2address of the VPC CIDR, the “Amazon-provided DNS”) that resolves both public names and private zones, and can forward to on-prem DNS.
Load balancing and CDN
Cloud load balancers
Cloud load balancers are managed, elastic, and highly available across AZs:
- Layer 4 (network) LB — routes by IP/port, very high throughput, preserves source IP, handles TCP/UDP. E.g., AWS Network Load Balancer (NLB), Azure Load Balancer, GCP passthrough/proxy Network LB.
- Layer 7 (application) LB — routes by HTTP host/path, terminates TLS, supports host/path routing, sticky sessions, WebSockets. E.g., AWS Application Load Balancer (ALB), Azure Application Gateway, GCP HTTP(S) Load Balancer.
- Regional vs global — a regional LB serves one region; a global LB (GCP Global HTTP(S) LB, AWS Global Accelerator, Azure Front Door) uses anycast to send users to the nearest healthy region.
CDN and anycast
A CDN (Content Delivery Network) caches content at edge PoPs close to users, cutting latency and origin load, and absorbing DDoS. Examples: Amazon CloudFront, Azure CDN / Front Door, Google Cloud CDN, and Cloudflare.
Anycast is the routing technique behind global LBs, CDNs, and public DNS: the same IP address is advertised from many locations, and BGP naturally routes each user to the topologically nearest PoP. This gives low latency and inherent DDoS resilience (attacks are spread across many PoPs).
Cloudflare and public resolvers
Cloudflare is a global edge network (a reverse proxy in front of your origin) that combines several of the above functions in one platform:
- Authoritative + managed DNS with very fast propagation.
- CDN caching and WAF / DDoS protection at the edge, on an anycast network.
- Zero Trust / Access, Tunnels (cloudflared) to expose private apps without opening inbound ports.
- Edge compute (Workers) close to users.
Cloudflare also runs the well-known public DNS resolver 1.1.1.1 (and 1.0.0.1), a privacy-focused recursive resolver — comparable to Google Public DNS 8.8.8.8 / 8.8.4.4. These are recursive resolvers anyone can point their devices at; they are not the same as the authoritative hosted zones you run for your own domains.
Provider terminology comparison
The concepts are the same across clouds; only the names differ.
| Concept | AWS | Azure | GCP |
|---|---|---|---|
| Virtual network | VPC | Virtual Network (VNet) | VPC (global) |
| Subnet | Subnet (per-AZ) | Subnet (regional) | Subnet (regional) |
| Internet access | Internet Gateway | (default outbound / NAT GW) | (default internet gateway) |
| Outbound NAT | NAT Gateway | NAT Gateway | Cloud NAT |
| Stateful firewall | Security Group | Network Security Group (NSG) | VPC firewall rules |
| Stateless subnet ACL | Network ACL | NSG (as subnet ACL) | (Hierarchical firewall policies) |
| Private VPC-to-VPC | VPC Peering | VNet Peering | VPC Network Peering |
| Cloud router / hub | Transit Gateway | Virtual WAN / Hub | Network Connectivity Center |
| Site-to-site VPN | VPN Gateway (VGW) | VPN Gateway | Cloud VPN |
| Dedicated circuit | Direct Connect | ExpressRoute | Cloud Interconnect |
| Private service access | PrivateLink / VPC Endpoint | Private Endpoint / Private Link | Private Service Connect |
| L4 load balancer | Network Load Balancer (NLB) | Load Balancer | Network Load Balancer |
| L7 load balancer | Application Load Balancer (ALB) | Application Gateway | HTTP(S) Load Balancer |
| Global L7 / edge | Global Accelerator / CloudFront | Front Door | Global HTTP(S) LB / Cloud CDN |
| Managed DNS | Route 53 | Azure DNS | Cloud DNS |
| CDN | CloudFront | Azure CDN / Front Door | Cloud CDN |
| WAF | AWS WAF | Azure WAF | Cloud Armor |
Best Practices
- Plan CIDR before you build. Choose non-overlapping RFC 1918 ranges that leave room to grow and that will not clash with on-prem or future peers. A
/16VPC with/24subnets per tier per AZ is a safe default. - Default to private subnets. Put app servers and databases in private subnets; expose only load balancers and (if needed) bastions in public subnets. Reach the internet outbound via NAT gateway, and reach cloud services via PrivateLink/VPC endpoints.
- Least-privilege security groups. Deny by default, open only the exact ports needed, and reference other security groups instead of IP ranges where possible. Use NACLs as a coarse subnet backstop, not your primary control.
- Design for multiple AZs. Spread subnets and load-balancer targets across at least two AZs. Remember a subnet lives in one AZ (AWS) — you need one subnet per AZ per tier.
- Prefer a hub for scale. Two or three VPCs can peer directly; beyond that, use a transit gateway / hub-and-spoke to avoid a non-transitive peering mesh.
- Encrypt and dual-home hybrid links. Use Direct Connect / ExpressRoute / Interconnect for volume and predictability, with a site-to-site VPN as an encrypted backup, and run BGP for dynamic failover.
- Mind egress cost. Outbound and cross-AZ/cross-region data transfer is billed. Use VPC endpoints to keep service traffic off the NAT/internet path, cache with a CDN, and keep chatty components in the same AZ.
- Push security to the edge. Terminate TLS, run a WAF, and enable DDoS protection at the CDN/global-LB layer (CloudFront/Cloudflare/Front Door) in front of your origin.
- Use private DNS zones for internal service discovery instead of hard-coded IPs, and enable DNS resolution/forwarding between cloud and on-prem.
- Everything as code. Manage VPCs, subnets, routes, and firewall rules with Terraform/CloudFormation/Bicep so the network is versioned, reviewable, and reproducible.
- Enable flow logs and monitoring. Turn on VPC Flow Logs (or the equivalent) for traffic visibility, troubleshooting, and security forensics.
For provider-specific depth, see ../../cloud/README.md, ../../cloud/aws/README.md, and ../../cloud/gcp/README.md.
References
- AWS — Amazon VPC User Guide
- AWS — Building a Scalable and Secure Multi-VPC Network Infrastructure
- Microsoft Azure — Virtual Network documentation
- Google Cloud — VPC network overview
- Google Cloud — Cloud Load Balancing overview
- Cloudflare — What is a CDN?
- Cloudflare — What is Anycast DNS?
- Cloudflare — 1.1.1.1 public DNS resolver