01
Your own network in the cloud: virtual networks and IP address ranges
A cloud data center runs servers for a huge number of customers side by side. Still, your servers should only talk to each other and stay separated from everyone else's. So the cloud gives each customer a logically isolated network, called a virtual network. The physical cables and switches are shared, but the addresses, routes and rules belong to you alone.
The first thing you decide when you create a virtual network is the range of IP addresses it will use (its address range). You usually pick it from the private address ranges, which are reserved so they're never used on the public internet. Any company or household can reuse these private addresses, which is exactly why they can't go straight out to the internet on their own (chapter 3 shows how they get out).
| Private range (RFC 1918) | Number of addresses | Common use |
|---|---|---|
| 10.0.0.0/8 | About 16.77 million | Cloud virtual networks, large corporate networks |
| 172.16.0.0/12 | About 1.05 million | Corporate networks, default container networks |
| 192.168.0.0/16 | 65,536 | Home routers, small offices |
CIDR: reading the number after the slash
An IPv4 address is 32 bits long. 10.0.0.0/16 means "the first 16 bits (10.0) are fixed, and this network gets to use the remaining 16 bits." That gives you 2^16 = 65,536 addresses. The bigger the number after the /, the more bits are fixed and the smaller the range. This notation is called CIDR, and the range it describes is a CIDR block. Try changing the subnet size in the scene below.
- Subnet size
- /24 · 256 addresses
- How many fit
- 256
- Usable by servers
- 252 (4 reserved)
Split the 10.0.0.0/16 range (the land) into equal subnets (the plots) · lime plot = first subnet
A Google Cloud VPC network has no IP range of its own — each subnet gets its own range. Think of the scene as a plan that hands out 10.0.0.0/16 to the subnets. /24 means the first 24 bits are the network and the other 8 bits are for addresses. One subnet holds 2^8 = 256 addresses. Each subnet reserves 4, so 252 addresses are left for servers. Each time the number after the / goes up by 1, the plots get half as big and there are twice as many.
| Prefix | Number of addresses | How many fit in a /16 |
|---|---|---|
| /16 | 65,536 | 1 |
| /20 | 4,096 | 16 |
| /24 | 256 | 256 |
| /28 | 16 | 4,096 |
You then split the virtual network's range into subnets. A subnet is a zone where you group servers that play the same role — say, a web tier that faces the internet and a database tier you keep hidden. Each subnet can get its own routes (chapter 2) and firewall rules (chapter 4).
You can't use every address in a subnet
In every subnet, the cloud reserves a few addresses for itself: the first address (the network address), the gateway that leads out of the subnet, DNS and so on. How many it reserves depends on the cloud provider. So even a /24 subnet gives you a little less than 256 addresses for your servers.
Go big from the start, and don't overlap
Address ranges are hard to change once they're created. Plan for more servers and services down the road, pick a generous range, and make sure it doesn't overlap with your corporate network or your other virtual networks. Here's the part that trips people up: if your office network uses 192.168.0.0/16 and your cloud network uses the same range, then when you try to connect them later, nothing can tell which side's 192.168.1.10 you mean — so the connection simply won't work (chapter 7).
If a question says… → pick this
- “How many /24 subnets fit in a 10.0.0.0/16 network”256
- “Usable addresses for servers in a /28 subnet”16 minus that provider's reserved addresses
- “You plan to connect to the corporate network later”Design a range that doesn't overlap with it
- “Address ranges not used on the internet”Private ranges (10/8, 172.16/12, 192.168/16)
- “You want different access rules for each subnet”Split subnets by role (tier)
You've split your range into subnets. But when a server in a subnet sends a packet, how does that packet know where to go?
02
Subnets and routing: what makes a subnet public or private
When a server sends a packet, the route table associated with its subnet decides where it goes. A route table is a list of lines that say "packets headed for this range go out through that door." Every virtual network starts with a default route that says "addresses inside the network are delivered inside the network," so subnets can talk to each other without any extra setup.
Destination Next hop (where to send it) 10.0.0.0/16 Inside the network (local) 172.16.0.0/12 VPN connection → corporate network 0.0.0.0/0 Internet gateway
The route table looks for the line that matches the packet's destination address and sends it to that line's next hop. Say a web server sends a packet to a database server on the same network (10.0.2.15). 10.0.2.15 is inside 10.0.0.0/16, so it matches the first line. But 0.0.0.0/0 means "every address," so it matches the last line too.
When several lines match, the most specific one wins — the one with the bigger number after the /. This is called longest prefix match. A /16 is more specific than a /0, so this packet is delivered inside the network. A website on the internet (203.0.113.10), on the other hand, doesn't match the first two lines. It only matches 0.0.0.0/0, so it goes to the internet gateway. That's why 0.0.0.0/0 is called the default route: it's where any address that matches nothing else ends up. Try changing the destination and the subnet type in the scene below.
- From
- VM with an external IP
- Destination
- Website on the internet (203.0.113.10)
- Result
- default-internet-gateway
A packet from the server picks its path at the signpost (VPC network routes (all VMs)) · lime row = winning route, blue text = matched but lost
Only 0.0.0.0/0 matches 203.0.113.10, so the packet goes out through the default-internet-gateway. On the way, the source address shows up as the public IP 198.51.100.20, not the server’s private IP 10.0.1.20 — private IPs can’t be used on the internet.
Public subnets and private subnets
A subnet with a route toward the internet (0.0.0.0/0 → internet) is called a public subnet, and one without it is a private subnet. Here's the part that trips people up: it's the route that decides, not the name you gave the subnet. And even in a public subnet, a server needs a public IP to talk to the internet directly. A server with only a private IP can't be reached from the internet, even if it sits in a public subnet.
A typical web service is laid out like this.
| Tier | Where it goes | Why |
|---|---|---|
| Load balancer | Public subnet | It has to receive requests from the internet |
| Web / app servers | Private subnet | They only receive requests through the load balancer |
| Database | Private subnet | Nothing but the app servers has any reason to reach it |
If a question says… → pick this
- “Keep a subnet's servers from being directly reachable from the internet”Private subnet (no internet route)
- “Two routes match the same destination”The more specific (longer prefix) route wins
- “Subnets in the same network talking to each other”The default local route — nothing to set up
- “Keep the database unreachable from the internet”Put it in a private subnet
- “It's a public subnet, but the server can't be reached from the internet”Check that the server has a public IP
You've hidden your database and app servers in private subnets. But they still need security updates, and they need to reach the cloud's storage service. With no internet route, how do they get out?
Advertisement
03
Getting out of a private subnet: NAT and private endpoints
NAT (network address translation) acts on behalf of your private servers. When a server sends a packet to the internet, NAT swaps the packet's source address for its own public IP and sends it out. When the reply comes back, NAT remembers who made the request and hands the reply to the right server.
- Situation
- Server → internet (getting updates)
How the app server in the private subnet talks to the outside · lime = outgoing packets, blue = returning packets
A server in a private subnet has no public IP, so it can’t reach the internet on its own. The NAT swaps the source address for its own public IP, sends the packet out, remembers who asked, and hands the reply back to that server. Cloud NAT isn’t a device inside a subnet — it’s a regional configuration built on a Cloud Router.
The key is direction. NAT only handles connections that start from the inside. A connection that starts from the outside is dropped, because NAT has no idea which server it's for. So when a question says "the servers must get updates but must not be reachable from the internet," the answer is NAT. If you do need to accept requests from the internet, you need a load balancer (chapter 5) or a public IP on the server.
You usually use NAT as a service the cloud manages for you. You can also turn a server of your own into a NAT instance, but if it goes down, the whole private subnet loses its way out — so high availability and upkeep are on you. Where a managed NAT lives (a single zone, or the whole region) depends on the provider.
Reaching cloud services without the internet: private endpoints
Managed cloud services like storage, queues and key management usually have public, internet-facing addresses. If a private server just calls them, the traffic goes out through NAT to the internet and comes back in. With a private endpoint, that trip stays inside your network. There are two kinds.
| Kind | How it works | What to know |
|---|---|---|
| Route-based | You add a "that service's range → endpoint" route to the route table | You keep using the service's public address. Few services support it, and it's often free |
| Interface-based | A private IP for that service is placed in your subnet | You call it by private IP. It also works from a corporate network connected by VPN or a dedicated connection. Billed by the hour and by data |
If a question says… → pick this
- “Private servers get patches but stay unreachable from the internet”NAT
- “Access the storage service without going over the internet”Private endpoint
- “Big transfers to the same cloud's storage make NAT costs high”Private endpoint for storage
- “Call a cloud service by private IP from the corporate network”Interface endpoint
- “Private servers must accept requests from the internet”A load balancer, not NAT
Now the packets know where to go. But just because there's a road doesn't mean you let anyone drive on it. You need a gatekeeper that decides which packets get in and which get blocked.
Pro only
That’s the free part of this guide
The other 5 chapters are open to Pro subscribers. Each one continues with 3D visuals and “if a question says…” tips, and the last chapter lets you check yourself with a short quiz.
- 04Two layers of firewalls (stateful and stateless)
- 05Load balancers and health checks
- 06DNS and the edge (CDN and WAF)
- 07Connecting networks (peering, VPN and dedicated connections)
- 08When you can't connect
PasslyExam
You have read the concept. Now test it on exam questions
PasslyExam offers original practice questions, explanations and full mock exams built around each certification’s exam guide. The explanations cover why the right option is right and why the look-alike options are wrong. Sign up to practice for free every day.
Exams that cover this concept
- AIF-C01AWS Certified AI Practitioner
- SAA-C03AWS Certified Solutions Architect - Associate
- CLF-C02AWS Certified Cloud Practitioner
- SOA-C03AWS Certified CloudOps Engineer - Associate
- SAP-C02AWS Certified Solutions Architect - Professional
- AZ-900Microsoft Azure Fundamentals
- AZ-104Microsoft Azure Administrator
- ACEGoogle Cloud Associate Cloud Engineer
- NCA-100NAVER Cloud Platform Certified Associate
- NCP-202NAVER Cloud Platform Certified Professional (Network/Media, Database/Management/Analytics)
- NCP-207NAVER Cloud Platform Certified Professional (Troubleshooting)
- NCP-200NAVER Cloud Platform Certified Professional (Overview, Compute/Storage)