/etc/resolv.conf配置详解

options timeout:n attempts:n

timeout是指连接某个dns server有问题造成堵塞的超时值,单位是秒;
attempts是指解析域名尝试的次数。

根据内核源码/usr/include/resolv.h中的定义:
# define MAXNS 3 /* max # name servers we’ll track */
# define MAXDNSRCH 6 /* max # domains in search path */
# define RES_TIMEOUT 5 /* min. seconds between retries */
# define RES_DFLRETRY 2 /* Default #/tries. */

可以知道:

  • resolv.conf里的nameserver只能有3个,多写的无效;
  • timeout默认是5秒;
  • attempts默认是2次,也就是解析域名尝试的次数
    • 此值必须大于等于1
    • 这里的“次数”如果是1,指从nameserver1到nameserver3都做了尝试(碰巧都失败)。并非指某个nameserver的尝试次数。
0%