代码改变世界

/etc/resolv.conf options rotate

2018-07-18 21:23  Loull  阅读(3189)  评论(0编辑  收藏  举报

timeout:n

  sets  the  amount  of time the resolver will wait for a response from a remote name server before retrying the query via a different name server.  Measured in seconds, the default is RES_TIMEOUT (currently 5, see <resolv.h>).  The value for this option is  silently capped to 30.


attempts:n

  sets  the  number of times the resolver will send a query to its name servers before giving up and returning an error to the calling application.  The default is RES_DFLRETRY (currently 2, see <resolv.h>).  The value for this option is silently capped to 5.


rotate 

  sets RES_ROTATE in _res.options, which causes round robin selection of nameservers from among those listed.  This has the effect  of  spreading the query load among all listed servers, rather than having all clients try the first listed server first every time.

rotate是伪随机,经常会固定使用某个nameserver,不一定是第一个

Root Cause

The reason why RES_ROTATE related code picks up the second nameserver every time as the first one is that the item rotation of nameserver list happens before contacting any of the nameservers, thus the second nameserver goes as first every time.

https://access.redhat.com/solutions/1426263