| [ Web Proxy ] |
| Viewing: https://developers.cloudflare.com/dns/internal-dns/get-started/ | [Back] [Original] |
Follow this guide to get started with Internal DNS.
Make sure you have an Enterprise account with access to Gateway resolver policies and Internal DNS.
Consider the different ways in which you can connect to Gateway resolver.
Caution
If using WARP, make sure your internal DNS zones or their TLDs are not listed in your Local Domain Fallback configuration. Otherwise, DNS queries for a matching domain will be sent to the local DNS server specified in the fallback, instead of being sent to Cloudflare.
If you will be using an API token for authentication, make sure you have the following permissions:
API token configuration
Permissions
Account Resources
Zone Resources
Include - Specific zones
When creating a token for Internal DNS, we recommend scoping it to specific internal zones rather than using "All zones". This follows the principle of least privilege. If you create new internal zones later, you will need to update the token scope to include them. Support for automatic zone-type scoping (for example, "all internal zones") is planned for a future release.
About authentication
Internal DNS uses the same authentication model as the rest of Cloudflare DNS. There is no separate role or special permission group for internal zones. You use standard DNS permissions scoped to the specific zones you want to manage.
One important distinction: a zone-scoped token cannot create a zone because the zone does not exist yet to be scoped to. To create an internal zone via API, you need a token with Zone > Zone > Edit scoped to All zones or at the account level. After the zone exists, switch to a zone-scoped token for managing records and settings.
In the Cloudflare dashboard, go to the Internal DNS page.
Go to Internal DNS ↗Select Create an internal zone.
Give your internal zone a name.
Internal zone configuration conditions
xyz.local), if it is created on the TLD itself (local), or even if on the root (.).1 Logical groupings of internal DNS zones that are referenced by Gateway resolver policies to define how a specific query should be resolved.
Note
Creating multiple internal DNS records in batch is currently only supported via API.
type to internal.Internal zone configuration conditions
xyz.local), if it is created on the TLD itself (local), or even if on the root (.).1 Logical groupings of internal DNS zones that are referenced by Gateway resolver policies to define how a specific query should be resolved.
Example
Required API token permissions
At least one of the following token permissions is required:Zone Zone EditZone DNS Editcurl "https://api.cloudflare.com/client/v4/zones" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"account": {
"id": "<ACCOUNT_ID>"
},
"name": "<ZONE_NAME>",
"type": "internal"
}'
/batch, to manage DNS records. Refer to Batch record changes for details.During an internal DNS query resolution, if no internal record is found within a matching internal zone, Cloudflare will check if the matching internal zone is referencing another internal zone. Successive references can be followed with a maximum of five references in a chain.
For details, refer to reference zones.
In the Cloudflare dashboard, go to the Internal DNS page.
Go to Internal DNS ↗Select a zone.
Within the selected zone, go to Reference zone.
Select Add reference zone.
Find the zone you want to use as reference and choose Select in the respective row.
--json, specify the internal_dns object with the parameter reference_zone_id.In the following example, internal zone A (ID 8a904aeb565c42cfa207d98f6edea2f3) is referencing internal zone B (ID 8e64c6fb4b514f3faf64de81efc11e51).
Required API token permissions
At least one of the following token permissions is required:Zone DNS Settings WriteDNS Writecurl "https://api.cloudflare.com/client/v4/zones/8a904aeb565c42cfa207d98f6edea2f3/dns_settings" \
--request PATCH \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"internal_dns": {
"reference_zone_id": "8e64c6fb4b514f3faf64de81efc11e51"
}
}'Since the resolver policy will require a DNS view, you must have at least one view to be able to route requests to internal zones.
In the Cloudflare dashboard, go to the Internal DNS page.
Go to Internal DNS ↗Go to Internal DNS Views.
Select Create a view.
Give your view a descriptive name.
DNS view configuration conditions
1 DNS zones that contain public DNS records and are accessible by public resolvers.
DNS view configuration conditions
1 DNS zones that contain public DNS records and are accessible by public resolvers.
Note
The Gateway configuration must exist within the same Cloudflare account where the internal zone exists.
Besides selecting an internal DNS view when setting up your resolver policies, you can also enable the fallback through public DNS option.
Use the API endpoints under Zero Trust > Gateway > Rules to set up resolver policies. For guidance about selectors, operators, and values, refer to Gateway.
Use the rule settings object to define resolve_dns_internally, specifying view_id and fallback option. The fallback options behave as follows:
none: Gateway DNS resolver returns the response as-is to the client.public_dns: In case the response from the internal zone is REFUSED, NXDOMAIN, or a response with a CNAME type, Gateway DNS resolver sends the query to Cloudflare 1.1.1.1 public resolver and tries to resolve the query via public DNS.Once you add the Gateway resolver policy, it will be listed in the respective internal view under Resolver policies referencing this view.
You can also manage Internal DNS resources with the Cloudflare Terraform provider . The patterns are identical to public DNS zones the only difference is setting type = "internal" on the cloudflare_zone resource.
Use a zone-scoped API token for day-to-day management and an account-level token for creating new zones. If your token is scoped to specific zones, remember to update it when you add new internal zones. For a complete working example, refer to the Terraform provider documentation .
| Web Proxy Viewer | New URL | Original Page |