r/CloudFlare: Resolve hundreds of domains (wildcard) to the same IP, using ns1.nameserver.com and ns2.nameserver.com

r/CloudFlare: Resolve hundreds of domains (wildcard) to the same IP, using ns1.nameserver.com and ns2.nameserver.com
💡
This article archives a conversation, which took place in a subreddit post (original source linked below) and to which I contributed a solution or answer (with the u/MasterofSynapse handle), in a Q&A format.

Original Reddit post: https://www.reddit.com/r/CloudFlare/comments/wvq2ll/resolve_hundreds_of_domains_wildcard_to_the_same/

Question

We have a few hundred domain names. They all use the same nameserver "ns1.nameserver.com" and "ns2.nameserver.com".

I want to resolve all domains using this nameserver, to a specific IP address. Is this possible in Cloudflare without adding all the domains to the Cloudflare account? (I want to avoid manual labor)

Example:

- domain1.com uses ns1.nameserver.com and ns2.nameserver.com

end result:

- ping domain1.com -> 1.2.3.4

- ping anything.domain1.com -> 1.2.3.4


I can set up a DNS server to handle it but I would prefer to have it serverless with clever DNS-records or Cloudflare workers for example.

Answer

To my knowledge, the x.ns.cloudflare.com servers only accept authoritative zones for domains that are actively registered in an account with Cloudflare since they would want to make sure they have someone to contact if a zone is abused or hosts illegal stuff.

You can however batch add domains via this: https://support.cloudflare.com/hc/en-us/articles/360000841472-Adding-Multiple-Sites-to-Cloudflare-via-Automation

That way you have Cloudflare manage all your zones but can still achieve what you want.

If you actually need ns1/ns2.nameserver.com, you need the paid Business plan to receive custom nameservers. And the only zone that needs that plan would be the one holding the ns1/ns2 NS records.

Comment 1 on Answer

Very useful information, thank you so much for your valued time. It's a bit sad that the pricing is so steep for small business owners, compared to hosting a $10 dns server and paying some devops a couple of hundreds to get it up and running. I'd love to experiment with the paid tiers. Cheers buddy!

My response to comment 1

Depending on the viewpoint, the pricing could seem steep.

However your theoretical calculation doesn't include the manpower to keep the DNSs online and secure. And you also have to factor in the upscaling cost if query numbers grow. Thats what breaks most of the SMBs backs so they go towards serverless and SaaS solutions. And thats fine, thats what they are for.