Ravindra BagaleCourses & study guides Track your progress

AWS Cloud

AWS VPC Hands-On Interview Questions: Subnets, Route Tables, NAT, VPN and Direct Connect with CLI (50 Questions)

This page has 50 hands-on VPC and hybrid networking interview questions with full answers. Set 1 explains what VPCs, subnets and gateways are, and Set 2 covers Transit Gateway, PrivateLink and Route 53. Here you build, check and fix networks from the command line, and handle real VPN and Direct Connect situations.

1. An everyday example: roads in a gated township

Why hands-on networking questions?

Network problems are the most common reason "the app cannot connect". Interviewers want to see that you can find the route table a subnet really uses, read a tunnel status, and explain why one path is chosen over another.

Think of a gated township. The VPC is the township wall, subnets are the blocks, route tables are the signboards at each junction, the internet gateway is the main gate, the NAT gateway is a guarded exit that lets residents out but not visitors in, and VPN or Direct Connect is a private road to your company's other office.

How to use this page

  • Build a small VPC in a test account with the commands here, then delete it.
  • NAT gateways and VPN connections are charged per hour, so remove them after practice.
  • All IDs and IP ranges are examples, such as account 111122223333 and 10.20.0.0/16.

2. Fresher level questions

Start here if you are a fresher or have less than two years of experience. Try to answer each question aloud first. Then open it and compare.

Q1. How do you create a VPC with a name tag from the CLI? Fresher
aws ec2 create-vpc --cidr-block 10.20.0.0/16 --tag-specifications 'ResourceType=vpc,Tags=[{Key=Name,Value=shop-vpc}]' --query Vpc.VpcId --output text

Output:

vpc-0a1b2c3d4e5f67890

A VPC with 65,536 private addresses was created and tagged.

A new VPC comes with a main route table, a default network ACL and a default security group. It has no internet gateway until you add one.

Q2. How do you create a subnet in a specific Availability Zone? Fresher
aws ec2 create-subnet --vpc-id vpc-0a1b2c3d4e5f67890 --cidr-block 10.20.1.0/24 --availability-zone ap-south-1a --tag-specifications 'ResourceType=subnet,Tags=[{Key=Name,Value=public-a}]' --query Subnet.SubnetId --output text

Output:

subnet-0a1a1a1a1a1a1a1a1

The subnet lives only in ap-south-1a. A subnet can never span AZs.

Use the AZ ID (such as aps1-az1) when you need the same physical AZ across accounts, because AZ names are mapped differently in each account.

Q3. How do you attach an internet gateway to a VPC and add a default route? Fresher
aws ec2 create-internet-gateway --query InternetGateway.InternetGatewayId --output text

Output:

igw-0b2b2b2b2b2b2b2b2
aws ec2 attach-internet-gateway --internet-gateway-id igw-0b2b2b2b2b2b2b2b2 --vpc-id vpc-0a1b2c3d4e5f67890
aws ec2 create-route --route-table-id rtb-0c3c3c3c3c3c3c3c3 --destination-cidr-block 0.0.0.0/0 --gateway-id igw-0b2b2b2b2b2b2b2b2

subnets associated with rtb-0c3c... can now send internet traffic to the gateway. Instances still need a public IP to be reachable.

Q4. How do you make instances in a subnet get a public IP automatically? Fresher
aws ec2 modify-subnet-attribute --subnet-id subnet-0a1a1a1a1a1a1a1a1 --map-public-ip-on-launch

Check:

aws ec2 describe-subnets --subnet-ids subnet-0a1a1a1a1a1a1a1a1 --query "Subnets[].MapPublicIpOnLaunch"

Output:

[true]

New instances launched here get a public IPv4 address by default.

Only use this on public subnets. Remember that public IPv4 addresses are charged per hour, so do not give them to instances that do not need them.

Q5. How do you find which route table a subnet really uses? Fresher
aws ec2 describe-route-tables --filters Name=association.subnet-id,Values=subnet-0d4d4d4d4d4d4d4d4 --query "RouteTables[].RouteTableId" --output text

If this returns nothing, the subnet has no explicit association and uses the VPC's main route table:

aws ec2 describe-route-tables --filters Name=vpc-id,Values=vpc-0a1b2c3d4e5f67890 Name=association.main,Values=true --query "RouteTables[].RouteTableId" --output text

Output:

rtb-0e5e5e5e5e5e5e5e5

This subnet follows the main route table. Many "why is my private subnet public?" problems come from a main route table that has a route to an internet gateway.

Q6. How do you see how many free IP addresses are left in a subnet? Fresher
aws ec2 describe-subnets --filters Name=vpc-id,Values=vpc-0a1b2c3d4e5f67890 --query "Subnets[].[SubnetId,CidrBlock,AvailableIpAddressCount]" --output table

Output:

| subnet-0a1a1a1a1a1a1a1a1 | 10.20.1.0/24 | 245 |
| subnet-0d4d4d4d4d4d4d4d4 | 10.20.11.0/24 | 12 |

The second subnet has only 12 free addresses. EKS pods, Lambda ENIs or Fargate tasks may fail to start there soon.

Alarm on this number for busy subnets.

Q7. How do you associate a subnet with a custom route table? Fresher
aws ec2 associate-route-table --route-table-id rtb-0f6f6f6f6f6f6f6f6 --subnet-id subnet-0d4d4d4d4d4d4d4d4

Output:

{"AssociationId": "rtbassoc-0a7a7a7a7a7a7a7a7"}

The subnet now uses rtb-0f6f... instead of the main route table.

To move a subnet to another table later, use replace-route-table-association with the association ID. A subnet has exactly one route table at a time.

Q8. How do you find which resource is using a private IP address in your VPC? Fresher

Look up the network interface that owns the address:

aws ec2 describe-network-interfaces --filters Name=addresses.private-ip-address,Values=10.20.11.57 --query "NetworkInterfaces[].[NetworkInterfaceId,InterfaceType,Description,Attachment.InstanceId]" --output text

Output:

eni-0b8b8b8b8b8b8b8b8  interface  ELB app/shop-alb/0123456789abcdef  None

10.20.11.57 belongs to an Application Load Balancer node, not an instance.

This helps when flow logs or firewall logs show an IP and you need to know what it is.

Q9. How do you check if a NAT gateway is healthy from the CLI? Fresher
aws ec2 describe-nat-gateways --filter Name=vpc-id,Values=vpc-0a1b2c3d4e5f67890 --query "NatGateways[].[NatGatewayId,State,SubnetId,NatGatewayAddresses[0].PublicIp]" --output text

Output:

nat-0c9c9c9c9c9c9c9c9  available  subnet-0a1a1a1a1a1a1a1a1  203.0.113.77

The NAT gateway is available, in a public subnet, with public IP 203.0.113.77. External partners may need to allowlist this IP.

If State is failed, check FailureMessage (for example no free Elastic IP or subnet IPs).

Q10. Private DNS for an interface endpoint does not work in a new VPC. Which two VPC settings do you check, and what do they do? Fresher
  • enableDnsSupport: lets instances use the Amazon-provided DNS server (the VPC base address plus two, such as 10.20.0.2).
  • enableDnsHostnames: gives instances with public IPs a public DNS name, and is needed for private DNS on interface VPC endpoints and Route 53 private hosted zones to work as expected.
aws ec2 modify-vpc-attribute --vpc-id vpc-0a1b2c3d4e5f67890 --enable-dns-hostnames "{\"Value\":true}"

Many "endpoint does not resolve to a private IP" problems are fixed by turning both on.

Q11. What is a customer gateway in a Site-to-Site VPN? Fresher

A customer gateway is the AWS resource that describes your side of the VPN: the public IP of your on-premises router or firewall and, for dynamic routing, its BGP ASN.

aws ec2 create-customer-gateway --type ipsec.1 --public-ip 198.51.100.10 --bgp-asn 65010

Output:

"CustomerGatewayId": "cgw-0d0d0d0d0d0d0d0d0"

The AWS side is a virtual private gateway (VGW) or a Transit Gateway. The VPN connection links the two and creates two tunnels.

Q12. How do you check whether VPN tunnels are up? Fresher
aws ec2 describe-vpn-connections --vpn-connection-ids vpn-0e1e1e1e1e1e1e1e1 --query "VpnConnections[].VgwTelemetry[].[OutsideIpAddress,Status,StatusMessage,AcceptedRouteCount]" --output text

Output:

52.0.0.10  UP    2 BGP ROUTES  2
52.0.0.20  DOWN  IPSEC IS DOWN 0

tunnel 1 is up and has learned 2 routes by BGP; tunnel 2 is down. Traffic still flows, but there is no redundancy.

Alarm on the TunnelState CloudWatch metric for each tunnel.

Q13. How do you turn on VPC Flow Logs for a whole VPC to CloudWatch Logs from the CLI? Fresher
aws ec2 create-flow-logs --resource-type VPC --resource-ids vpc-0a1b2c3d4e5f67890 --traffic-type ALL --log-destination-type cloud-watch-logs --log-group-name /vpc/shop-flow --deliver-logs-permission-arn arn:aws:iam::111122223333:role/flowlogs-to-cwl

Output:

{"FlowLogIds": ["fl-0a1b2c3d4e5f67890"], "Unsuccessful": []}

All accepted and rejected traffic for every ENI in the VPC is now logged.

For large VPCs, sending to S3 in Parquet format is cheaper, and you can query it with Athena. Add custom fields (such as pkt-srcaddr and flow-direction) when you need more detail.

Q14. How do you create an S3 gateway endpoint and attach it to private route tables with the CLI? Fresher
aws ec2 create-vpc-endpoint --vpc-id vpc-0a1b2c3d4e5f67890 --vpc-endpoint-type Gateway --service-name com.amazonaws.ap-south-1.s3 --route-table-ids rtb-0f6f6f6f6f6f6f6f6 rtb-0a8a8a8a8a8a8a8a8

Output:

"VpcEndpointId": "vpce-0b9b9b9b9b9b9b9b9"

Those route tables now get a route with the S3 prefix list (pl-...) as destination and the endpoint as target. S3 traffic from those subnets no longer goes through the NAT gateway.

Check with describe-route-tables: you will see a route with DestinationPrefixListId and GatewayId vpce-....

Q15. How do you allocate an Elastic IP and attach it to an instance? Fresher
aws ec2 allocate-address --domain vpc --query AllocationId --output text

Output:

eipalloc-0f2f2f2f2f2f2f2f2
aws ec2 associate-address --allocation-id eipalloc-0f2f2f2f2f2f2f2f2 --instance-id i-0abc1234def567890

The instance now has a fixed public IP that stays after stop and start.

Release addresses you no longer need with release-address; idle public IPv4 addresses are charged.

Q16. How do you list all routes in a route table and spot problems? Fresher
aws ec2 describe-route-tables --route-table-ids rtb-0f6f6f6f6f6f6f6f6 --query "RouteTables[].Routes[].[DestinationCidrBlock,GatewayId,NatGatewayId,TransitGatewayId,State]" --output text

Output:

10.20.0.0/16  local  None  None  active
0.0.0.0/0     None   nat-0c9c9c9c9c9c9c9c9  None  blackhole

The default route points to a NAT gateway that no longer exists, so internet traffic from this subnet is dropped.

Q17. What does a blackhole route mean, and how do you fix it? Fresher

A route is in the blackhole state when its target is gone or unusable, for example a deleted NAT gateway, a detached internet gateway, a deleted peering connection or a stopped instance used as a NAT.

Traffic matching that route is dropped silently.

Fix: replace the route with a working target.

aws ec2 replace-route --route-table-id rtb-0f6f6f6f6f6f6f6f6 --destination-cidr-block 0.0.0.0/0 --nat-gateway-id nat-0a3a3a3a3a3a3a3a3

Then find out why the old target was deleted (CloudTrail) and manage routes in IaC.

3. Mid level questions

These questions check how you use the service in real projects. Interviewers expect the why, the how and one real example.

Q18. How do you add a secondary CIDR block to a VPC that is running out of addresses? Mid level
aws ec2 associate-vpc-cidr-block --vpc-id vpc-0a1b2c3d4e5f67890 --cidr-block 100.64.0.0/16

The VPC now has extra address space. You can create new subnets in it.

Points:

  • The new range must not overlap with existing ranges or connected networks.
  • Existing subnets cannot grow; you add new subnets and move workloads.
  • 100.64.0.0/10 (shared address space) is often used for EKS pod subnets, as non-routable to on-premises.
  • Update security groups, NACLs and on-premises routes if traffic needs to reach the new range.
Q19. What is a managed prefix list, and why use it in security groups and route tables? Mid level

A prefix list is a named set of CIDR blocks, such as all office IP ranges.

aws ec2 create-managed-prefix-list --prefix-list-name office-ranges --max-entries 10 --address-family IPv4 --entries Cidr=198.51.100.0/24,Description=mumbai Cidr=203.0.113.0/24,Description=pune

Then reference pl-0abc... in security group rules or routes.

Benefits:

  • Change the list once, and all rules using it update.
  • Share it across accounts with AWS RAM.
  • AWS also publishes managed prefix lists, such as one for S3 or CloudFront origin-facing IPs.

Note: each entry counts toward security group rule limits.

Q20. A NAT gateway shows ErrorPortAllocation errors. What is happening? Mid level

A NAT gateway can open a limited number of simultaneous connections to the same destination (same IP, port and protocol) from each of its IP addresses (about 55,000). When many instances call one popular endpoint, ports run out and new connections fail.

aws cloudwatch get-metric-statistics --namespace AWS/NATGateway --metric-name ErrorPortAllocation --dimensions Name=NatGatewayId,Value=nat-0c9c9c9c9c9c9c9c9 --start-time 2026-11-20T04:00:00Z --end-time 2026-11-20T05:00:00Z --period 300 --statistics Sum

Output:

"Sum": 1834.0

Fixes: add secondary IP addresses to the NAT gateway, reuse connections (keep-alive and pools), spread traffic, or use VPC endpoints for AWS services.

Q21. When would you create a NAT gateway with private connectivity instead of public connectivity? Mid level

A private NAT gateway translates source IPs for traffic to other private networks (VPCs or on-premises), not to the internet. It has no Elastic IP.

Use cases:

  • Overlapping CIDRs: workloads in a VPC with an overlapping range reach another network through a NAT in a non-overlapping (routable) subnet.
  • Allowlisting: the partner network sees only a few NAT IPs instead of many instance IPs.

Traffic goes from the private NAT gateway through a Transit Gateway or virtual private gateway to the destination.

Q22. How do you see which subnets and ENIs are behind a VPC endpoint, and whether private DNS is on? Mid level
aws ec2 describe-vpc-endpoints --filters Name=service-name,Values=com.amazonaws.ap-south-1.secretsmanager --query "VpcEndpoints[].[VpcEndpointId,VpcEndpointType,PrivateDnsEnabled,SubnetIds,NetworkInterfaceIds]"

Output:

[["vpce-0a4a4a4a4a4a4a4a4", "Interface", true, ["subnet-0d4d...","subnet-0e5e..."], ["eni-0f1f...","eni-0a2a..."]]]

The endpoint has one ENI in each of two subnets, and the normal service name resolves to these private IPs.

If an AZ has no endpoint ENI, traffic from that AZ crosses AZs, which adds data transfer charges and a dependency on another AZ.

Q23. How do you test reachability from a subnet to an on-premises IP before blaming the VPN? Mid level
  • Check the route table of the source subnet: is there a route for the on-premises CIDR to the VGW, Transit Gateway or a propagated route?
  • Check the security group and NACL allow the traffic.
  • Use Reachability Analyzer from the instance ENI to the VGW or Transit Gateway attachment.
  • Check the tunnel status and that BGP advertises the on-premises prefix.
  • From the instance, test with the right tool: nc -vz 192.168.10.5 1433 or traceroute -T -p 443 192.168.10.5.

If AWS-side checks pass, the problem is usually on-premises: firewall rules or a missing return route to the VPC CIDR.

Q24. What is route propagation, and how do you turn it on? Mid level

Route propagation lets a virtual private gateway add routes learned from VPN (BGP or static) or Direct Connect into a route table automatically.

aws ec2 enable-vgw-route-propagation --route-table-id rtb-0f6f6f6f6f6f6f6f6 --gateway-id vgw-0b5b5b5b5b5b5b5b5

on-premises routes appear in this route table with Propagated = true.

If the same prefix exists as a static route, the static route wins. With Transit Gateway, propagation works on TGW route tables instead.

Q25. What is the difference between static and dynamic (BGP) routing for Site-to-Site VPN? Mid level
  • Static: you list on-premises prefixes on the AWS side and AWS prefixes on your device. Simple, but failover between tunnels depends on your device, and changes are manual.
  • Dynamic (BGP): both sides exchange routes automatically. If a tunnel goes down, BGP removes its routes and traffic moves to the other tunnel. New networks are learned automatically.

Use BGP when your device supports it, especially with two tunnels, multiple VPNs, or Direct Connect plus VPN backup.

Q26. How do you check the BGP status of a Direct Connect virtual interface from the CLI? Mid level
aws directconnect describe-virtual-interfaces --virtual-interface-id dxvif-fg1h2i3j --query "virtualInterfaces[].[virtualInterfaceState,bgpPeers[].[bgpStatus,addressFamily]]"

Output:

["available", [["up", "ipv4"], ["down", "ipv6"]]]

The virtual interface is configured and its IPv4 BGP session is up, but the IPv6 session is down, so IPv6 traffic will not use this link.

Also check the ConnectionState and VirtualInterfaceBgpStatus CloudWatch metrics, and alarm when a session goes down.

Q27. What is a Direct Connect LAG? Mid level

A link aggregation group (LAG) bundles several Direct Connect connections of the same speed at the same location into one logical connection, using LACP.

  • More bandwidth: for example four 10 Gbps links act as 40 Gbps.
  • You set a minimum number of active links; below that, the LAG goes down so traffic fails over to another path instead of squeezing into too few links.

A LAG is at one location, so it does not protect against a whole location failing. For high resilience, use connections at two or more locations.

Q28. What is MACsec on Direct Connect? Mid level

MACsec (IEEE 802.1AE) encrypts traffic at layer 2 between your router and the AWS Direct Connect device, on supported dedicated connections (for example 10 Gbps and 100 Gbps at supported locations).

Direct Connect is private, but not encrypted by default. Options for encryption:

  • MACsec for line-rate encryption on the physical link.
  • IPsec VPN over Direct Connect (for example a private IP VPN over a transit VIF) for end-to-end encryption.
  • Application-level TLS, which you should use anyway for sensitive data.
Q29. How do you test Direct Connect failover safely? Mid level

Use the Direct Connect failover test feature (part of the resiliency toolkit): it lets you bring down the BGP sessions of chosen virtual interfaces for a set time, then restores them automatically.

Steps:

  • Plan a maintenance window and tell users.
  • Start the test on the primary VIF and confirm traffic moves to the secondary DX or VPN.
  • Measure the failover time and check applications.
  • The test ends automatically, or you cancel it.

Record the results as evidence for your DR plan.

Q30. What is VPC Traffic Mirroring? Mid level

Traffic Mirroring copies network packets from an ENI and sends them to a target, such as a network appliance or a Network Load Balancer in front of monitoring tools.

Uses:

  • Intrusion detection systems that need full packets.
  • Deep troubleshooting of protocol problems.
  • Security investigations.

You define a mirror session, a filter (which traffic) and a target. It works on Nitro-based instances. Flow logs show only metadata (who talked to whom); mirroring shows the actual packets.

Q31. What does Network Access Analyzer do, and how is it different from Reachability Analyzer? Mid level
  • Reachability Analyzer checks one path: can source A reach destination B on a port? It tells you yes or no, and which component blocks it.
  • Network Access Analyzer checks rules across your whole network: for example "no database subnet may be reachable from an internet gateway" or "only the inspection VPC may reach on-premises". It finds all paths that break your rules.

Use Reachability Analyzer for troubleshooting and Network Access Analyzer for continuous compliance checks.

Q32. How do you find everything that blocks a VPC from being deleted? Mid level

delete-vpc fails while dependencies exist. List them:

aws ec2 describe-network-interfaces --filters Name=vpc-id,Values=vpc-0a1b2c3d4e5f67890 --query "NetworkInterfaces[].[NetworkInterfaceId,InterfaceType,Description]" --output text

Output:

eni-0b8b...  interface  ELB app/test-alb/...
eni-0c9c...  nat_gateway  Interface for NAT Gateway nat-0c9c...

A load balancer and a NAT gateway still use the VPC.

Delete in order: instances, load balancers, NAT gateways, endpoints, ENIs, then detach and delete the internet gateway, subnets, custom route tables, NACLs and security groups, then the VPC.

Q33. What is accelerated Site-to-Site VPN? Mid level

Accelerated VPN sends VPN traffic from your site to the nearest AWS edge location using AWS Global Accelerator, then over the AWS global network to the Region, instead of over the public internet all the way.

Benefits: more consistent latency and fewer drops for distant offices.

Points: it works with a Transit Gateway attachment (not a VGW), must be chosen when you create the VPN, and has extra charges. Check current support details.

Q46. How do you quickly block one attacking IP range for a whole subnet using the CLI? Mid level

Security groups cannot deny traffic, so use the subnet's network ACL with a deny rule numbered lower than the allow rules:

aws ec2 create-network-acl-entry --network-acl-id acl-0c1c1c1c1c1c1c1c1 --ingress --rule-number 50 --protocol -1 --rule-action deny --cidr-block 192.0.2.0/24

All traffic from 192.0.2.0/24 into the subnet is dropped, because NACL rules are checked in number order and the first match wins.

For web traffic, a WAF IP set rule is usually better, because it works at the load balancer or CloudFront before traffic reaches the VPC. NACLs also have a small rule limit.

Q47. How can one account-level VPC setting stop all internet gateway traffic, and when would you use it? Mid level

VPC Block Public Access is an account and Region level setting that blocks traffic through internet gateways (and egress-only internet gateways) for VPCs, even if route tables and security groups would allow it.

  • Bidirectional mode blocks inbound and outbound internet traffic.
  • Ingress-only mode blocks only inbound traffic, so NAT-based outbound access can still work.
  • Exclusions let specific VPCs or subnets keep internet access.

It is a strong guardrail for accounts that must never be public. Check the current documentation for exact modes and supported traffic.

4. Senior level and scenario questions

These questions check design thinking and troubleshooting. Think aloud. Say what you check first, what you change, and how you prevent it next time.

Q34. Design an IP address plan for 60 VPCs across three Regions and on-premises. Senior
  • Start with a large private block that does not overlap with on-premises (for example 10.64.0.0/10), and split it by Region, then by environment (prod, non-prod), then by VPC.
  • Give each VPC a /20 or /19 based on growth, with subnets per AZ and tier.
  • Reserve space for future Regions and for EKS pods (or use secondary non-routable ranges for pods).
  • Use Amazon VPC IPAM to allocate CIDRs from pools automatically and prevent overlaps.
  • Use summarisable ranges so routing to on-premises needs few routes.
  • Document and enforce through account vending.
Q35. Private instances fail to call a payment API randomly at peak, while other traffic works. What do you check? Senior
  • NAT gateway ErrorPortAllocation and ConnectionAttemptCount: port exhaustion to the single payment API IP is likely, because all connections go to the same destination.
  • PacketsDropCount on the NAT gateway.
  • Application connection handling: new connection per request instead of keep-alive.

Fixes:

  • Reuse connections with pools.
  • Add secondary IPs to the NAT gateway (more ports per destination).
  • Spread traffic across NAT gateways in each AZ.
  • Ask the provider whether a PrivateLink service is offered.
Q36. A legacy app needs a fixed public IP that must move to a standby instance within a minute if the primary fails. How do you design it? Senior

Options:

  • Better: put both instances behind a Network Load Balancer with an Elastic IP per AZ. Health checks remove the failed instance automatically, and the public IPs never move.
  • If the app cannot use a load balancer: a health check (Route 53 or CloudWatch alarm) triggers automation (EventBridge plus Lambda or SSM Automation) that calls associate-address with --allow-reassociation to move the Elastic IP to the standby.
aws ec2 associate-address --allocation-id eipalloc-0f2f2f2f2f2f2f2f2 --instance-id i-0standby1234567890 --allow-reassociation

Test failover regularly and measure the time.

Q37. You need on-premises users to reach S3 privately over Direct Connect. What are the options? Senior
  • Interface VPC endpoint for S3 in a VPC reached over a private or transit VIF. On-premises DNS resolves S3 names to the endpoint IPs (through Route 53 Resolver inbound endpoints or endpoint-specific DNS names).
  • Public VIF: reach S3 public IPs over Direct Connect instead of the internet. Traffic is private-path but uses public addresses, and you receive many AWS prefixes.
  • Use bucket policies with aws:SourceVpce (for the interface endpoint) to restrict access.

Interface endpoints are usually simpler to control; public VIFs suit very large volumes.

Q38. How can an IPv6-only workload in a VPC call an API that has only an IPv4 address? Senior

Use DNS64 and NAT64:

  • Turn on DNS64 on the IPv6-only subnet. When a name has only an IPv4 address, the Amazon DNS server returns a synthesised IPv6 address in the 64:ff9b::/96 range.
  • Add a route for 64:ff9b::/96 to a NAT gateway (in a dual-stack public subnet). The NAT gateway performs NAT64, translating IPv6 to IPv4 and back.
  • The NAT gateway then reaches the IPv4 API through the internet gateway as usual.

This lets you run IPv6-only subnets (no IPv4 exhaustion) while still talking to IPv4-only services.

Q39. You are building an EKS cluster that may run 5,000 pods. How do you plan the VPC subnets? Senior
  • With the Amazon VPC CNI, each pod gets a VPC IP, so 5,000 pods need at least 5,000 free addresses, plus nodes, load balancers and room to grow.
  • Use large subnets per AZ (for example /19 each) for pods, or add a secondary CIDR (such as from 100.64.0.0/10) just for pods using custom networking.
  • Turn on prefix delegation so nodes get /28 prefixes and can run more pods per node with fewer API calls.
  • Keep node, pod and load balancer subnets separate if you want different routing or security.
  • Alarm on AvailableIpAddressCount per subnet.
Q40. A partner will accept calls only from one fixed IP address, but your code runs in Lambda. How do you meet this? Senior
  • Attach the Lambda function to private subnets in your VPC.
  • Route those subnets' internet traffic through a NAT gateway that has an Elastic IP (one NAT gateway per AZ means one IP per AZ, so tell the partner all of them, or route all AZs through one NAT if a single IP is strictly required and you accept the AZ risk).
  • Give the partner the Elastic IP addresses to allowlist.
  • Make sure the function still reaches AWS services it needs (through the NAT or VPC endpoints).

Test with a call to an IP echo service from the function to confirm the source IP.

Q41. How do you find which flows are using the most NAT gateway data? Senior
  • Turn on VPC Flow Logs for the NAT gateway's ENI (or the private subnets) with fields such as pkt-srcaddr, pkt-dstaddr and bytes.
  • Query them in CloudWatch Logs Insights or Athena:

Output:

stats sum(bytes) as total by srcAddr, dstAddr | sort total desc | limit 10
10.20.11.34  52.95.110.1  48 GB

One instance sent 48 GB to an AWS service IP (often S3 or ECR) through the NAT.

Fix: add gateway or interface endpoints for AWS services, cache dependencies, and move large transfers off the NAT path.

Q42. On-premises servers must resolve names from a Route 53 private hosted zone. How do you set it up? Senior
  • Create a Route 53 Resolver inbound endpoint in the VPC associated with the private hosted zone. It gets IP addresses in your subnets (use at least two AZs).
  • On the on-premises DNS servers, add a conditional forwarder for the zone (for example internal.shop.example) pointing to the inbound endpoint IPs.
  • Allow DNS (TCP and UDP 53) from on-premises to the endpoint's security group, over VPN or Direct Connect.
  • For the reverse direction (AWS resolving on-premises names), use an outbound endpoint and forwarding rules.

Test with dig api.internal.shop.example @10.20.11.10 from on-premises.

Q43. Your VPC uses one NAT gateway for all AZs. How do you move to one NAT gateway per AZ safely? Senior
  • Create a new NAT gateway in a public subnet of each other AZ.
  • Create (or update) a private route table per AZ, each with 0.0.0.0/0 pointing to its own AZ's NAT gateway.
  • Move subnet associations one AZ at a time, during low traffic. Existing long-lived connections through the old NAT may drop, so warn teams and retry-safe apps will recover.
  • Tell partners who allowlist your NAT IPs about the new Elastic IPs before the change.
  • Watch errors and NAT metrics after each step.

Result: an AZ failure no longer cuts internet access for all AZs, and cross-AZ data charges drop.

Q44. How do you migrate from VPC peering mesh (20 VPCs) to Transit Gateway without downtime? Senior
  • Create the Transit Gateway and attach all VPCs (attachments do not change traffic yet).
  • Set up TGW route tables and propagation.
  • For one pair of VPCs at a time, add routes that point to the TGW using more specific prefixes, or replace the peering routes with TGW routes in a maintenance window.
  • Test connectivity and security group rules (security group references across peering do not work through TGW, so change them to CIDR or prefix list rules).
  • Remove peering connections after traffic moves.
  • Monitor flow logs and errors during each step.
Q45. How do you make sure no team can create an internet gateway in sensitive accounts? Senior
  • Use an SCP that denies ec2:CreateInternetGateway, ec2:AttachInternetGateway and similar actions in those accounts or OUs, with an exception for the network team's role.
  • Turn on VPC Block Public Access (if available in your Regions) to block internet gateway traffic for VPCs, with exclusions where needed.
  • Use AWS Config rules to detect internet gateways and public subnets.
  • Provide approved central egress through Transit Gateway instead.

Combine prevention (SCPs) with detection (Config and Security Hub controls).

Q48. Network throughput between two EC2 instances is much lower than the instance type promises. What do you check? Senior
  • Single-flow limits: one TCP flow between instances is limited (for example around 5 Gbps outside a cluster placement group, higher inside one). Use several parallel streams to test.
  • Instance size: "up to" bandwidth is burst; the baseline is lower and burst credits can run out.
  • ENA driver and enhanced networking must be enabled.
  • Cross-AZ or cross-Region paths add latency, which lowers TCP throughput for one stream.
  • MTU: jumbo frames (9001) inside the VPC help; paths through internet or VPN use 1500 or less.

Test with iperf3 using several streams, and check the EC2 network allowance metrics (bw_in_allowance_exceeded) with ethtool -S.

Q49. How can an internet-facing ALB in one VPC send traffic to servers in a different VPC? Senior
  • Use a target group with target type ip, and register the private IP addresses of the servers in the other VPC.
  • The two VPCs must be connected by VPC peering or Transit Gateway, with routes in both directions.
  • Security groups on the servers must allow traffic from the ALB's subnets or security group (security group references work across peering in the same Region only).
  • Health checks also travel over this path, so routing and rules must allow them.

Use cases: a shared ingress VPC for many application VPCs. For many apps, consider VPC Lattice or PrivateLink patterns too.

Q50. How would you segment a VPC that holds card payment (PCI) systems and normal web systems? Senior
  • Best: put PCI systems in their own VPC and account, connected only through controlled paths (PrivateLink or inspected Transit Gateway routes). This keeps the audit scope small.
  • If they must share a VPC: separate subnets for PCI tiers, strict security groups that reference only approved sources, NACLs as an extra layer, and no direct internet routes.
  • Inspect traffic into the PCI zone with AWS Network Firewall.
  • Use VPC endpoints so PCI systems reach AWS services privately.
  • Log everything: flow logs, firewall logs, CloudTrail.
  • Prove it with Network Access Analyzer scopes that show no unapproved paths.

5. Frequently asked questions

Do I need the CLI for networking interviews?

For cloud and network engineer roles, yes, at least the describe commands. They show exactly what is configured, which is faster than clicking through many console pages.

Is BGP knowledge needed for Direct Connect?

Basic BGP is expected: what an ASN is, how routes are advertised, and how to prefer one path (more specific prefixes, AS path prepending, local preference communities).

What should I build?

A VPC with public and private subnets in two AZs, one NAT gateway per AZ, a gateway endpoint for S3, flow logs, and a test Site-to-Site VPN to a software router in another VPC.

6. Quick revision

  • A subnet without an explicit association uses the main route table.
  • A blackhole route means the target (such as a deleted NAT gateway) no longer exists.
  • ErrorPortAllocation on a NAT gateway means source port exhaustion to one destination.
  • Each Site-to-Site VPN has two tunnels; use both, ideally with BGP.
  • Direct Connect: private VIF to a VGW or DX gateway, transit VIF to Transit Gateway, public VIF to AWS public endpoints.

This page is one part of the complete AWS interview question set. Open the full list here: All 2052 AWS interview questions.