SkillSprout
Chapter 5 · Lesson 1
Intermediate
7 min read

VPC Connectivity Troubleshooting

Overview

"I can't connect" is the most common operations ticket in AWS. The fix is almost always found by walking the packet path one hop at a time: instance firewall (security group), subnet firewall (network ACL), route table, gateway (IGW, NAT, endpoint, peering, TGW), then the far side's controls.

Treat it like tracing a parcel: the label (IP and port), the van (route), the building gate (NACL) and the receptionist (security group) must all agree. One missing step and the parcel never arrives. VPC Reachability Analyzer automates the trace by analysing configuration without sending any packets.

Mastering the differences between stateful security groups and stateless NACLs, and between public and private connectivity paths, answers a large portion of the SOA-C03 networking domain.

Key Concepts

  • Security groups are stateful, allow-only, attached to ENIs; return traffic is automatically allowed. They can reference other security groups.
  • Network ACLs are stateless, support allow and deny, numbered rules evaluated in order, applied per subnet; you must allow ephemeral ports (1024-65535) for return traffic.
  • A subnet is public only if its route table has 0.0.0.0/0 -> igw-...; the instance also needs a public/Elastic IP.
  • Private subnets reach the internet through a NAT gateway (in a public subnet, one per AZ for HA) with a route 0.0.0.0/0 -> nat-....
  • Gateway endpoints (S3, DynamoDB) add prefix-list routes; interface endpoints (PrivateLink) create ENIs with private DNS.
  • Most specific route (longest prefix) wins; local routes cannot be overridden except with more specific routes in some cases.
  • Reachability Analyzer tests source-to-destination paths and names the blocking component; Network Access Analyzer finds unintended access.
  • DNS inside a VPC requires enableDnsSupport and (for public DNS names) enableDnsHostnames.

Detailed Notes

Security group vs NACL

FeatureSecurity groupNetwork ACL
LevelENI / instanceSubnet
StateStatefulStateless
RulesAllow onlyAllow and deny
EvaluationAll rulesLowest rule number first
DefaultDeny inbound, allow outboundDefault NACL allows all; custom NACL denies all

Troubleshooting flow

StepQuestionTool
1Does the destination listen on the port?ss -tlnp, curl localhost:PORT via Session Manager
2Does the destination SG allow source/port?describe-security-groups
3Does the source SG allow outbound?SG outbound rules
4Do both subnets' NACLs allow request and response (ephemeral)?describe-network-acls
5Do route tables have a path both ways?describe-route-tables (return routes for peering/TGW!)
6Is there a public IP / NAT / endpoint?Instance details, NAT status
7Is DNS resolving correctly?dig, Route 53 Resolver logs
8Anything in between dropping packets?Flow Logs, Reachability Analyzer

Reachability Analyzer

bash
aws ec2 create-network-insights-path --source i-0aaa --destination i-0bbb \
  --protocol tcp --destination-port 443
aws ec2 start-network-insights-analysis --network-insights-path-id nip-0123
aws ec2 describe-network-insights-analyses --network-insights-analysis-ids nia-0123 \
  --query "NetworkInsightsAnalyses[0].[Status,NetworkPathFound,Explanations[].ExplanationCode]"

Explanation codes such as ENI_SG_RULES_MISMATCH, NO_ROUTE_TO_DESTINATION, SUBNET_ACL_RESTRICTION point directly at the cause.

Typical symptoms and causes

SymptomLikely cause
Cannot SSH to a public instanceNo public IP, IGW route missing, SG port 22 closed, NACL blocks, wrong key
Private instance cannot reach internetNAT gateway missing/route absent, NAT in private subnet, no EIP on NAT, SG outbound removed
Works one way onlyNACL missing ephemeral rule; missing return route (peering/TGW)
Peered VPCs cannot talkMissing routes on both sides, SGs not allowing the peer CIDR, overlapping CIDRs, no transitive routing
Cannot reach S3 privatelyGateway endpoint not associated to the route table; endpoint policy or bucket policy denies
Ping works but app failsSG allows ICMP only; app port closed
Intermittent failuresCross-AZ NAT dependency, conntrack limits, DNS issues, ENA allowance exceeded

CLI helpers

bash
aws ec2 describe-route-tables --filters Name=association.subnet-id,Values=subnet-0abc \
  --query "RouteTables[].Routes"
aws ec2 describe-security-groups --group-ids sg-0abc --query "SecurityGroups[].IpPermissions"
aws ec2 describe-nat-gateways --filter Name=state,Values=available
aws ec2 describe-vpc-endpoints --query "VpcEndpoints[].[ServiceName,VpcEndpointType,State]"

NACL ephemeral port example

json
[
  { "RuleNumber": 100, "Protocol": "tcp", "RuleAction": "allow", "Egress": false, "PortRange": {"From":443,"To":443},  "CidrBlock": "0.0.0.0/0" },
  { "RuleNumber": 110, "Protocol": "tcp", "RuleAction": "allow", "Egress": true,  "PortRange": {"From":1024,"To":65535}, "CidrBlock": "0.0.0.0/0" }
]

NAT gateway operations

  • Needs an Elastic IP (public NAT) and lives in a public subnet.
  • Scales to 100 Gbps automatically; one per AZ avoids cross-AZ charges and single-AZ failure.
  • Monitor ErrorPortAllocation (port exhaustion), PacketsDropCount and BytesOutToDestination.
  • Use gateway endpoints for S3/DynamoDB to avoid NAT data processing charges.

DNS inside VPCs

Interface endpoints with private DNS override the public service name so SDK calls route privately. If resolution fails, verify enableDnsSupport, DHCP option sets, and Route 53 Resolver rules.### Layered troubleshooting checklist

LayerCheckTool
RouteSubnet route table has a route to IGW/NAT/TGW/peering; return path existsReachability Analyzer, route tables
Security groupStateful; inbound rule for source/portdescribe-security-groups
Network ACLStateless; needs inbound AND outbound incl. ephemeral ports 1024-65535NACL rules
Public accessPublic IPv4/Elastic IP, IGW attached, route 0.0.0.0/0 to IGWConsole
IPv6 egressPrivate IPv6 outbound needs an egress-only internet gatewayRoute table
DNSenableDnsSupport and enableDnsHostnames; private hosted zone associationdig, Resolver logs
EndpointGateway endpoint route entry, interface endpoint private DNS and SGEndpoint policy
bash
aws ec2 create-network-insights-path --source eni-0aaa --destination eni-0bbb --protocol tcp --destination-port 3306
aws ec2 start-network-insights-analysis --network-insights-path-id nip-0123
aws ec2 describe-network-acls --filters Name=association.subnet-id,Values=subnet-0abc
aws ec2 describe-route-tables --filters Name=association.subnet-id,Values=subnet-0abc

A typical sign of NACL issues is requests arriving (seen in Flow Logs as ACCEPT inbound) but replies REJECTed outbound. Overlapping CIDRs block peering and TGW routing, and VPC peering is not transitive. VPC Network Access Analyzer finds unintended access paths, and Traffic Mirroring captures packets for deep inspection.

Real World Example

Scenario – new app tier cannot reach the database. After a migration, application servers in subnet A time out connecting to MySQL in subnet B. The engineer runs Reachability Analyzer from the app ENI to the database ENI on TCP 3306 and gets ENI_SG_RULES_MISMATCH: the database security group still allowed the old CIDR.

Fixing the rule to reference the app security group ID resolves the issue permanently, because group references track membership instead of IP ranges. The analysis is saved as a runbook step for future network incidents.

Architecture Diagram

Packet path checklist
Architecture
VPC
SourceSG outbound
NACLstateless
Route tableIGW / NAT / peer
Dest NACL
Dest SGstateful
Destinationport listening
  1. 1The source security group must allow the outbound connection.
  2. 2The subnet NACL must allow the packet, and ephemeral return traffic.
  3. 3A route must exist to the destination (and a return route on the other side).
  4. 4Destination NACL and security group must allow the port, and the service must be listening.

Best Practices

  • ✓Reference security group IDs instead of CIDRs between tiers.
  • ✓Keep NACLs simple (default allow) and use them for explicit deny needs; remember ephemeral ports.
  • ✓Run one NAT gateway per AZ and add gateway endpoints for S3/DynamoDB.
  • ✓Use Reachability Analyzer in runbooks and before/after network changes.
  • ✓Document CIDR plans to avoid overlaps that break peering/TGW.

Common Interview Questions

Exam Tips

SOA-C03 focus

  • SG = stateful allow-only; NACL = stateless allow+deny, ordered rules.
  • Private subnet internet access -> NAT gateway in a public subnet + route.
  • VPC peering is non-transitive and needs routes on both sides.
  • Diagnose paths without traffic -> Reachability Analyzer; see accepted/rejected traffic -> Flow Logs.

Finished this lesson?

0 of 46 lessons done · 0% of the course