What is the difference between a security group and a network ACL, and when would you touch NACLs?
BeginnerScenarioVPC and Networking
Answer
Situation read → SGs are stateful and attach to ENIs; NACLs are stateless and attach to subnets.
What I'd do →
- Default to SGs for all allow rules
- Use NACLs for coarse subnet-wide denies such as blocking a hostile CIDR
- Remember NACL rules need both inbound and outbound with ephemeral ports
1024-65535 - Inspect:
aws ec2 describe-network-acls --filters Name=vpc-id,Values=vpc-0abc
Why → SG rules are allow-only, NACLs support explicit deny and are evaluated in rule-number order.
Interview tip → State the "stateful vs stateless" contrast first.
More on VPC and Networking
What is a VPC and what are the CIDR constraints?BeginnerWhat makes a subnet public or private?BeginnerHow do route tables work, including the local route and longest-prefix match?IntermediateInternet Gateway vs NAT Gateway: what does each do?BeginnerNAT Gateway vs NAT instance?IntermediateSecurity group vs network ACL: compare them.Beginner