What Are Public and Private Subnets?

halfbrain_logo512adminJune 22, 2026
96 lượt xem

Public and private subnets are network zones inside a cloud network.

A public subnet can route traffic directly to and from the internet. A private subnet does not directly expose its resources to the internet and is usually used for application servers, databases, internal systems, and sensitive workloads.

The practical rule is simple: expose only the entry point, not the whole system.

Cloud Architecture Brief

Architecture Problem

Beginners often put everything in one public subnet, making databases, admin ports, and internal services easier to attack.

Business Context

Companies need subnet design to separate internet-facing services from private application and data layers.

Core Concept

A subnet is a smaller network segment inside a cloud network. Public or private behavior is determined mainly by routing and exposure, not by the name alone.

Learn Once, Apply Ten

If you understand route tables, internet gateway, NAT, firewall rules, and workload placement, you can design safe network segmentation across cloud providers and data centers.

Architecture Decision

Architecture Pattern

three_tier

Workload Type

api_backend

Cloud Model

public_cloud

Reference Architecture

Public subnet contains load balancer and NAT gateway. Private app subnet contains application servers. Private data subnet contains database and cache. Route tables control which subnet can reach the internet.

Key Design Decision

Place only necessary public entry points in public subnets and keep application and data layers private.

Why This Design

This reduces attack surface and limits what an external attacker can directly reach.

Trade-offs

More subnet segmentation improves security but requires better routing, firewall, DNS, and troubleshooting skill.

Cloud Building Blocks

Compute Layer

Web servers or app servers usually run in private subnets behind a load balancer unless direct public access is required.

Network Layer

Internet gateway enables direct internet routing; NAT enables outbound internet access from private subnets; route tables define the actual traffic path.

Storage Layer

Private workloads should access object storage through private endpoints when security and compliance require it.

Database Layer

Databases should be placed in private data subnets and accept traffic only from application subnets or controlled admin paths.

Security Layer

Use security groups, network ACLs, firewall rules, private endpoints, and no public IPs for sensitive systems.

Observability Layer

Use flow logs, firewall logs, NAT metrics, load balancer logs, and DNS logs to understand traffic behavior.

Enterprise Readiness

Reliability Design

Create subnets across multiple availability zones so one zone failure does not remove the whole application layer.

Scalability Design

Plan CIDR ranges with enough IP space for autoscaling, Kubernetes pods, managed services, and future environments.

Security Controls

Block public database access, restrict admin ports, separate production and development, and review route tables before launch.

Cost Optimization

Avoid unnecessary NAT traffic, use private endpoints when cheaper and safer, and avoid overbuilding network appliances.

Operational Runbook

When a private server cannot connect, check route table, NAT, firewall rule, DNS, endpoint policy, and target service status.

Failure & Job Readiness

Risk Checklist

Confirm subnet route tables; confirm no public IP on private systems; confirm database access source; confirm NAT or private endpoint path; confirm flow logs.

Recovery Strategy

Remove public IP, fix route table, close firewall rule, move resource to correct subnet, restore NAT path, or isolate exposed system.

Real Company Scenario

A company wants customer traffic to reach an API but does not want customers to directly access app servers, databases, or internal admin tools.

Interview Angle

Explain why a private subnet is not secure by name alone and how route tables decide public or private behavior.

Hands-on Lab

Design a VPC with one public subnet, one private app subnet, and one private database subnet. Mark route table, NAT, firewall rules, and allowed traffic.

Related Concepts

VPC; Route Table; NAT Gateway; Firewall; Private Endpoint

Share:

Disclaimer: The guides, checklists, commands, and examples on HalfBrain.net are provided for educational and operational reference only. Server environments, hosting providers, software versions, security settings, and WordPress configurations can vary, so you should always review commands before running them on your own system. We do our best to keep the content accurate and useful, but we cannot guarantee that every command, configuration, or recommendation will fit every environment. Always back up your website, database, and server configuration before making changes. HalfBrain.net is not responsible for data loss, downtime, security incidents, misconfiguration, or other issues that may result from applying the information on this website. Use the material at your own discretion.

Leave a Reply

Your email address will not be published. Required fields are marked *