Companies increasingly run their servers in a public cloud instead of their own data centre. The servers are virtual, and so is the network that connects them. The good news is that everything you have learned so far (IP addresses, subnets, gateways, NAT, firewalls) still applies. The cloud gives each piece a new name and lets you create it with a few clicks or a few lines of code.
What the cloud is
Cloud computing means renting computing resources (servers, storage, databases, networks) from a provider over the internet, on demand, and paying for what you use. The large public cloud providers include Amazon Web Services (AWS), Microsoft Azure and Google Cloud. Behind the scenes, the cloud is a set of huge data centres full of physical servers, and you rent virtual slices of them.
Infrastructure as a Service: you rent virtual machines and networks and manage everything that runs on them. This is where cloud networking matters most.
Platform as a Service: you run your code or database on a managed platform; the provider runs the servers.
Software as a Service: you simply use the application, such as web email or an online office suite.
You will meet two more terms everywhere. A region is a geographic area where a provider has data centres (for example, "Frankfurt" or "US East"). Each region is split into availability zones (AZs): separate data centres, a few kilometres apart, with their own power and cooling. Placing copies of a service in two AZs keeps it running if one site fails.
Why cloud networking exists
Thousands of customers share the same physical data centres. Each one needs its own private network that:
- is isolated: no other customer can see or reach it;
- uses its own addresses: chosen by the customer, often from the same private ranges that other customers use;
- is controlled by the customer: which servers can reach the internet, which can talk to each other and which can reach the office.
No provider could rewire physical switches for every customer, so the network is software-defined. The provider's systems wrap (encapsulate) each customer's traffic so that it stays inside that customer's virtual network. The customer configures routes and firewalls through a web console or code.
The building blocks, and what each provider calls them
| Concept | What it is | AWS | Azure | Google Cloud |
|---|---|---|---|---|
| Virtual network | Your private, isolated network | VPC | VNet | VPC network |
| Subnet | A slice of the network's address range | Subnet | Subnet | Subnet |
| Route table | Rules for where traffic goes | Route table | Route table (UDR) | Routes |
| Internet access | The door between the network and the internet | Internet gateway | Built in (system route) | Default internet gateway |
| Outbound-only internet | A shared public address for private resources | NAT gateway | NAT gateway | Cloud NAT |
| Resource firewall | Allow rules for each server | Security group | Network security group (NSG) | Firewall rules |
| Subnet firewall | Allow/deny rules at the subnet edge | Network ACL | NSG on the subnet | Firewall rules / policies |
| Hybrid VPN | Encrypted tunnel to the office | Site-to-Site VPN | VPN Gateway | Cloud VPN |
| Dedicated link | Private circuit to the cloud | Direct Connect | ExpressRoute | Cloud Interconnect |
The rest of this lesson uses the general names: VPC, internet gateway, NAT gateway, security group and network ACL.
A VPC with public and private subnets
Here is one of the most common cloud designs, used behind countless websites: a web server that people can reach, and an application server and database that they can't.
Route to the internet gateway: resources with a public IP are reachable from the internet (if security rules allow).
| Destination | Target |
|---|---|
| 10.0.0.0/16 | local |
| 0.0.0.0/0 | internet gateway |
No route from the internet. Outbound only, through the NAT gateway.
| Destination | Target |
|---|---|
| 10.0.0.0/16 | local |
| 0.0.0.0/0 | NAT gateway |
| 192.168.0.0/16 | VPN gateway |
The virtual private cloud (VPC)
A VPC (or VNet) is your own private network inside the cloud. When you create one, you give it an address range in CIDR notation, usually from the private (RFC 1918) ranges, for example, 10.0.0.0/16 (65,536 addresses). Every resource you create in the VPC gets an address from this range.
💡 Plan the range first. If the cloud network will ever connect to the office or to another VPC, its range must not overlap with theirs. If the office uses 192.168.0.0/16 and the VPC does too, routing between them breaks, because each side thinks the other's addresses are local. Changing a VPC's range later is difficult.
Subnets: public and private
You split the VPC into subnets, smaller ranges such as 10.0.1.0/24 and 10.0.2.0/24. In AWS, each subnet lives in one availability zone; in Azure and Google Cloud, a subnet covers a whole region. You put each resource in the subnet that matches how exposed it should be:
| Public subnet | Private subnet | |
|---|---|---|
Route for 0.0.0.0/0 | Internet gateway | NAT gateway (or none) |
| Reachable from the internet? | Yes, if the resource has a public IP and security rules allow it | No |
| Can reach the internet? | Yes | Outbound only, through the NAT gateway |
| Typical resources | Load balancers, web servers, NAT gateway, VPN endpoints | Application servers, databases, internal tools |
In each subnet, the cloud provides a virtual router at the first usable address (here 10.0.1.1 and 10.0.2.1). That is each VM's default gateway, handed out by the cloud's built-in DHCP service. Most clouds also reserve a few other addresses in each subnet, so a /24 gives slightly fewer than 254 usable addresses.
Route tables
A route table is a list of rules, each with a destination range and a target. Every subnet uses one route table. Like a router, the cloud chooses the most specific matching rule (the longest prefix) for each packet.
| Destination | Target | Meaning |
|---|---|---|
10.0.0.0/16 | local | Traffic within the VPC is delivered directly. Created automatically, so every subnet can reach every other subnet |
0.0.0.0/0 | internet gateway | Everything else goes to the internet (public subnet) |
0.0.0.0/0 | NAT gateway | Everything else goes out through NAT (private subnet) |
192.168.0.0/16 | VPN gateway | The office network is reached through the VPN |
⚠️ The local route means that all subnets in a VPC can reach each other by default. To stop the web subnet from talking to the database subnet, you use security groups and network ACLs, not routes.
Public and private IP addresses in the cloud
Every VM gets a private IP address from its subnet and usually keeps it for as long as the VM exists. A VM in a public subnet can also be given a public IP address. There are usually two kinds: a temporary one that may change when the VM is stopped and started, and a fixed ("static" or "elastic") one that you reserve and keep.
This surprises many beginners: the public IP address is not configured on the VM. The VM only knows its private address. The internet gateway translates between the two, one-to-one, as packets pass through. It is the same idea as static NAT.
Learn more: How NAT and PAT Work
Internet gateway and NAT gateway
- Attached to the VPC as its door to the internet.
- Traffic can go both ways: in and out.
- Translates each public IP to its VM's private IP (1:1).
- Used by the public subnet's route table.
- Sits in a public subnet, with its own public IP.
- Lets private resources start connections out (for software updates and APIs).
- Blocks new connections in: it has no mapping to translate them to.
- Many VMs share one public IP, like PAT on a home router.
How traffic flows, step by step
- 1. 1. Inbound web request: to 203.0.113.25. The internet gateway translates the destination to 10.0.1.10, and the web server's security group allows TCP 443.
- 2. 2. Inside the VPC: web → app on TCP 8080, app → database on TCP 5432. The 'local' route delivers the traffic, and security groups allow only these ports.
- 3. 3. Private server goes out: the app server downloads updates. Its subnet's 0.0.0.0/0 route points to the NAT gateway, and the traffic leaves from the public address 203.0.113.40.
- 4. 4. Blocked: nobody on the internet can reach the app server: it has no public IP address, so the internet gateway has nothing to translate to it.
- 5. 5. Hybrid: an administrator in the office reaches 10.0.2.20 privately through the VPN. The private subnet's route table has 192.168.0.0/16 → VPN gateway.
Packet behaviour: what changes on the way
Flow 1, the customer's request and the reply:
| Where | Source IP:port | Destination IP:port |
|---|---|---|
| On the internet | 198.51.100.77:52010 | 203.0.113.25:443 |
| After the internet gateway (inside the VPC) | 198.51.100.77:52010 | 10.0.1.10:443 |
| Reply leaving the VM | 10.0.1.10:443 | 198.51.100.77:52010 |
| Reply after the internet gateway | 203.0.113.25:443 | 198.51.100.77:52010 |
Flow 3, the private app server going out through the NAT gateway:
| Where | Source IP:port | Destination IP:port |
|---|---|---|
| Leaving the app server | 10.0.2.20:41822 | 192.0.2.80:443 |
| After the NAT gateway | 10.0.1.5:1031 | 192.0.2.80:443 |
| On the internet (after the internet gateway) | 203.0.113.40:1031 | 192.0.2.80:443 |
The update server (192.0.2.80) only ever sees 203.0.113.40. The NAT gateway remembers the mapping, so the reply finds its way back to 10.0.2.20.
Security groups and network ACLs
The cloud gives you two built-in firewalls, at two different places:
| Security group | Network ACL | |
|---|---|---|
| Applies to | Each resource (its network interface) | A whole subnet, at its edge |
| Rule types | Allow rules only; everything else is denied | Allow and deny rules, checked in number order |
| Stateful? | Stateful: replies to allowed traffic are allowed back automatically | Stateless: you must allow the reply direction too (including high "ephemeral" ports) |
| Can refer to | IP ranges, or other security groups ("allow from SG web") | IP ranges only |
| Typical use | The main control: open exactly the ports each server needs | A coarse extra layer, for example to block a known bad range for a whole subnet |
💡 Least privilege: the web server's security group allows TCP 443 from anywhere. The app server's group allows TCP 8080 only from the web server's security group. The database's group allows TCP 5432 only from the app server's group. Even if an attacker takes over the web server, they can't reach the database directly. This is network segmentation in the cloud.
Hybrid connectivity: linking the cloud to the office
Most companies don't move everything at once. A hybrid network joins the on-premises network (the office or company data centre) with the cloud so that they work as one network.
| Site-to-site VPN | Dedicated link | |
|---|---|---|
| How it works | An encrypted VPN tunnel over the internet between the office firewall or router and the cloud's VPN gateway | A private circuit from your site (or a partner's building) straight into the provider's network |
| Set-up time | Minutes to hours | Weeks (a physical circuit must be ordered) |
| Performance | Varies with internet conditions | Consistent speed and delay; higher bandwidth |
| Cost | Low | Higher |
| Common use | Small sites, backup for a dedicated link | Large, steady or sensitive traffic |
Either way, the cloud's route table needs a route to the office range (192.168.0.0/16 → VPN gateway), and the office router needs a route back to 10.0.0.0/16. If you forget one direction, traffic goes out but the replies never return.
A real-world example
A small accounting firm moves its client portal to the cloud. The firm:
- Creates a VPC,
10.0.0.0/16, which doesn't overlap the office's192.168.0.0/16. - Creates public subnets in two availability zones for a load balancer and NAT gateways, and private subnets in both zones for the portal servers and the database.
- Gives the load balancer the only public address that customers use; the portal servers have private IP addresses only.
- Sets security groups: the load balancer allows TCP 443 from anywhere, the portal servers allow TCP 443 only from the load balancer, and the database allows TCP 5432 only from the portal servers.
- Builds a site-to-site VPN so that staff can reach the admin pages, which are never exposed to the internet.
If one availability zone has a power failure, the load balancer sends all traffic to the servers in the other zone. This is the same redundancy idea as in a physical data centre, done in software.
What happens when it fails
| Mistake or failure | Symptom |
|---|---|
Public subnet has no 0.0.0.0/0 → internet gateway route | A VM with a public IP address is unreachable from the internet and can't connect out |
| A VM in a public subnet has no public IP address | It can't be reached from the internet or reach it (unless its traffic goes through a NAT gateway) |
| The private subnet's default route points to nothing, or the NAT gateway was deleted | Software updates and outbound API calls time out |
| A security group is missing an allow rule | Connections time out (packets silently dropped) |
| A network ACL allows inbound traffic but not the outbound reply ports | Connection attempts time out even though the security group looks right |
| The VPC and office ranges overlap | The VPN is up, but some or all hosts can't be reached |
| A whole availability zone fails | Services that run in only that zone go down; services spread over two zones keep running |
Troubleshooting and useful commands
Cloud troubleshooting follows the same method, but the "cables and switches" are now configuration settings. Check these, in order:
- The VM: Is it running? Does it have the correct private IP address? Is the service listening (
ss -tulpn)? Is the OS firewall blocking it? - Security group: Is the port allowed from the right source?
- Network ACL: Are both directions allowed, including the reply ports?
- Route table: Does the subnet's route table have the route you expect (internet gateway, NAT gateway or VPN)?
- Public IP and gateways: Does the resource have a public IP address? Is the internet gateway attached, and is the NAT gateway healthy?
Cloud providers also offer flow logs (a record of accepted and rejected connections) and reachability analysers, which trace a path through your configuration and tell you which rule blocks it.
$ ip -br addr; ip route lo UNKNOWN 127.0.0.1/8 ::1/128 ens5 UP 10.0.1.10/24 fe80::ff:fe00:110/64 default via 10.0.1.1 dev ens5 proto dhcp src 10.0.1.10 metric 100 10.0.1.0/24 dev ens5 proto kernel scope link src 10.0.1.10 metric 100
ens5, only the private address 10.0.1.10/24 appears, even though this web server is reached on 203.0.113.25. That is normal: the internet gateway handles the public address. The default via 10.0.1.1 line shows the default gateway, which is the cloud's virtual router, learned from DHCP (proto dhcp).$ nc -vz -w 5 10.0.2.20 8080 nc: connect to 10.0.2.20 port 8080 (tcp) timed out: Operation now in progress
$ nc -vz -w 5 10.0.2.20 8080 nc: connect to 10.0.2.20 port 8080 (tcp) failed: Connection refused
From outside, the Port Checker tests whether a public port is open, and What Is My IP shows the public address your traffic comes from, such as the NAT gateway's address.
Common mistakes
Allowing SSH (TCP 22) or RDP (TCP 3389) from the whole internet invites constant attacks. Allow only your office range, or use the VPN.
A database rarely needs to be reached from the internet. Keep it in a private subnet with no public IP address.
Overlapping ranges break routing over VPNs and peering. Before you build, pick VPC ranges that don't clash with the office or other VPCs.
Network ACLs don't track connections, so they need rules for the reply traffic too.
An availability zone can fail as a whole. Spread important services over two or more zones.
The VM only has its private address, so software configured to listen on the public IP fails to start. Bind to the private IP or 0.0.0.0.
- A VPC (VNet in Azure) is your isolated private network in the cloud, with a range like
10.0.0.0/16. - A subnet's route table makes it public or private:
0.0.0.0/0to an internet gateway (public) or to a NAT gateway (private). - VMs only see their private IP address; the internet gateway maps public addresses to them one-to-one.
- A NAT gateway lets private resources connect out while blocking new connections in.
- Security groups (per resource, stateful, allow-only) and network ACLs (per subnet, stateless, allow and deny) are the cloud's firewalls.
- Site-to-site VPNs and dedicated links connect the cloud to on-premises networks, and both sides need routes to each other.
Check yourself
A subnet's route table sends 0.0.0.0/0 to a NAT gateway. What kind of subnet is it?
A web server in a public subnet has the public IP address 203.0.113.25. You run ip addr on the VM. What address does it show?
You allow inbound TCP 443 in a network ACL, but connections still time out. The security group also allows TCP 443. What is the most likely cause?
From the web server, you test the app server on port 8080 with nc and get "Connection refused". Where is the problem?
The office uses 10.0.0.0/16 and you plan to connect a new VPC by VPN. Which VPC range is the better choice?
Related lessons
Cloud networking is built from ideas you already know. These lessons cover the building blocks, the physical data centres the cloud runs on, and the full end-to-end picture.
Learn more: Public and Private IP AddressesSubnet Mask BasicsThe Default GatewayHow NAT and PAT WorkFirewall BasicsVPN BasicsData Centre Networking BasicsWhat Happens When You Open a Website?