Vpc Peering Private Dns Resolution
In the drawing below a single outbound forwarding zone is set up in vpc h.
Vpc peering private dns resolution. Select the vpc you want to peer with. Go to the vpc peering connections chose your peering select edit dns settings. Enable the dns hostnames.
Open your list of vpc resources. Select the vpc peering connection and choose actions edit dns settings. Today we are announcing dns resolution support for a virtual private cloud vpc peering connection.
To ensure that queries from the peer vpc resolve to private ip addresses in your local vpc choose the option to enable dns resolution for queries from the peer vpc. Once in vpc h it will identify this as part of the outbound forwarding zone and forward the request to on prem. This functionality is also supported cross account so the two vpcs can be in different accounts.
I realised that the dns is being resolved to the public ip of the atlas cluster and the connection request goes through the internet gateway and not through the private peering connection. Go to the vpc find your vpc select edit dns hostnames. I also ran a port scan on the entire vpc cidr of atlas to confirm that i m able to see mongo nodes from my instance in private subnet.
Any queries set to be resolved from on prem will now go from the originating vpc a b or c in this example to vpc h. The hub vpc utilizes dns forwarding to perform the hybrid connection to the on prem network and the spoke vpcs uses dns peering to connect to the hub vpc. Enable dns hostnames and dns resolution to ensure that the cluster s hostnames in standard connection strings automatically resolve to private instead of public ip addresses when the atlas cluster is accessed from within the vpc.
If you wanted to just use an ad or other dns server you could create a dhcp option set and set the dns ips in there. You can now enable resolution of public dns hostnames to private ip addresses when queried from the peered vpc. In the navigation pane choose peering connections.