大网数据广告活动
服务器运维问答

Java and /etc/resolv.conf DNS server failover

· 52CE 我爱测

Executive Summary Does Java query the next resolv.conf name server entry if the first one fails or times out? What is the default timeout at which Java will consider a resolver "down"? Details In /etc/resolv.conf , in most sites,…

问题原文

原帖链接 · Friedrich 'Fred' Clausen · CC BY-SA 4.0

Executive Summary

  • Does Java query the next resolv.conf name server entry if the first one fails or times out?
  • What is the default timeout at which Java will consider a resolver "down"?

Details

In /etc/resolv.conf, in most sites, there are multiple DNS servers configured for use by the system. Can anyone clarify what happens, with Java, if the first DNS server in the list fails? For example, imagine the following resolv.conf:

nameserver 8.8.8.8
nameserver 4.4.4.4

If 8.8.8.8 becomes unreachable then will Java try 4.4.4.4? In our experience it does not - we saw many threads waiting to resolve DNS names even though the backup DNS servers were reachable.

已采纳解答

原帖链接 · HBruijn · CC BY-SA 3.0

On Linux java will delegate hostname resolution to the underlying C system library which does the actual resolving.

The name servers will be queried in the order listed as specified in /etc/resolv.conf after the other sources of information specified in /etc/nsswitch.conf have been queried (think /etc/hosts but possibly NIS or LDAP).

You can specify a timeout value in /etc/resolv.conf , according to the man page the default is 5 seconds.

If your first server gives a valid error code I.e. servfail the second name server will not be queried

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-02-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0 / CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。