Routelearn.net
Course menu

Unit 15: Modern Networking IntroductionLesson 15.2 (2 of 2 in this unit)84 of 84 in the Network Fundamentals course

Cloud Networking Basics

In the cloud, you never touch a cable or a switch, but the network is still there, built in software. Learn the vendor-neutral building blocks: the virtual private cloud, public and private subnets, route tables, internet and NAT gateways, security groups and network ACLs. You will also see how a cloud network connects back to the office.

Beginner · 17 min read · Before this: Public and private IP addresses, The default gateway, How NAT and PAT work, Firewall basics

Cloud networking is networking built from software-defined components, such as virtual private clouds, subnets, route tables, gateways and security groups. The cloud provider runs them on its own infrastructure, and customers configure them through a web console or API instead of installing physical equipment.

In simple terms: In the cloud, you still have networks, subnets, routers and firewalls, but they are settings you create in software rather than devices and cables you install.

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.

IaaS

Infrastructure as a Service: you rent virtual machines and networks and manage everything that runs on them. This is where cloud networking matters most.

PaaS

Platform as a Service: you run your code or database on a managed platform; the provider runs the servers.

SaaS

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

ConceptWhat it isAWSAzureGoogle Cloud
Virtual networkYour private, isolated networkVPCVNetVPC network
SubnetA slice of the network's address rangeSubnetSubnetSubnet
Route tableRules for where traffic goesRoute tableRoute table (UDR)Routes
Internet accessThe door between the network and the internetInternet gatewayBuilt in (system route)Default internet gateway
Outbound-only internetA shared public address for private resourcesNAT gatewayNAT gatewayCloud NAT
Resource firewallAllow rules for each serverSecurity groupNetwork security group (NSG)Firewall rules
Subnet firewallAllow/deny rules at the subnet edgeNetwork ACLNSG on the subnetFirewall rules / policies
Hybrid VPNEncrypted tunnel to the officeSite-to-Site VPNVPN GatewayCloud VPN
Dedicated linkPrivate circuit to the cloudDirect ConnectExpressRouteCloud 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.

Internet
users at e.g. 198.51.100.77
Cloud region
VPC / VNet · 10.0.0.0/16
Internet gateway
the VPC's door to the internet
Public subnet · 10.0.1.0/24

Route to the internet gateway: resources with a public IP are reachable from the internet (if security rules allow).

Web server10.0.1.10
public 203.0.113.25
🛡 SG web: allow TCP 443 from anywhere
NAT gateway10.0.1.5
public 203.0.113.40
Route table
DestinationTarget
10.0.0.0/16local
0.0.0.0/0internet gateway
Private subnet · 10.0.2.0/24

No route from the internet. Outbound only, through the NAT gateway.

App server10.0.2.20
🛡 SG app: allow TCP 8080 from SG web
Database10.0.2.30
🛡 SG db: allow TCP 5432 from SG app
Route table
DestinationTarget
10.0.0.0/16local
0.0.0.0/0NAT gateway
192.168.0.0/16VPN gateway
VPN gateway
encrypted tunnel / dedicated link
On-premises office
192.168.0.0/16
One VPC with a public and a private subnet. Network ACLs (not drawn) filter traffic at each subnet's edge; security groups (SG) filter traffic at each resource.

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 subnetPrivate subnet
Route for 0.0.0.0/0Internet gatewayNAT gateway (or none)
Reachable from the internet?Yes, if the resource has a public IP and security rules allow itNo
Can reach the internet?YesOutbound only, through the NAT gateway
Typical resourcesLoad balancers, web servers, NAT gateway, VPN endpointsApplication 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.

DestinationTargetMeaning
10.0.0.0/16localTraffic within the VPC is delivered directly. Created automatically, so every subnet can reach every other subnet
0.0.0.0/0internet gatewayEverything else goes to the internet (public subnet)
0.0.0.0/0NAT gatewayEverything else goes out through NAT (private subnet)
192.168.0.0/16VPN gatewayThe 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

Internet 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.
NAT gateway
  • 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

VPN tunnelCustomer198.51.100.77InternetInternet gatewayWeb server10.0.1.10 / 203.0.113.25NAT gateway10.0.1.5 / 203.0.113.40App server10.0.2.20Database10.0.2.30VPN gatewayOffice PC192.168.1.50
  1. 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. 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. 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. 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. 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:

WhereSource IP:portDestination IP:port
On the internet198.51.100.77:52010203.0.113.25:443
After the internet gateway (inside the VPC)198.51.100.77:5201010.0.1.10:443
Reply leaving the VM10.0.1.10:443198.51.100.77:52010
Reply after the internet gateway203.0.113.25:443198.51.100.77:52010

Flow 3, the private app server going out through the NAT gateway:

WhereSource IP:portDestination IP:port
Leaving the app server10.0.2.20:41822192.0.2.80:443
After the NAT gateway10.0.1.5:1031192.0.2.80:443
On the internet (after the internet gateway)203.0.113.40:1031192.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 groupNetwork ACL
Applies toEach resource (its network interface)A whole subnet, at its edge
Rule typesAllow rules only; everything else is deniedAllow and deny rules, checked in number order
Stateful?Stateful: replies to allowed traffic are allowed back automaticallyStateless: you must allow the reply direction too (including high "ephemeral" ports)
Can refer toIP ranges, or other security groups ("allow from SG web")IP ranges only
Typical useThe main control: open exactly the ports each server needsA coarse extra layer, for example to block a known bad range for a whole subnet
Internet gateway
Public → private IP
Network ACL
Subnet edge, stateless
Security group
At the VM, stateful
OS firewall
ufw / Windows Firewall
Application
Listening on TCP 443
An inbound packet must pass both cloud checks, plus the VM's own firewall

💡 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 VPNDedicated link
How it worksAn encrypted VPN tunnel over the internet between the office firewall or router and the cloud's VPN gatewayA private circuit from your site (or a partner's building) straight into the provider's network
Set-up timeMinutes to hoursWeeks (a physical circuit must be ordered)
PerformanceVaries with internet conditionsConsistent speed and delay; higher bandwidth
CostLowHigher
Common useSmall sites, backup for a dedicated linkLarge, 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:

  1. Creates a VPC, 10.0.0.0/16, which doesn't overlap the office's 192.168.0.0/16.
  2. 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.
  3. Gives the load balancer the only public address that customers use; the portal servers have private IP addresses only.
  4. 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.
  5. 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 failureSymptom
Public subnet has no 0.0.0.0/0 → internet gateway routeA 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 addressIt 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 deletedSoftware updates and outbound API calls time out
A security group is missing an allow ruleConnections time out (packets silently dropped)
A network ACL allows inbound traffic but not the outbound reply portsConnection attempts time out even though the security group looks right
The VPC and office ranges overlapThe VPN is up, but some or all hosts can't be reached
A whole availability zone failsServices 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:

  1. 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?
  2. Security group: Is the port allowed from the right source?
  3. Network ACL: Are both directions allowed, including the reply ports?
  4. Route table: Does the subnet's route table have the route you expect (internet gateway, NAT gateway or VPN)?
  5. 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.

Example output from a Linux virtual machine in a cloud VPC, written for this lesson
$ 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
What to look for: on 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).
Example output from a Linux virtual machine in a cloud VPC, written for this lesson
$ 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
What to look for: timed out. The web server got no answer at all from the app server, so the packets were silently dropped. In the cloud, that usually means a security group or network ACL rule is missing.
Example output from a Linux virtual machine in a cloud VPC, written for this lesson
$ nc -vz -w 5 10.0.2.20 8080
nc: connect to 10.0.2.20 port 8080 (tcp) failed: Connection refused
What to look for: Connection refused is different. The packet reached the app server, and the server replied that nothing is listening on port 8080. The network and security rules are fine; the application is stopped or uses another port. Learning to tell these two results apart saves hours.

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

Opening management ports to 0.0.0.0/0.

Allowing SSH (TCP 22) or RDP (TCP 3389) from the whole internet invites constant attacks. Allow only your office range, or use the VPN.

Putting databases in public subnets.

A database rarely needs to be reached from the internet. Keep it in a private subnet with no public IP address.

Choosing overlapping address ranges.

Overlapping ranges break routing over VPNs and peering. Before you build, pick VPC ranges that don't clash with the office or other VPCs.

Forgetting that network ACLs are stateless.

Network ACLs don't track connections, so they need rules for the reply traffic too.

Running everything in one zone.

An availability zone can fail as a whole. Spread important services over two or more zones.

Expecting the public IP address on the VM.

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.

Key takeaways
  • 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/0 to 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

Predict · scenario 1

A subnet's route table sends 0.0.0.0/0 to a NAT gateway. What kind of subnet is it?

Predict · scenario 2

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?

Predict · scenario 3

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?

Predict · scenario 4

From the web server, you test the app server on port 8080 with nc and get "Connection refused". Where is the problem?

Predict · scenario 5

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?

FAQ

Is a VPC the same as a VNet?
They are the same idea with different names. AWS and Google Cloud call a private, isolated network in the cloud a VPC (virtual private cloud); Microsoft Azure calls it a VNet (virtual network). The details differ. For example, a Google Cloud VPC spans all regions, while AWS VPCs and Azure VNets belong to one region. The building blocks in this lesson apply to all of them.
What makes a subnet public or private?
Its route table. A subnet is public when its route table sends internet-bound traffic (0.0.0.0/0) to an internet gateway. A private subnet has no such route. It usually sends 0.0.0.0/0 to a NAT gateway instead, so its resources can connect out but cannot be reached from the internet.
Do I still need a firewall in the cloud?
Yes. Security groups and network ACLs are the cloud's built-in firewalls, and every resource should be protected by them. Many organisations also add a dedicated cloud firewall service or a virtual firewall appliance for deeper inspection, logging and control of traffic between VPCs.
Why can't I see the public IP inside my virtual machine?
Because the public IP address is not configured on the VM. The VM's network interface has only its private address (for example, 10.0.1.10). The cloud's internet gateway translates between that private address and the public one as traffic enters and leaves. This is a one-to-one form of NAT.