0

When I read 《DNS and BIND》 CHOOSING BETWEEN AUTHORITATIVE NAMESERVERS:

Some of the card-carrying Mensa members in our reading audience may be wondering how the nameserver that receives the recursive query chooses among the nameservers authoritative for the zone. For example, we said that there are 13 root nameservers on the Internet today. Does the nameserver simply query the one that appears first in the referral? Does it choose randomly?

BIND nameservers use a metric called roundtrip time, or RTT, to choose among nameservers authoritative for the same zone. Roundtrip time is a measurement of how long a remote nameserver takes to respond to queries. Each time a BIND nameserver sends a query to a remote nameserver, it starts an internal stopwatch. When it receives a response, it stops the stopwatch and makes a note of how long that remote nameserver took to respond. When the nameserver must choose which of a group of authoritative nameservers to query, it simply chooses the one with the lowest roundtrip time.

Before a BIND nameserver has queried a nameserver, it gives it a random roundtrip time value lower than any real-world value. This ensures that the BIND nameserver queries all nameservers authoritative for a given zone in a random order before playing favorites.

On the whole, this simple but elegant algorithm allows BIND nameservers to “lock on” to the closest nameservers quickly and without the overhead of an out-of-band mechanism to measure performance.

this paragraph I don't understand,

Before a BIND nameserver has queried a nameserver, it gives it a random roundtrip time value lower than any real-world value. This ensures that the BIND nameserver queries all nameservers authoritative for a given zone in a random order before playing favorites.

why there say gives it a random roundtrip time value lower than any real-world value then the nameserver will queries all nameservers authoritative for a given zone in a random order before playing favorites?


My guess is that if the given low RTT time reach it will send DNS query to the next, and after all, it get all nameservers' RTT for saving, right?

aircraft
  • 288
  • 1
  • 5
  • 15

1 Answers1

0

I don't think the exact details of the nameserver selection algorithm in BIND is necessarily that important; it's an entirely implementation specific piece of code which may change over time.
On that note, the 5th edition of the book DNS and BIND that you reference is 14 years old now, so it may well be going into details that do not reflect the current reality.

However, the overall idea is relevant regardless exactly how it is implemented (and the concept is more relevant across the board as well):

It's beneficial to keep track of which nameservers are responsive and latch on to those, while not wasting time trying to use the ones that are not responsive (but retrying them now and then).


That said, I think the implementation that the book describes is something like:
  • For any new nameserver that is encountered (from an NS-set), assign a random close-to-zero RTT value.
  • When querying a zone, sort the NS-set by RTT. Take the first one. After you receive the response, update the RTT value.

That way, it will work itself through all the nameservers and assign RTT values as it keeps querying.

I believe there's also a decay function that lowers RTTs over time to ensure all the nameservers, even the ones that were "bad" at some point, get used now and then to find the current usable ones.

Håkan Lindqvist
  • 33,741
  • 5
  • 65
  • 90
  • `For any new nameserver that is encountered (from an NS-set), assign a random close-to-zero RTT value.` do you mean, assign all the `NS`-set to close-to-zero RTT value, right? – aircraft Nov 23 '20 at 02:01