A cloud engineer must block a known hostile address range at the edge of one subnet in a virtual private cloud. The rule must sit among numbered allow and deny rules shared by every server in the subnet.
The virtual private cloud
A virtual private cloud is a private network that an organisation builds inside a cloud provider's data centres, using settings instead of cables. No background is assumed. A security professional needs it because the customer, not the provider, writes the routes and filters around each server. One wrong setting can put a private database on the internet.
By the end of this unit you will be able to:
- Explain what makes a subnet in a virtual private cloud public or private
- Tell apart a security group and a network access control list on level, rule type, order and state
- Choose between peering, a transit hub and a private endpoint for joining a virtual private cloud to other networks
- Explain which security tasks stay with the customer under the shared responsibility model
The booking database anyone could reach
An illustrative example
A chain of four dental surgeries moves its appointment system to a cloud provider. A contractor builds the network in an afternoon. The web server and the patient database sit side by side, both with public addresses and a rule that accepts connections from anywhere.
Three months later a security researcher emails the practice manager. She has found the database from her home, read its list of tables, and stopped there. The contractor points out that the provider's data centre is certified secure.
Which settings, and whose, should have kept the database off the internet while the web server stayed open?
A private network built from settings in a shared data centre
A cloud provider is a company that rents out computing, storage and networks from its own data centres, paid for by use. Many customers share the same physical machines. Each customer's servers are virtual machines: complete computers made in software, several of which run side by side on one physical server.
A virtual private cloud (VPC) is a customer's own private network inside the provider's data centres. The customer chooses its address range, divides it into smaller networks, and decides what may enter and leave. Other customers' traffic cannot see into it, although it runs on shared equipment.
A private floor in a shared office tower
A firm rents the twelfth floor of a tower. The landlord owns the building, the lifts and the front desk. The firm decides how its floor is divided into rooms, which doors lock and who gets a key. A visitor can only arrive by a route the floor's own plan allows.
The provider builds and protects the tower. The customer designs the floor. Providers use different product names for the same parts. The names below are those used by Amazon Web Services. Other providers offer the same building blocks under their own names.
A subnet is public or private because of its routes
A VPC is divided into subnets, each a smaller range of addresses holding servers with a similar job. Each subnet follows a route table, the list of where its outgoing traffic may be sent. What a subnet can reach is decided by that table, and so is whether the internet can reach it.
- Internet gateway
- The VPC's door to the internet. Traffic passes through it only from subnets whose route table points there.
- Public subnet
- A subnet with a route to the internet gateway. A server here with a public address can be reached from the internet. Web servers and load balancers live here.
- Private subnet
- A subnet with no route to the internet gateway. Application servers and databases live here.
- NAT gateway
- A device in a public subnet that lets servers in a private subnet start connections out, for example to fetch updates. It rewrites their private source address to its own, so nothing on the internet can start a connection back to them.
- Isolated subnet
- A subnet with no route out of the VPC at all.
Only the public subnet has a route in
Read this figure as text
A VPC is divided into subnets, and each follows a route table. A subnet is public or private because of its routes: only a subnet whose route table points to the internet gateway can be reached from the internet.
- Users' requests arrive from the internet at the internet gateway, the VPC's door to the internet.
- The public subnet has a route to the internet gateway, so requests reach the load balancer there.
- The load balancer passes them on to the application server in the private subnet, which has no route to the internet gateway. The database sits there too.
- Servers in the private subnet start connections out, for example to fetch updates, through the NAT gateway in the public subnet. It rewrites their private source address to its own.
- The NAT gateway sends that traffic out through the internet gateway, and nothing on the internet can start a connection back to the private servers.
- Each server has a security group: a stateful filter of allow rules attached to it. The edge of each subnet carries a network access control list: a stateless, numbered list of allow and deny rules.
- Everything inside the VPC, routes and filters alike, is configured by the customer under shared responsibility.
The usual design puts only the load balancer or web server in a public subnet. Everything holding data sits in private subnets and leaves through the gateway when it must.
Security groups guard servers; network ACLs guard subnets
Two filters decide which traffic is allowed once a route exists. Both are rules the customer writes.
A security group is a attached to each virtual machine. It holds allow rules only, and anything not allowed is refused. It is stateful: it remembers each connection it let through, so the reply is admitted without a rule of its own.
A network access control list (network ACL) is a filter on the edge of a subnet that every server in it shares. It holds numbered allow and deny rules, read from the lowest number upward until one matches. It is stateless: it judges every alone, so replies need rules of their own.
| Point | Security group | Network ACL |
|---|---|---|
| Attached to | Each virtual machine | Each subnet |
| Rules | Allow only | Allow and deny |
| How rules are read | All rules, then decide | In number order; first match wins |
| Reply traffic | Allowed automatically (stateful) | Needs its own rule (stateless) |
| Best used for | The main, precise control | A coarse second layer, such as blocking a known bad range |
Used together they give . If a server is launched with the wrong security group, the subnet's network ACL still limits what can reach it. A new subnet's default network ACL allows all traffic, so it adds nothing until someone writes rules.
Peering, transit hubs and private endpoints join a VPC to others
A VPC rarely stands alone. It may need to reach another VPC, the company's offices or one of the provider's services.
- VPC peering
- A private link between exactly two VPCs, using private addresses. The two address ranges must not overlap. Peering is not transitive: if A peers with B and with C, B still cannot reach C through A.
- Transit gateway
- A hub that many VPCs and the office networks connect to, with its own route tables deciding which may talk to which. It replaces a tangle of peering links.
- Site-to-site VPN or dedicated line
- An tunnel over the internet, or a leased private circuit, from the company's own sites into the VPC.
- Private endpoint
- A connection to one of the provider's services, such as file storage, that stays on private addresses. No internet gateway, NAT gateway or public address is needed.
Each join widens what can reach what. Peering exposes the whole range of the other VPC unless routes and security groups narrow it. A private endpoint is the safest way to use a provider's service from a private subnet, because the traffic never needs a path to the internet.
The provider secures the cloud; the customer secures what is in it
The shared responsibility model divides security duties between a cloud provider and its customer. The provider secures the cloud itself: buildings, physical machines, the software that runs virtual machines, and its own network. The customer secures what it puts in the cloud.
- The VPC's subnets and route tables
- Security group and network ACL rules
- Which servers receive public addresses
- the virtual machines' own software
- The data, its encryption and who may read it
- Turning on and reading it
VPC flow logs are the network record the customer switches on. Each line records one flow: source and destination address, ports, protocol, packets, bytes, time, and whether it was accepted or rejected. carry no content. They are collected away from the traffic's path, so they do not slow it. They show who tried to reach a database, and whether a rule stopped them.
Common misconception
“A provider whose data centres are certified secure keeps every customer's servers secure.”
The certification covers the provider's share. Routes, filters, public addresses and patching are the customer's settings, and an open rule or a public database is the customer's failure.
A question, worked through
A council runs a planning portal in a VPC. The web servers are in a public subnet. The database is in a private subnet and must download security updates from the internet each night. An auditor reports that the database's subnet has a route to the internet gateway and that the database holds a public address.
Which change BEST removes the exposure while keeping the nightly updates?
Decide on your answer, then open the reasoning
- The question asks for a fix that stops the internet starting connections to the database but still lets the database start its own connections out.
- Rule out c: flow logs record who tried to connect. They detect the exposure and do not remove it.
- Rule out d: moving the database into a peered VPC adds a link and changes nothing about its public address or its route out.
- Between a and b: a deny-all inbound rule on a stateless network ACL also blocks the replies to the database's own update requests, so updates fail. A NAT gateway lets the database start connections out while nothing outside can start one in.
- Option a fixes the cause, the route and the address, and keeps the updates, so it is the best answer.
Answer: A. Route the database subnet through a NAT gateway and remove its public address
Choosing between good answers
- A question asks what makes a cloud subnet public
- the answer is its route to an internet gateway, not its name or its filters.
- Servers in a private subnet must reach the internet but must not be reachable from it
- choose a NAT gateway.
- Options contrast security groups with network ACLs
- security groups are per server, allow only and stateful. Network ACLs are per subnet, numbered allow and deny, and stateless.
- A VPC must use the provider's storage or database service without any internet path
- choose a private endpoint.
- A cloud breach came from an open rule or a public address
- it is the customer's responsibility under the shared responsibility model, whatever the provider's certifications.
Try it
Follow a request from an office laptop into a private cloud subnet and find which rule the customer, not the provider, wrote.
Loading the preview.
Check your understanding
4 questions on this unit, easiest first. Confirm an answer to see the reasoning for it, then the right answer, the other options and the rule to reuse. Your answers are kept in this browser and feed readiness and review.
These questions are drafts that no named reviewer has approved yet.
Question 1 of 4
What to remember
- A virtual private cloud is a customer's own private network inside a shared cloud provider, built from settings.
- A subnet is public when its route table points to the internet gateway. Data belongs in private subnets, which reach out through a NAT gateway.
- A security group is a stateful, allow-only firewall on each server. A network ACL is a stateless, numbered allow and deny list on each subnet.
- Peering joins two VPCs and is not transitive. A transit gateway joins many. A private endpoint reaches a provider's service with no internet path.
- Under shared responsibility the customer owns its routes, rules, patching, data and logging. Flow logs record each flow's addresses, ports and verdict, never its content.
Say it from memory
What makes a VPC subnet public or private, and how do security groups and network ACLs differ?
A public subnet has a route to the internet gateway; a private subnet does not and reaches out through a NAT gateway. Security groups attach to each server, allow only and are stateful. Network ACLs attach to a subnet, have numbered allow and deny rules read in order, and are stateless. The customer configures all of it and switches on flow logs.
What is a virtual private cloud, and who decides its layout?
A virtual private cloud (VPC) is a customer's own private network inside a cloud provider's data centres. The customer chooses its address range, divides it into smaller networks and decides what may enter and leave. Other customers' traffic cannot see into it, although it runs on shared equipment.
What does a NAT gateway let a private subnet do, and what is an isolated subnet?
A NAT gateway sits in a public subnet and lets servers in a private subnet start connections out, for example to fetch updates. It rewrites their private source address to its own, so nothing on the internet can start a connection back to them. An isolated subnet has no route out of the VPC at all.
Is VPC peering transitive, and what is the safest way for a private subnet to use a provider's service?
No. If A peers with B and with C, B still cannot reach C through A, and the two peered address ranges must not overlap. A private endpoint is the safest way, because it reaches the service on private addresses with no internet gateway, NAT gateway or public address.
Under the shared responsibility model, what does the cloud provider secure, and what do VPC flow logs record?
The provider secures the cloud itself: buildings, physical machines, the software that runs virtual machines and its own network. The customer secures what it puts in. Each flow log line records source and destination address, ports, protocol, packets, bytes, time, and whether the flow was accepted or rejected, with no content.
Sources
- Infrastructure security in Amazon VPC, Amazon Web ServicesA VPC is a logically isolated virtual network. Security groups work per instance, allow only, evaluate all rules and are stateful. Network ACLs work per subnet, allow and deny, are read in ascending order, are stateless and serve as a second layer.
- Subnets for your VPC, Amazon Web ServicesA public subnet routes directly to an internet gateway. A private subnet does not and needs a NAT device. An isolated subnet has no route out. The default network ACL allows all traffic.
- NAT gateways, Amazon Web ServicesA NAT gateway lets instances in a private subnet connect out while external services cannot start connections to them; it sits in a public subnet and translates the source address.
- How VPC peering connections work, Amazon Web ServicesA peering connection joins two VPCs, their address ranges cannot overlap, and transitive peering is not supported.
- What is AWS Transit Gateway for Amazon VPC?, Amazon Web ServicesA transit gateway is a hub that interconnects VPCs and on-premises networks, with its own route tables.
- What is AWS PrivateLink?, Amazon Web ServicesA VPC endpoint reaches services privately without an internet gateway, NAT device or public address.
- Logging IP traffic using VPC Flow Logs, and Flow log records, Amazon Web ServicesFlow logs capture IP traffic to and from network interfaces, outside the traffic's path. Each record holds addresses, ports, protocol, packets, bytes, times and an ACCEPT or REJECT action.
- AWS Shared Responsibility Model, Amazon Web ServicesThe provider secures the infrastructure of the cloud; the customer secures what it puts in the cloud, including security group configuration and its data and encryption.