Custom nameservers
With custom (or vanity) nameservers, a domain can use Cloudflare DNS without using the hostnames of Cloudflare-assigned nameservers. For instance, you can configure ns1.example.com
and ns2.example.com
as nameservers for example.com
.
Availability
Cloudflare domains on Business or Enterprise plans can set Custom Nameservers at Cloudflare:
- Enterprise plans:
- Business plans:
- Create account-level nameservers via the API (after contacting Cloudflare Support)
- Create zone-level nameservers via the dashboard or API
Restrictions
For both account-level and zone-level custom nameservers, you have to configure at least two custom nameservers and no more than five.
Account-level nameservers
Once you configure account-level custom nameservers, these nameservers can be applied and used by any zones in that account, excluding:
- Reverse zones
- Subdomain zones
- Zones in partial setup - because these zones are not using Cloudflare’s Authoritative DNS.
Cloudflare Registrar
If you are using Cloudflare Registrar for the zone that provides the hostnames for the account-level custom nameservers, you have a simpler setup process.
Add account nameservers
- Create between two and five account-level nameservers with a POST command.
- Open a ticket with customer support to add glue records to your account nameservers and have your nameservers updated.
- To enable the custom nameservers on existing zones, use a PUT command on each zone. Cloudflare will assign an IPv4 and IPv6 address to each custom nameserver hostname and automatically create the associated
A
orAAAA
records.
To make this custom nameserver the default for all new zones, use a PUT command on an account and set the value of use_account_custom_ns_by_default
to true
.
Remove account nameservers
To remove account-level nameservers and their associated DNS records from a zone, use a PUT command.
Non-Cloudflare Registrar
If you are not using Cloudflare Registrar for the zone that provides the hostnames for the account-level custom nameservers, you have to set the glue records yourself.
Add account nameservers
Create between two and five account-level nameservers with a POST command.
If you are not using Cloudflare Registrar for your domain, add the Custom Nameservers and IP addresses to your domain’s registrar as glue (A and AAAA) records. If you do not add these records, DNS lookups for your domain will fail.
To enable the custom nameservers on existing zones:
Use a PUT command on each zone. Cloudflare will assign an IPv4 and IPv6 address to each custom nameserver hostname and automatically create the associated
A
orAAAA
records.Update the name servers at the registrar to use the custom nameserver names.
To make this custom nameserver the default for all new zones added to your account from now on, use a PUT command on an account and set the value of use_account_custom_ns_by_default
to true
.
Remove account nameservers
To remove account-level nameservers and their associated DNS records from a zone, modify the zone’s registrar to use your regular Cloudflare nameservers and then send a PUT command to the Cloudflare API.
Zone-level nameservers
When you choose the names for your zone-level nameservers, each hostname must be a subdomain of the zone this is configured for.
Create zone-level nameservers
Using the dashboard
To add custom nameservers to a specific zone:
- Log in to the Cloudflare dashboard and select your account and domain.
- Go to DNS > Records.
- On Custom Nameservers, click Add Custom Nameservers and enter the subdomains used for the nameserver hostnames (like ns1, ns2, ns3).
- Cloudflare will assign an IPv4 and IPv6 address to each custom nameserver hostname and automatically create the associated
A
orAAAA
records (visible after you refresh the page). - The next step depends on whether you are using Cloudflare Registrar for your domain:
- If you are using Cloudflare Registrar for your domain, no further action is required. Glue records will be added automatically on your behalf.
- If you are not using Cloudflare Registrar for your domain, add the Custom Nameservers at your registrar as your authoritative nameservers and as glue (A and AAAA) records. If you do not add these records, DNS lookups for your domain will fail.
Using the API
To add zone-level custom nameservers via the API, use a PATCH request and specify the custom nameservers in the payload:
"vanity_name_servers": ["ns1.example.com","ns2.example.com"]
Remove zone-level nameservers
Using the dashboard
To remove zone-level nameservers (and their associated, read-only DNS records) using the dashboard:
- Log in to the Cloudflare dashboard and select your account and domain.
- Go to DNS > Records.
- On Custom Nameservers, click Remove Custom Nameservers.
- Cloudflare will remove your nameservers and their associated read-only
A
orAAAA
records.
Using the API
To remove zone-level custom nameservers (and their associated, read-only DNS records) via the API, use a PATCH request and include an empty array in the payload:
"vanity_name_servers": []