Skip to content

Can private DNS of an EC2 instance in a peer VPC from the same Region be resolved, and does this need to be explicitly enabled?

0

From the VPC Peering docs, it is not clear (to me anyway) whether private DNS hostnames in a peer VPC from the same Region can be resolved to private IP addresses (ie when sending traffic from a first VPC to a peer VPC).

The docs here on Enabling DNS resolution begin with "To enable a VPC to resolve public IPv4 DNS hostnames..." (emphasis mine) ie seem to suggest that only public DNS hostnames are affected (not private). Does this mean that it's not possible to resolve private DNS hostnames in a peer VPC, or perhaps that private DNS resolution always enabled by default?

Elsewhere, the docs here say- "If the IPv4 CIDR block of a VPC in a VPC peering connection falls outside of the private IPv4 address ranges specified by RFC 1918, private DNS hostnames for that VPC cannot be resolved to private IP addresses. To resolve private DNS hostnames to private IP addresses, you can enable DNS resolution support for the VPC peering connection." Does the second sentence here mean that enabling DNS resolution support is required to resolve private hostnames in a peer VPC only for this case of a non-RFC 1918 IP? Or is the second sentence not supposed to be interpreted in the context of the first sentence?

Thanks in advance for the help!!

Note that if the peer VPC is in a different region then the docs clearly state: You must enable DNS resolution support for the VPC peering connection to resolve private DNS hostnames of the peered VPC to private IP addresses, even if the IPv4 CIDR for the VPC falls into the private IPv4 address ranges specified by RFC 1918.

asked 2 years ago479 views

2 Answers
3

Yes, private DNS hostnames of EC2 instances in a peer VPC can be resolved to private IP addresses, but this functionality needs to be explicitly enabled for the VPC peering connection.

By default, DNS resolution between peered VPCs is not enabled. To allow instances in one VPC to resolve private DNS hostnames to private IP addresses for instances in the peered VPC, you must enable DNS resolution support for the VPC peering connection.

This applies to all cases, not just for VPCs with CIDR blocks outside the RFC 1918 ranges. The mention of RFC 1918 in the documentation is addressing a specific edge case, but the general requirement to enable DNS resolution support applies to all VPC peering connections where you want to resolve private DNS hostnames across the peered VPCs.

To enable this feature, both VPCs in the peering connection must have DNS hostnames and DNS resolution enabled. Then, you need to modify the VPC peering connection settings to enable DNS resolution for queries from the peer VPC. This can be done through the Amazon VPC console, AWS CLI, or AWS Tools for Windows PowerShell.

It's important to note that this setting needs to be enabled for both sides of the peering connection if you want bi-directional private DNS resolution. If the peered VPCs are in different AWS accounts or regions, the process needs to be completed by the respective VPC owners.

Once enabled, instances in one VPC can resolve the private DNS hostnames of instances in the peered VPC to their private IP addresses, facilitating easier communication between resources across the peered VPCs using friendly DNS names instead of IP addresses.
Sources
Enable DNS resolution for a VPC peering connection - Amazon Virtual Private Cloud
How VPC peering connections work - Amazon Virtual Private Cloud
DNS - Building a Scalable and Secure Multi-VPC AWS Network Infrastructure

answered 2 years ago

EXPERT

reviewed 2 years ago

1
Accepted Answer

Yes, you can resolve private DNS hostnames of EC2 instances in a peer VPC, but you need to enable it explicitly for the VPC peering connection.

By default, DNS resolution does not work across peered VPCs. If you want instances in one VPC to resolve private hostnames of instances in another VPC within the same region, you must enable DNS resolution support for the VPC peering connection.

Here's what you need to do:

1.Ensure that both VPCs have DNS resolution and DNS hostnames enabled.

2.Modify the VPC peering connection settings to enable DNS resolution for the peer VPC. You can do this via the AWS console, AWS CLI, or AWS PowerShell.

Once enabled, instances in one VPC can resolve private hostnames in the peer VPC, making communication easier without needing to use IP addresses.

Also, if you want DNS resolution to work in both directions (VPC A to VPC B and vice versa), you need to enable it on both sides of the peering connection.

For VPC peering across different regions, AWS requires you to enable DNS resolution explicitly—otherwise, private DNS hostnames won’t be resolved.

EXPERT

answered 2 years ago

AWS
EXPERT

reviewed 2 years ago

  • Thanks for the reply

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.