在Unix / Linux中search名称parsing的顺序

可以说/etc/resolv.conf有以下内容..

nameserver 10.10.10.10 search x.com y.com 

对于“ping foo”解决scheme,我看到parsing器首先尝试configurationsearch域(即:foo.x.com,foo.y.com)的FQDN,然后尝试默认的“foo”。

这是所有* nix平台上的行为是否一致? 或者有些实现可以先在根域进行短名称parsing(即:“foo。”)?

从resolv.conf的手册页:

 options ndots:n Sets a threshold for the number of dots which must appear in a name given to res_query(3) (see resolver(3)) before an initial absolute query will be made. The default for n is 1, meaning that if there are any dots in a name, the name will be tried first as an absolute name before any search list elements are appended to it. The value for this option is silently capped to 15. 

因此,如果resolv.conf具有options ndots:0 ,它将立即尝试根域search,而不尝试任何search列表域。 手册页似乎表明它应该尝试search查询域是否不存在于根,但是我的parsing器在testing时没有这样做。 否则,如果没有点,则首先尝试search元素,然后耗尽列表后再尝试search元素。 请注意,您可以设置search . 这将根域放在search列表中。

另外需要注意的是,如果请求在另一个nsswitch.conf机制中得到满足,那么您的名称parsing可能永远不会将其parsing为resolv.conf。