What is a VPC flow log and how would you use it when a connection is mysteriously dropped?
BeginnerScenarioVPC and Networking
Answer
Situation read → Flow logs record accepted and rejected flows per ENI, subnet or VPC.
What I'd do →
- Enable:
aws ec2 create-flow-logs --resource-type VPC --resource-ids vpc-0abc --traffic-type ALL --log-destination-type s3 --log-destination arn:aws:s3:::flowlogs-bucket - Query with Athena for
action = 'REJECT'on the destination IP and port - Distinguish SG vs NACL: stateless NACL rejects often show up on return traffic
- Fix the rule that shows the REJECT
Why → Flow logs show whether traffic reached the ENI and was refused, narrowing blame to the network.
Interview tip → Flow logs exclude DNS to Route 53 resolver and IMDS traffic.
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