HashiCorp Cloud Platform
Configure private DNS
You can bring your own DNS server(s) to allow name resolution between your private DNS and a HashiCorp Virtual Network (HVN).
All HCP Vault Dedicated tiers support private DNS.
Limitations
Beta feature
Private DNS forwarding is in beta and available for Amazon Web Services (AWS).
During the beta period, private DNS forwarding works with the following limitation:
- TLS certificates from a private certificate authority (CA) are not supported
Prerequisites
The prerequisites listed are specific to the beta period. Check back at general availability for a list of supported providers and prerequisites.
- Access to the HCP Portal
- AWS HVN created with a unique address space
- AWS VPC exists and configured with its address space DNS support and DNS hostnames enabled for the VPC to allow DNS lookups of records in the network.
- A valid connection between the AWS HVN and the target VPC must exist, using one of the following methods:
- VPC peering connection exists between the target VPC and the HVN, configured with the required routes to enable network traffic between the two networks.
- Transit Gateway Attachment is established between the HVN and the target AWS transit gateway, with valid routes to enable network traffic between the two networks. Note: A valid hvn route specifying the target VPC CIDR must be created in the HVN route table for the Private DNS feature to function properly when using a transit gateway.
- Target VPC's private hosted zone is associated with the VPC connected to the HVN via peering or TGW.
- Security group exists in the target VPC, which allows inbound traffic on port 53 (both UDP and TCP) from the HVN CIDR block to your self-managed DNS server or AWS Route 53 VPC endpoint.
- If using AWS Route 53, ensure an inbound resolver endpoint exists that allows DNS queries from the HVN to be routed to the target VPC endpoint. Select Do53 protocol and choose a Security Group for which you have configured the inbound rules to allow DNS (TCP and UDP) traffic on port 53 from the HVN CIDR block for the resolver endpoint.
- HCP service principal user created with a client ID and secret.
Retrieve HCP API token
Request a HCP API token using the HCP API.
Set environment variables for the HCP organization, HCP project, HVN, and peering ID.
$ export HCP_ORG_ID=<HCP_ORG_ID> \ HCP_PROJ_ID=<HCP_PROJ_ID> \ HCP_NETWORK_ID=<HCP_NETWORK_ID> \ PEERING_ID=<PEERING_ID>
Set environment variables for the HCP service principal user
HCP_CLIENT_ID
andHCP_CLIENT_SECRET
:$ export HCP_CLIENT_ID=<HCP_CLIENT_ID> HCP_CLIENT_SECRET=<HCP_CLIENT_SECRET>
Retrieve a HCP API token using a HCP service principal user HCP_CLIENT_ID, and HCP_CLIENT_SECRET and store it in the
HCP_API_TOKEN
variable.$ HCP_API_TOKEN=$(curl --location "https://auth.idp.hashicorp.com/oauth2/token" \ --header "Content-Type: application/x-www-form-urlencoded" \ --data-urlencode "client_id=$HCP_CLIENT_ID" \ --data-urlencode "client_secret=$HCP_CLIENT_SECRET" \ --data-urlencode "grant_type=client_credentials" \ --data-urlencode "audience=https://api.hashicorp.cloud" | jq -r .access_token)
Create DNS forwarding
Note
During the beta period, configure private DNS using the HCP API.
For a full list of all private DNS forwarding API endpoints, see the HCP API documentation.
Verify you have the required environment variables configured.
$ echo $HCP_API_TOKEN $HCP_ORG_ID $HCP_PROJ_ID $HCP_NETWORK_ID $PEERING_ID
Use the
dnsforwardings
endpoint to create DNS forwarding. Update highlighted items in thedata
block with the values for your environment.Note
The
inbound_endpoint_ips
is the IP address of your self-managed DNS servers, or the AWS Route 53 VPC endpoint IP addresses.Set
connection_type
tohvn-peering
ortgw-attachment
based on the type of connection between the HVN and the VPC.$ curl --location "https://api.cloud.hashicorp.com/network/2020-09-07/organizations/$HCP_ORG_ID/projects/$HCP_PROJ_ID/networks/$HCP_NETWORK_ID/dnsforwardings" \ --request POST \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer $HCP_API_TOKEN" \ --data '{ "dnsForwarding": { "id": "dnsforwarding-byod", "peering_id": "peering-name", "connection_type": "hvn-peering", "rule": { "id": "staging-forwarding-rule", "domain_name": "staging.byod.com", "inbound_endpoint_ips": ["10.0.0.12", "10.0.0.9"] }, "hvn": { "location": { "region": { "region": "us-west-2", "provider": "aws" } } } } }'
Example output:
{ "dns_forwarding": { "id": "dnsforwarding-byod", "hvn": { "type": "hashicorp.network.hvn", "id": "HCP_NETWORK_ID", "uuid": "HCP_NETWORK_ID", "location": { "organization_id": "HCP_ORG_ID", "project_id": "HCP_PROJ_ID", "region": { "provider": "aws", "region": "us-west-2" } }, "description": "" }, "state": "CREATING", "peering_id": "HCP_NETWORK_PEERING_ID", "connection_type": "hvn-peering", "rules": [ { "hvn": { "type": "hashicorp.network.hvn", "id": "hvn-aws-latest-test-1", "uuid": "hvn-aws-latest-test-1", "location": { "organization_id": "c1597488-1053-4cc8-a536-e84cfef0ea7f", "project_id": "b1e20b0d-2411-47e6-adb0-88f39563fbec", "region": { "provider": "aws", "region": "us-west-2" } }, "description": "" }, "dns_forwarding_id": "dnsforwarding-byod", "state": "CREATING", "rule": { "id": "staging-forwarding-rule", "domain_name": "staging.byod.com", "inbound_endpoint_ips": [ "10.0.0.12", "10.0.0.9" ] }, "created_at": "2025-05-14T12:49:52.457815118Z", "updated_at": "2025-05-14T12:49:52.457815118Z" } ], "created_at": "2025-05-14T12:49:52.457815118Z", "updated_at": "2025-05-14T12:49:52.457815118Z" }, "operation": { "id": "OPERATION_ID", "state": "PENDING", "location": { "organization_id": "HCP_ORG_ID", "project_id": "HCP_PROJ_ID", "region": { "provider": "aws", "region": "us-west-2" } }, "link": { "type": "hashicorp.network.dnsforwarding", "id": "dnsforwarding-byod", "uuid": "dnsforwarding-byod", "location": { "organization_id": "HCP_ORG_ID", "project_id": "HCP_PROJ_ID", "region": { "provider": "aws", "region": "us-west-2" } }, "description": "DNS Forwarding (\"dnsforwarding-byod\")" }, "created_at": "2025-05-14T12:49:52.464766Z", "updated_at": "2025-05-14T12:49:52.464766Z" } }
You have completed the private DNS forwarding configuration.