Q: Two EC2 instances in the exact same VPC and subnet cannot ping each other, but they can both reach the internet. What is the most likely cause?
If they can reach the internet, the routing table and internet gateways are correct. The issue is security at the instance or subnet level.
Want to master this scenario in a live sandbox? KodeKloud's Istio Service Mesh & Advanced Kubernetes Networking Course covers this exact problem with hands-on terminal drills.
🛠️ Production Runbook & Step-by-Step Resolution
Direct Answer: "When an interviewer asks how I diagnose network connectivity, I follow an outside-in OSI model approach. The interviewer is testing: Security Groups vs Network ACLs, default behaviors.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."
Initial Diagnostics & Root Cause Analysis
If they can reach the internet, the routing table and internet gateways are correct. The issue is security at the instance or subnet level.
- Local OS firewall (
iptablesorfirewalld) blocking ICMP. - Network ACLs (NACLs) are usually stateless and evaluated before SGs, but if they were blocking local traffic, they'd likely block the internet return traffic too, unless misconfigured with exact IP denies.
Remediation & Permanent Safeguards
The most likely culprit is the Security Group. By default, AWS Security Groups permit all outbound traffic but deny all inbound traffic. If they are in the same security group, they still cannot ping each other unless there is an explicit inbound rule allowing ICMP traffic from the self-referencing security group ID (or the subnet's CIDR). Other possibilities:
- Local OS firewall (iptables or firewalld) blocking ICMP.
- Network ACLs (NACLs) are usually stateless and evaluated before SGs, but if they were blocking lo...
Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:
- Ignoring MTU fragmentation and Path MTU Discovery (PMTUD) packet drops across VPN or DirectConnect links when addressing networking When intermediate routers drop ICMP fragmentation-needed messages, large TCP packets are silently dropped (black-holed), causing connections to stall.
- Overlooking DNS TTL propagation and negative caching behavior (SOA MINIMUM) during traffic migrations Shortening TTL values immediately before a migration fails if upstream resolving nameservers cache previous records or negative NXDOMAIN lookups.
- Debugging complex network packet anomalies without capturing raw network packet dumps via tcpdump Packet captures provide definitive ground truth on TCP SYN-ACK handshakes, RST resets, and TLS handshake alert codes.
- Failing to pass X-Forwarded-For and X-Forwarded-Proto headers across edge proxy termination layers Omitting proxy protocol headers breaks downstream security rate limiters, client geo-routing, and SSL redirect validation.