DEV Community

Cover image for How DNS Works Inside an AWS VPC
Irfan Satrio
Irfan Satrio

Posted on

How DNS Works Inside an AWS VPC

In AWS networking, resources resolve endpoints, services communicate, and applications run as expected. Within a VPC, DNS plays an important role in how services discover each other and how traffic is route. Looking at how DNS actually works inside AWS helps explain why traffic flows the way it does and why certain connections succeed or fail.

This article walks through DNS inside an AWS VPC from a networking perspective, focusing on resolution flow rather than application logic.

DNS as a Core VPC Service

Every VPC comes with a built-in DNS resolver provided by AWS. This resolver is available at a reserved IP address within the VPC and is automatically used by resources unless configured otherwise.

When an EC2 instance makes a DNS query, the request does not go directly to the internet. Instead, it is handled internally by the VPC DNS resolver, which decides how and where the name should be resolved.

This design allows AWS to integrate DNS tightly with networking, compute, and managed services.

The Role of VPC DNS Settings

DNS behavior in a VPC is controlled by two main settings: DNS resolution and DNS hostnames.

DNS resolution determines whether resources in the VPC can resolve domain names at all. When enabled, instances can query the VPC resolver for both internal and external domains. DNS hostnames determine whether AWS assigns DNS names to resources such as EC2 instances and load balancers.

In most cases, both settings are enabled by default. Disabling them is uncommon and usually reserved for specialized networking setups.

Resolving Public Domain Names from a VPC

When an instance inside a VPC resolves a public domain name, the request is first sent to the VPC DNS resolver. The resolver then queries public DNS infrastructure on behalf of the instance and returns the result.

From the instance’s perspective, DNS resolution works as expected, even if the subnet is private. The key point is that DNS resolution itself does not require internet access. Only the subsequent network traffic does.

This is why private instances can resolve external domain names even when outbound connectivity is restricted or routed through a NAT Gateway.

Internal DNS Names and AWS Resources

AWS automatically creates DNS records for many resources inside a VPC. EC2 instances, load balancers, and certain managed services are assigned internal DNS names that resolve to private IP addresses.

When one resource communicates with another using these names, the resolution happens entirely within the VPC. Traffic stays internal and does not involve the internet.

This internal DNS behavior is what enables service-to-service communication without hardcoding IP addresses, which would otherwise change over time.

Private DNS and Service Integration

DNS inside a VPC becomes more powerful when private DNS is involved. With private hosted zones, domain names can be resolved only within one or more VPCs.

This allows teams to use familiar domain naming patterns for internal services while keeping them inaccessible from outside. Applications can rely on stable names even as infrastructure scales or changes.

Private DNS is commonly used for internal APIs, microservices, and shared services across multiple environments.

How DNS Works with Managed AWS Services

Many AWS services rely heavily on DNS to function correctly. Endpoints for storage, databases, and messaging services are exposed as DNS names rather than fixed IPs.

When accessed from within a VPC, these names often resolve to internal addresses, especially when VPC endpoints are used. This keeps traffic inside the AWS network and avoids unnecessary exposure to the internet.

From a networking standpoint, DNS acts as the glue that connects routing, endpoints, and service access together.

DNS Resolution and Network Design

DNS decisions influence how traffic flows, even though they do not move packets themselves. A resolved IP address determines whether traffic stays within the VPC, goes through a NAT Gateway, or exits via an Internet Gateway.

Because of this, DNS should be considered part of network design rather than an afterthought. Clear domain naming, consistent use of private DNS, and an understanding of resolution paths make architectures easier to reason about and troubleshoot.

Common Sources of DNS Confusion

DNS issues inside a VPC often come from assumptions rather than misconfigurations. Expecting private instances to resolve names without DNS resolution enabled, confusing public and private DNS records, or assuming DNS queries require internet access are common examples.

When troubleshooting, checking VPC DNS settings and understanding which resolver is being used often leads to quicker answers than inspecting security rules or routes.

Conclusion

DNS inside a VPC is simple by design, but deeply integrated with AWS networking. The VPC DNS resolver handles both internal and external name resolution in a controlled and predictable way. Once you understand where DNS queries go and how results are returned, it becomes much easier to reason about connectivity, service access, and network behavior across AWS environments.

Top comments (0)