What has priority: nameservers or a records?

If I have a domain name with nameservers pointing to Webhost One, but have an A Record that points to Webhost Two, which host would the domain name bring me to?

I'm pretty sure the A Record takes precedent, doesn't it? I currently have domains with GoDaddy, but point an A Record to 000Webhost. My domain brings me to 000Webhost. But doesn't this mean that the domain WHOIS information is inaccurate?

Is it that the nameservers point to GoDaddy, and then GoDaddy points to 000Webhost? Or does it go straight to 000WebHost?

The reason I ask is that a friend of mine has a website that is pointed to a webhost, but that webhost has no record of that site being hosted there, and yet the site has been online for a decade. So I'm wondering if the nameservers are ever taking precedent, or, really, what is going on?


Solution 1:

I think you're badly misunderstanding how DNS work. NS records are used to find the authoritative server for a domain. The A resource record is what the client is requesting (normally) and is what will be looked up for the response to the client.

Quickly-ish:

Lets say you own example.com. Someone enters http://www.example.com into their webbrowser. Their computer issues a recursive lookup for www.example.com to their local DNS server. That server doesn't know what IP www.example.com resolves to, so it figures out the lowest level of domain for which it does know the servers. In this case it's the . root servers. The domain name www.example.com is actually www.example.com. <-- note the "." on the end.

So that DNS server contacts the root server and asks them if they know where www.example.com is. They don't. They do know where "com." is however, by was of NS records for that domain. This NS record is returned to the DNS server. So the DNS server contacts the "com." server and asks them if they know where www.example.com is, they don't either. But they do know where "example.com." is, again by NS records, which point to a.iana-servers.net. and b.iana-servers.net.. Nobody "just knows" where those servers are, so glue records for those domains are registered with the "net." root servers. More lookups to the "net." root servers...

The DNS server now knows how to contact the server for the example.com. domain! So it asks that server if it knows where 'www.example.com' is, it does! That server has a SOA record that identifies it as authoritative for the 'example.com.' domain, and it knows the A record for 'www.example.com', the IP it points to. The DNS server returns this IP to the client and the world is safe for another night.

Moar details:

When the client requested www.example.com from the DNS server it told the DNS server it was looking for an A record (A are for IPv4; clients also commonly look for IPv6 AAAA records too these days). When the other DNS server got the requests for the A record they also looked for CNAME records, but didn't search other record types. The DNS server know that when the request for a longer domain name fails (eg the root servers don't know where www.example.com is) that the DNS server is going to be interested in what information that server does have, eg. the NS record(s). How this works is more complicated than you'll care about, but the root server definitely returns a "failure" of sorts when the DNS server is trying to find the domain.

If the client was requesting a MX record for e-mail, or a SRV record, or a TXT record, or whatever, the responding DNS server will not just search for any record type that matches the domain name give, it will only search for the same record type (with the exception when looking for A or AAAA records the results for a CNAME match will be returned if no A or AAAA record matches). Also the server can have a "default" or wildcard records that may also match, but are subordinated to direct matches. It's best to avoid these situations unless you really know what you're doing.

Solution 2:

Chris' answer is most relevant to the OP's situation. However it is actually possible to have an NS and an A record in the same authoritative DNS manager. In that case "which takes priority" isn't directly addressed by Chris' answer. The answer is that the NS record takes priority over the A record.

I used records at Google Domains to test. The subdomain does not resolve while both exist (the NS record pointing to nameservers without an entry for the subdomain). If I rename the NS record to a different subdomain, the A record is "exposed" and resolves to the IP address indicated. If I rename the NS record back, it "masks" the A record again and produces no valid response.

Solution 3:

There is no thing like "precedence" with A records across different providers. There is one authoritative name service for your domain name. I cannot extract from your explanation though which provider it is in your case.

But if you can do a quick dig +trace yourdomain.name you will see the "chain" of queried DNS servers starting from the root zone. (Or just hand over the domain name in question.) You will see which provider gives you the authoritative address that your browser will follow.

Maybe you are confused by the fact that more than provider holds DNS information about your domain. That might be the case for whatever reason but as long as a provider does not hold the authoritative records, he will never be queried by a real-life client.