Interview questions and model answers
"What happens when you type a URL into a browser?"
The browser checks its caches, then resolves the hostname through the OS stub resolver and a recursive resolver, which walks root, TLD and authoritative servers and caches the answer by TTL. The OS routes the packet to the default gateway after ARP finds its MAC. TCP does a three-way handshake to port 443, TLS verifies the certificate and agrees session keys, then the HTTP request goes out — typically through a CDN or ALB that terminates TLS and routes by host and path to a backend. The response comes back and the browser renders, fetching further resources over the same connection with HTTP/2. I'd mention the debugging tool for each step.
"Security group vs NACL?"
Security groups are stateful allow-lists attached to ENIs, evaluated as a whole, and can reference other security groups. NACLs are stateless subnet-level lists with allow and deny rules, evaluated in number order with first match winning, so you must allow return traffic on ephemeral ports. I use SGs for almost everything and NACLs only for coarse guardrails.
"Connection refused vs connection timed out?"
Refused means the packet reached the host and it actively rejected it with a RST — nothing listening on that port, or listening only on localhost. Timed out means no response — something dropped the packets: a security group, NACL, firewall, missing route, or the host is down. They point to completely different fixes.
"Private subnet instances can't reach the internet. Walk me through it."
Check that a NAT gateway exists in a public subnet with an Elastic IP, that the public subnet routes 0.0.0.0/0 to an internet gateway, that the private subnet's associated route table routes 0.0.0.0/0 to the NAT gateway, and that SGs and NACLs allow the outbound traffic and the return traffic. If the goal is only AWS services like S3 or ECR, I'd add VPC endpoints instead — cheaper and more private.
"ALB vs NLB?"
ALB is layer 7: HTTP-aware routing by host, path and headers, TLS termination with ACM, WAF, OIDC authentication, redirects, per-request balancing for gRPC. NLB is layer 4: TCP/UDP/TLS, static IPs per AZ, extreme throughput and low latency, client IP preservation, and it's the front for PrivateLink services. HTTP microservices go behind an ALB; non-HTTP protocols, static IP requirements or PrivateLink go behind an NLB.
"Explain SNAT vs DNAT with examples."
SNAT rewrites the source address — a NAT gateway letting private instances reach the internet with one public IP, or pods egressing with the node's IP. DNAT rewrites the destination — a load balancer or Docker's -p 8080:80 forwarding to a backend, or kube-proxy translating a Service ClusterIP to a pod IP. Both rely on connection tracking to translate replies back.
"How would you design network isolation for a three-tier app on AWS?"
A VPC across three AZs with public subnets for the ALB and NAT gateways, private subnets for the application tier, and isolated subnets for databases without internet routes. Security groups chain: the ALB accepts 443 from the internet, the app accepts only from the ALB SG, the database only from the app SG. VPC endpoints for S3, ECR, STS and logging, Flow Logs enabled, and NACLs only as broad guardrails.
"Why might a NetworkPolicy have no effect?"
Because NetworkPolicy is only an API — enforcement depends on the CNI. If the CNI doesn't implement it (Flannel, or the VPC CNI without network policy enabled), policies are accepted but ignored. Also check the policy's selectors actually match the pods and namespaces.