0

We have registered 4 name servers in tld server for our domain. Here is an example of our NS record.

example.com. 172800 IN NS ns1.example.com.
example.com. 172800 IN NS ns2.example.com.
example.com. 172800 IN NS ns3.example.com.
example.com. 172800 IN NS ns4.example.com.

I have three questions here.

1.I just want to know which name server will be chosen to handle DNS query, Randomly or Orderly?

2.Is it possible that the name server is chosen based on the locaion of the client IP address?

3.If a DNS query was sent to ns3.example.com, but this name server did not respond within a certain period, what to do next? Will this DNS query be sent to another name server?

4.If there are multiple A records for a domain, which one would be chosen? For example,

ns1.example.com 172800 IN A 192.168.1.3 
ns1.example.com 172800 IN A 192.168.1.4

which IP will be returned for a DNS query?

3
  1. The choice of which authoritative server to query is done arbitrarily by the resolver server. The details of the strategy is implementation specific. Expect that any authoritative server may receive any query and must be able to answer all of them.

  2. Not in the sense that you could rely on it in any way.
    But, as an example, if the client is near the resolver server that queries your authoritative servers and that resolver implementation likes to latch on to a specific server based on low latency, you might indirectly get mostly this sort of effect if there's a steady stream of queries.

  3. The resolver server should try the other servers until it gets a response (ideal case, of course), all options are exhausted or the whole operation times out.

4

1.I just want to know which name server will be chosen to handle DNS query, Randomly or Orderly?

That depends on both how the authoritative name server for your domain is configured to respond, as well as on how your resolver deals with equivalent records.

In Bind DNS that is governed by means of the rrset-order which defaults to cyclic/round-robin. Round-robin seems to be the default for other name-servers as well.

Rounnd-Robin is not actually random, with each subsequent request the name server will move the top record to the bottom of the stack:

  • request #01 will be ordered NS1, NS2 , NS3, NS4
  • request #02 will be ordered NS2 ,NS3, NS4, NS1
  • request #03 will be ordered NS3, NS4, NS1, NS2
  • request #04 will be ordered NS4, NS1, NS2 , NS3
  • request #05 will again be ordered NS1, NS2 , NS3, NS4
  • request #06 will be ordered the same as request #2 : NS2 ,NS3, NS4, NS1
  • request #07 will be ordered the same request #3 etc. etc.

Since you don't know how many requests the name server has responded to between two subsequent requests by yourself the effect of round-robin may appear non-deterministic to you.

2.Is it possible that the name server is chosen based on the location of the client IP address?

Yes.

Somewhat...

Fairly typical for the better DNS hosting providers is to have the ip-addresses of authoritative name servers configured with anycast which simplified allows the same ip-address to be hosted in multiple geographic locations.

Routing protocols will then direct the DNS request from the client to the "nearest" name server, but that distance is measured in network routes, not actual geographic distance...

Once the client request has reached the nearest name server by means of anycast, then the name server may be configured with a geo-ip database and return different results (a different ip-address for for instance www.example.com.) based on the actual geographic location associated with the client ip-address.

3.If a DNS query was sent to ns3.example.com, but this name server did not respond within a certain period, what to do next? Will this DNS query be sent to another name server?

Yes.

3
  • I forgot a question. If there are multiple A records for a domain, which one would be chosen? For example, ns1.example.com 172800 IN A 192.168.1.3 ns1.example.com 172800 IN A 192.168.1.4, which IP is returned for a DNS query?
    – yifan
    Jan 30 '19 at 8:11
  • rrset-order does not determine how the recursion is performed, though? Only the order in which records are returned to clients in responses? Jan 30 '19 at 8:13
  • @yifan Regarding what is returned in the response: all. As for what exactly is done with the response depends on the software on the client. Jan 30 '19 at 8:42
2

The name servers will be chosen randomly and if one name server is down, the client will automatically choose another name server. Natively, the client will not choose a name server that is close to the server however, there is many 'tricks' that some DNS providers can offer. Amazons Route 53 for example, provides geolocation queries. This will not affect the name server for the domain but will allow you to create A, MX ect... records that follow a geolocation policy. In your case, if you wanted to host your own DNS you could register ns1.example.com with amazon and then use a geolocation routing policy to route the queries to a server that is close the the client. I personally don't see the point in doing that but, it's possible if you really wanted to.

It is also common large companies to have there public ip address hosted at many data centers across the world. For example, google's dns server is 8.8.8.8. Traffic to 8.8.8.8 is routed to the closest google data center depending on the location and network health.

3
  • I am afraid that if there is a long distance between our NS and client, the DNS query cost could be a problem for our website.
    – yifan
    Jan 30 '19 at 8:07
  • @yifan With caching at the resolver server, the average ought to be alright regardless but the cold-cache scenario is obviously worse with higher latency. Jan 30 '19 at 8:40
  • @Joe I recently found that the traffic volume on a name server is much more than the other three name servers. What could be the reason? Is it possible that the other three often respond slowly or even no response, so the name server with quicker response time is preferred by ISP or some other recursive resolvers?
    – yifan
    Mar 1 '19 at 5:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.