Skip to content
Learn Netverks

Lesson

Step 22/36 61% through track

security-groups-nacls

Security groups and NACLs

Last reviewed Jun 1, 2026 Content v20260601
Track mode
none
Means
Read / quiz
Reading
~2 min
Level
beginner

This lesson

This lesson teaches Security groups and NACLs: AWS concepts, console/CLI practice patterns, and how the service fits in a typical cloud architecture.

Network segmentation limits blast radius when credentials leak—default VPC habits are interview and audit fodder.

You will apply Security groups and NACLs in contexts like: Production hosting, data pipelines, and corporate cloud landing zones.

Read the lesson, reproduce steps in your AWS Free Tier or sandbox (console and optional AWS CLI), diagram the architecture in notes, and complete MCQs—no in-browser cloud lab.

When you can explain the previous lesson's ideas in your own words.

Security groups are stateful firewalls at the instance/ENI level. Network ACLs (NACLs) are stateless subnet-level filters—use SGs for most rules; NACLs for coarse subnet guardrails.

Security group rules

  • Inbound — allow SSH (22) only from your IP for learning
  • Outbound — often all traffic allowed by default
  • Stateful — return traffic automatically allowed
  • Reference other SGs (e.g. ALB SG → app SG on port 8000)

NACL basics

Numbered rules, evaluated in order, stateless—must allow return traffic explicitly. Default VPC NACL allows all; custom deny rules can block IP ranges at subnet edge.

List security groups

aws ec2 describe-security-groups \
  --query 'SecurityGroups[].{Id:GroupId,Name:GroupName,VpcId:VpcId}' \
  --output table

Practice: Create S3 buckets and VPC resources only in a sandbox account. Use unique bucket names globally; delete buckets and empty objects when finished.

Least exposure

Never open SSH (22) or RDP (3389) to 0.0.0.0/0 in production. Use Session Manager or bastion with tight SG rules. See Cybersecurity for hardening patterns.

Important interview questions and answers

  1. Q: Stateful vs stateless?
    A: SG tracks connection state; NACL does not—return paths need explicit allow in NACL.
  2. Q: SG vs NACL scope?
    A: SG attaches to ENI/instance; NACL attaches to subnet.

Self-check

  1. Why restrict SSH to your IP instead of 0.0.0.0/0?
  2. What does stateful mean for a security group?

Pitfall: Confusing stateful SG with stateless NACL—return traffic rules differ.

Interview prep

Stateful SG?

Return traffic automatically allowed for established connections.

SSH best practice?

Restrict port 22 to known IPs—never 0.0.0.0/0 in production.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • SG vs NACL?
  • SSH 0.0.0.0/0?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump