Disclosure: I built the Apify Actor mentioned near the end of this post.
To find a domain's DNS provider, look up its NS (nameserver) records and read the host names: *.ns.cloudflare.com is Cloudflare, ns-*.awsdns-* is Amazon Route 53, *.azure-dns.* is Azure DNS, *.nsone.net is NS1, and so on. For a list of domains you can do this with Python's standard library and a free DNS-over-HTTPS endpoint. The two things that trip up a bulk script are names like www. or en. that have no NS records of their own, and CNAMEs that quietly hand you somebody else's nameservers.
This post builds a small script that turns a list of domains (or URLs) into a CSV of zone, nameservers and provider, shows a real run on 11 inputs, and ends with a hosted option.
Nameservers, DNS provider, registrar: which one are you looking for?
Three different companies can be involved with one domain:
| Role | What it does | Where you see it |
|---|---|---|
| Registrar | Sold you the domain name | WHOIS / RDAP |
| DNS provider | Answers DNS queries for the domain | NS records |
| Web host / CDN | Serves the website | A / AAAA / CNAME records |
"Find the DNS provider of a domain" means the middle row. A domain registered at one company can use a completely different DNS provider, so the NS records are the thing to check, not the registrar.
How do I get the nameservers of a domain?
On the command line, dig +short NS github.com or nslookup -type=NS github.com. From Python without installing anything, Cloudflare's DNS over HTTPS JSON API is a plain GET with name, type and the header Accept: application/dns-json, no key needed. (I covered the basics of this endpoint in a separate post in this series on bulk SPF and DMARC checks.)
The catch shows up as soon as your list contains host names instead of registered domains. Here is what came back for www.python.org on 2026-12-01:
curl -s -H 'accept: application/dns-json' \ 'https://cloudflare-dns.com/dns-query?name=www.python.org&type=NS' {"Status":0,"TC":false,"RD":true,"RA":true,"AD":false,"CD":false, "Question":[{"name":"www.python.org","type":2}], "Answer":[{"name":"www.python.org","type":5,"TTL":604649,"data":"dualstack.python.map.fastly.net."}], "Authority":[{"name":"fastly.net","type":6,"TTL":14,"data":"ns1.fastly.net. hostmaster.fastly.com. 2017052201 3600 600 604800 30"}]} No NS records, a CNAME (type 5) to Fastly, and an SOA (type 6) for fastly.net. A common shortcut is "if there is no NS answer, take the zone name from the SOA in Authority". Here that gives fastly.net, and your report would say python.org's DNS is hosted by Fastly. It is not: python.org itself is on Route 53. The SOA belongs to the zone of the CNAME target.
www.github.com shows the other half: it is a CNAME to github.com, so the Answer does contain NS records, but they are owned by github.com. Right here by luck; wrong for any CNAME to a SaaS host.
How do I find the zone apex for a subdomain?
Walk up one label at a time and stop at the first name that has NS records owned by that exact name:
-
www.python.org→ only a CNAME, no NS owned by it → go up -
python.org→ NS records owned bypython.org→ this is the zone
Checking the owner name is what makes this safe for CNAMEs. Stop before the top-level domain, and if the first answer is NXDOMAIN (status 3), the name does not exist: report that and move on.
A delegated subdomain that is a zone of its own (say eu.example.com at another provider) is found too, because it has NS records owned by that name.
How do I map nameservers to a DNS provider?
Match the NS host names against patterns. The first six rows below matched real domains in my run; the last four are common patterns that my test list did not hit, so check one known customer before relying on them:
| NS host name looks like | Provider |
|---|---|
*.ns.cloudflare.com | Cloudflare |
*.foundationdns.com / .net / .org | Cloudflare Foundation DNS (Enterprise) |
ns-123.awsdns-45.com (any TLD) | Amazon Route 53 |
*.nsone.net | NS1 |
*.azure-dns.com / .net / .org / .info | Azure DNS |
NS under the domain itself (ns3.cloudflare.com for cloudflare.com) | own nameservers |
ns-cloud-*.googledomains.com | Google Cloud DNS (not in my run) |
*.domaincontrol.com | GoDaddy (not in my run) |
*.registrar-servers.com | Namecheap (not in my run) |
*.akam.net | Akamai (not in my run) |
- Several providers at once is normal for large sites: github.com and airbnb.com list both NS1 and Route 53. Report all of them.
- Custom or "vanity" nameservers hide the provider. Cloudflare, for example, offers account custom nameservers, so
ns1.yourcompany.comcan be served by a hosted provider. The host name alone cannot tell you that, so the script says "own nameservers". - Unknown is a valid answer. Do not guess from a partial match.
The script: DNS provider for a list of domains
Standard library only (tested with Python 3.9.6). Put one domain or URL per line in domains.txt:
import csv import json import re import sys import time import urllib.parse import urllib.request DOH = "https://cloudflare-dns.com/dns-query" PAUSE = 1.0 # seconds to wait after each request # NS host name pattern -> DNS provider. Extend this list for your own data. PROVIDERS = [ (r"\.ns\.cloudflare\.com$", "Cloudflare"), (r"\.foundationdns\.(com|net|org)$", "Cloudflare (Foundation DNS)"), (r"\.awsdns-\d+\.", "Amazon Route 53"), (r"\.nsone\.net$", "NS1"), (r"\.azure-dns\.", "Azure DNS"), (r"\.googledomains\.com$", "Google Cloud DNS"), (r"\.domaincontrol\.com$", "GoDaddy"), (r"\.registrar-servers\.com$", "Namecheap"), (r"\.akam\.net$", "Akamai"), ] def doh(name, rtype="NS"): url = DOH + "?" + urllib.parse.urlencode({"name": name, "type": rtype}) req = urllib.request.Request(url, headers={"accept": "application/dns-json"}) for attempt in range(3): try: with urllib.request.urlopen(req, timeout=10) as resp: data = json.load(resp) time.sleep(PAUSE) return data except Exception: if attempt == 2: raise time.sleep(2 ** attempt) def to_hostname(entry): """'https://www.Python.org/about/' -> 'www.python.org'""" entry = entry.strip() if "://" not in entry: entry = "//" + entry return urllib.parse.urlsplit(entry).hostname.rstrip(".") def find_zone(name): """Walk up from name until NS records are owned by that exact name.""" labels = name.split(".") for i in range(len(labels) - 1): candidate = ".".join(labels[i:]) data = doh(candidate) if data["Status"] == 3: return candidate, "NXDOMAIN", [] if data["Status"] != 0: return candidate, "RCODE %d" % data["Status"], [] ns = sorted( a["data"].rstrip(".").lower() for a in data.get("Answer", []) # type 2 = NS. A CNAME'd name returns the TARGET's NS records, # so only accept records whose owner is the name we asked about. if a["type"] == 2 and a["name"].rstrip(".").lower() == candidate ) if ns: return candidate, "NOERROR", ns return name, "NO NS FOUND", [] def providers(zone, hosts): found = set() for host in hosts: if host == zone or host.endswith("." + zone): found.add("own nameservers") continue for pattern, provider in PROVIDERS: if re.search(pattern, host): found.add(provider) break else: found.add("unknown") return "; ".join(sorted(found)) if __name__ == "__main__": writer = csv.writer(sys.stdout) writer.writerow(["input", "zone", "status", "dns_provider", "nameservers"]) for line in open(sys.argv[1]): if not line.strip(): continue zone, status, ns = find_zone(to_hostname(line)) writer.writerow([line.strip(), zone, status, providers(zone, ns), " ".join(ns)]) Input:
github.com https://www.python.org/about/ en.wikipedia.org www.shopify.com stripe.com airbnb.com microsoft.com example.com cloudflare.com bbc.co.uk nonexistent-domain-zz9q.com python3 dns_provider.py domains.txt > providers.csv Output from my run on 2026-12-01 (11 inputs, 15 requests, about 15 seconds; a second run a minute later gave the same file byte for byte):
input,zone,status,dns_provider,nameservers github.com,github.com,NOERROR,Amazon Route 53; NS1,dns1.p08.nsone.net dns2.p08.nsone.net dns3.p08.nsone.net dns4.p08.nsone.net ns-1283.awsdns-32.org ns-1707.awsdns-21.co.uk ns-421.awsdns-52.com ns-520.awsdns-01.net https://www.python.org/about/,python.org,NOERROR,Amazon Route 53,ns-1134.awsdns-13.org ns-2046.awsdns-63.co.uk ns-484.awsdns-60.com ns-981.awsdns-58.net en.wikipedia.org,wikipedia.org,NOERROR,unknown,ns0.wikimedia.org ns1.wikimedia.org ns2.wikimedia.org www.shopify.com,shopify.com,NOERROR,Cloudflare (Foundation DNS),gold.foundationdns.com gold.foundationdns.net gold.foundationdns.org stripe.com,stripe.com,NOERROR,Amazon Route 53,ns-1087.awsdns-07.org ns-1882.awsdns-43.co.uk ns-423.awsdns-52.com ns-705.awsdns-24.net airbnb.com,airbnb.com,NOERROR,Amazon Route 53; NS1,dns1.p08.nsone.net dns2.p08.nsone.net dns3.p08.nsone.net dns4.p08.nsone.net ns-1453.awsdns-53.org ns-1932.awsdns-49.co.uk ns-474.awsdns-59.com ns-558.awsdns-05.net microsoft.com,microsoft.com,NOERROR,Azure DNS,ns1-39.azure-dns.com ns2-39.azure-dns.net ns3-39.azure-dns.org ns4-39.azure-dns.info example.com,example.com,NOERROR,Cloudflare,elliott.ns.cloudflare.com hera.ns.cloudflare.com cloudflare.com,cloudflare.com,NOERROR,own nameservers,ns3.cloudflare.com ns4.cloudflare.com ns5.cloudflare.com ns6.cloudflare.com ns7.cloudflare.com bbc.co.uk,bbc.co.uk,NOERROR,own nameservers; unknown,ddns0.bbc.co.uk ddns0.bbc.com ddns1.bbc.co.uk ddns1.bbc.com dns0.bbc.co.uk dns0.bbc.com dns1.bbc.co.uk dns1.bbc.com nonexistent-domain-zz9q.com,nonexistent-domain-zz9q.com,NXDOMAIN,, How to read the less obvious rows:
-
https://www.python.org/about/went through the walk-up:www.python.org(CNAME) →python.org(Route 53), not Fastly. -
en.wikipedia.orgis "unknown" because its nameservers sit under a sister domain,wikimedia.org. That is self-hosted in practice, but the script only knows "same domain", so it does not guess. -
bbc.co.ukhas nameservers under bothbbc.co.ukandbbc.com; only the first set matches "own nameservers". -
cloudflare.comusesns3–ns7.cloudflare.com, not the*.ns.cloudflare.comnames Cloudflare gives customer zones, which is why the "own nameservers" check runs before the pattern list.
With one domain at a time and a one-second pause, 1,000 domains take roughly 20 to 30 minutes. Cloudflare does not publish a rate limit for this endpoint; I did not hit a 429 or SERVFAIL, so the retry branch is untested.
Do the registry and the nameservers agree?
What a recursive resolver returns is usually the NS set published by the domain's own nameservers. The registry (the parent zone, for example the .com servers) has its own copy: the delegation. After a migration, the two can disagree for a while, and that is a classic cause of "some people still see the old site". It is also the method behind the Stack Overflow question on testing a new nameserver before updating the registrar: you can query the new provider's servers directly before the delegation changes.
Compare them with dig by asking a parent server without recursion:
dig +norec +noall +authority @a.gtld-servers.net github.com NS # what .com delegates to dig +norec +noall +answer @ns-421.awsdns-52.com github.com NS # what the zone itself says On 2026-12-01 both returned the same eight hosts (TTL 172800 from the registry, 900 from the zone). I checked the other domains in my list the same way and every one matched, so I have no real mismatch to show you. Two practical points from doing it:
- Ask a server for the right TLD. Asking a
.comserver aboutpython.orgreturns a referral to the root servers, not an answer. Get the parent's servers withdig +short NS orgfirst. - In Python you need a library that can send a non-recursive query to a chosen server, such as
dnspython; the DNS-over-HTTPS endpoint always recurses.
Nameservers on Cloudflare vs a website that "uses Cloudflare"
People often search "how to tell if a website uses Cloudflare" and get a nameserver answer. They are two different questions:
- Cloudflare is the DNS provider when the NS records point to Cloudflare (example.com above). Records in that zone can still be set to DNS only, in which case web traffic does not pass through Cloudflare.
- Cloudflare proxies the website when traffic goes through Cloudflare's network. That can happen with nameservers elsewhere: Cloudflare's CNAME setup (partial) lets a site use "Cloudflare's reverse proxy while maintaining your primary and authoritative DNS provider".
For the second question, check the website, not the NS: curl -sI https://www.shopify.com | grep -i '^server' returned server: cloudflare on 2026-12-01, and Cloudflare publishes its IP ranges if you would rather compare the site's addresses.
What if I want this without running a script?
I built an Apify Actor, DNS Lookup in Bulk – MX, SPF, DMARC & DNS Records, that looks up DNS records for a list of domains. For nameservers there is a ready-made example, Find the nameservers of a list of domains (bulk NS lookup), which runs 7 domains with only the NS type selected.
What to expect, from its README:
- One row per domain and record type, with
status(NOERROR,NXDOMAIN,NODATA) and NS hosts inrecordsas{host}, lower case without the trailing dot. URLs in the input are cut down to the host name. - It queries the exact name you give it; it does not walk up to the zone apex and it does not map hosts to a provider name. Pass registered domains and use a pattern table like the one above for the provider column.
- System resolver first, Cloudflare DNS-over-HTTPS only as a fallback. No WHOIS or registrar data.
- US$0.20 per 1,000 rows plus US$0.0005 per run start. With only
NSselected, 1,000 domains is 1,000 rows (US$0.20). Failed lookups are not charged. Apify's free plan includes US$5 of usage a month, about 25,000 rows. - About 11–15 rows per second; up to 10,000 domains per list; one run lasts at most about 60 minutes.
Input for a nameserver-only run:
{ "domains": ["github.com", "python.org", "shopify.com"], "recordTypes": ["NS"], "maxItems": 1000 } It is not affiliated with or endorsed by Cloudflare, Amazon, Microsoft or any other DNS provider.
FAQ
How do I find out who hosts the DNS for a domain?
Look up the domain's NS records (dig +short NS example.com) and read the host names. The company that runs those nameservers is the DNS provider. For example, *.ns.cloudflare.com means Cloudflare and ns-*.awsdns-* means Amazon Route 53.
Why does www.example.com return no nameservers?
Nameservers belong to a zone, and www. is usually just a record inside the zone, often a CNAME. Remove labels from the left until you reach a name that has NS records owned by that exact name; that name is the zone apex.
Can I tell if a website uses Cloudflare from its nameservers?
Only that Cloudflare runs its DNS. Whether the website itself is served through Cloudflare's proxy is a separate question: records can be "DNS only", and sites with other DNS providers can still be proxied by Cloudflare. Check the site's response headers or IP addresses instead.
Why do some domains list two different DNS providers?
Large sites often publish nameservers from two providers so that DNS keeps working if one has an outage. In the run above, github.com and airbnb.com both list NS1 and Amazon Route 53.
What does your list turn up most often in the "unknown" column: vanity nameservers, sister domains, or providers missing from the table?
Disclosure: I built the Apify Actor mentioned in this post.