AWS Certified SysOps Administrator - Associate
Domain 5 Networking and Content Delivery
Configuring VPC Components Subnets Route Tables and Security GroupsNACLs
Welcome, students. In this lesson, we dive into configuring essential VPC components such as subnets, route tables, security groups, and network access control lists (NACLs) within AWS. These components work together to create a secure and isolated network environment tailored to your specific requirements.
Virtual Private Cloud (VPC) is a secure, isolated network segment within AWS that manages a range of IP addresses. Almost every AWS resource—whether it's a Lambda function with a network interface, an EC2 instance, or a container on a virtual machine—resides within a VPC subnet. This design empowers you with full control over network segmentation, routing, and firewall security.
A VPC spans an entire AWS region. AWS operates in over 30 geographic regions—such as Virginia, Oregon, Ohio, Mumbai, and Singapore. Each VPC is confined to a single region and acts as a logical boundary grouping a set of subnets.
Every VPC is associated with one or more IP address ranges, known as CIDR blocks. For instance, a CIDR block like 192.168.0.0/16 represents a large pool of IP addresses. You can also add additional CIDR blocks—including IPv6 addresses—to further expand your network. Although the slash notation might imply that a /16 is smaller than a /20, in reality a /16 block contains far more addresses (approximately 65,000 compared to 4,096).
VPCs serve as logical containers within your AWS account. AWS creates a default VPC in every region, allowing you to launch EC2 instances quickly without a custom setup. However, many organizations choose to build custom VPCs to meet specific security and configuration needs.
When using either the default or a custom VPC, you need to configure its internal components. In a default VPC, a typical CIDR block (e.g., 172.31.0.0/16) delivers 65,536 addresses. Subnets are then carved out from this space (for example, using a /20 block), where you can think of the VPC as the whole pie and each subnet as a slice.
Remember that AWS reserves the first four IP addresses and the last IP address within each subnet. This reservation means that a subnet with an apparent 4,096 addresses will have a few addresses that are not assignable.
Additionally, the default VPC is equipped with an Internet Gateway. The Internet Gateway connects your VPC to the internet; however, attaching one does not automatically expose your resources. Security measures like security groups and NACLs ensure that inbound access remains restricted unless explicitly enabled.
By default, public subnets in the VPC allow outbound internet traffic when configured with proper security group rules, though inbound connections remain blocked. Alongside the Internet Gateway, default VPCs include a security group and a NACL—these form the cornerstone of your instance-level and subnet-level security.
Subnets reside in individual Availability Zones (AZs) within a region. Although the VPC covers the entire region, subnets are confined to specific AZs to maximize high availability by distributing resources across different data centers. Subnets can be set up as either public or private, but the CIDR block assigned to any subnet must be a subset of the parent VPC's CIDR block.
A subnet’s CIDR block must fall within a /16 to /28 range. AWS reserves the first five IP addresses and the final IP in every subnet (typically used for the network address, router IP, DNS, and future purposes). For example, if you have a subnet of 192.168.0.0/24, the first available usable IP might start at 192.168.0.4.
When designing your network, ensure that the CIDR blocks for your subnets do not overlap; every subnet must represent a unique portion of your VPC’s IP address space. It is also possible to configure subnets as IPv6-only if needed.
Route Tables: Directing Traffic Within Your VPC
Routing within a VPC is controlled by route tables, which can be associated with individual subnets or with the VPC as a whole. A common configuration directs all non-local traffic to the Internet Gateway. The router’s interface (often the first usable IP address in a subnet, such as 192.168.1.1 for a 192.168.1.0/24 subnet) acts as the default gateway.
Just like a home network router that guides packet traffic, AWS route tables define how data is routed between subnets, to the internet, or even between other networks. Each subnet must be associated with exactly one route table, though a single route table may cover multiple subnets.
Firewalls in AWS: NACLs and Security Groups
AWS offers two types of firewalls to protect your network:
Stateless Firewalls (NACLs)
Network Access Control Lists (NACLs) are stateless firewalls that operate at the subnet level. They require explicit rules for both inbound and outbound traffic since they do not track connection states.
Stateful Firewalls (Security Groups)
Security groups act as stateful firewalls attached to individual resources. They automatically allow response traffic to outbound requests and only require allow rules to be specified. Traffic not explicitly allowed is denied by default.
Stateless Firewalls: NACLs
NACLs filter traffic at the subnet perimeter. Because they do not track the state of connections, each direction (inbound and outbound) must be configured independently. For example, when a client accesses a web server on port 80, you must add rules for both inbound client requests and outbound responses.
Stateful Firewalls: Security Groups
In contrast, security groups track connection states. When an inbound rule permits traffic, the corresponding outbound response is automatically allowed. This stateful behavior simplifies configuration as you only need to explicitly allow traffic in one direction.
In AWS, NACLs operate at the subnet level and are ideal for defining explicit allow or deny rules based on IP ranges, protocols, and port numbers. Security groups, however, attach directly to instances, RDS databases, or load balancers, and they only use allow rules to control access.
Comparing NACLs and Security Groups
- NACLs filter traffic at the subnet level and offer fine-grained control with both allow and deny rules.
- Security groups control traffic at the instance level, automatically permitting return traffic for allowed outbound calls.
- For example, you might define a custom TCP rule in a security group to allow inbound traffic on port 200 only from the IP address 1.1.1.1/32.
- By default, security groups allow all outbound traffic, ensuring that your instances can reach external destinations while inbound traffic is restrictive.
NACLs, on the other hand, evaluate rules in order. For instance, if a NACL rule denies traffic from a known bad IP range with a lower-numbered rule, that traffic will be dropped before a later allow rule is reached. In the default VPC, NACLs generally allow all traffic, leaving security groups as the primary access control mechanism.
When multiple security groups are assigned to the same resource, the effective permissions are a combination of all rules, with the most restrictive rules taking precedence.
Additional Important Points
- Security groups have default outbound rules that allow all traffic.
- Each subnet in a VPC is automatically associated with a NACL. Although a single NACL can be associated with multiple subnets, a subnet can only be linked to one NACL.
- NACLs do not filter some critical types of traffic such as DNS lookups, DHCP, EC2 instance metadata, ECS task metadata, NTP, or essential router communications. AWS ensures that these services function without interruption.
Lesson Summary
- A VPC is a pool of IP addresses confined to a single AWS region.
- Subnets are smaller segments within a VPC, each assigned to specific Availability Zones for high availability.
- Default VPCs come preconfigured with an Internet Gateway, security groups, and NACLs.
- Route tables control the flow of traffic between subnets, to the internet, and external networks.
- NACLs (stateless) and security groups (stateful) complement each other to secure your AWS resources by managing traffic based on different rule models.
Stay focused on these core concepts and best practices as you continue your studies. Happy networking, and see you in the next lesson!
Watch Video
Watch video content