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

Understanding the Difference Between DNS Resolvers

· 52CE 我爱测

Intro In the attempt to debug a networking issue local to our intranet, it became apparent that curl host nslookup and dig behave differently. Where dig and host returns the IP address of the URL in question, curl and nslookup re…

问题原文

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

Intro

In the attempt to debug a networking issue local to our intranet, it became apparent that curl host nslookup and dig behave differently. Where dig and host returns the IP address of the URL in question, curl and nslookup return:

 curl: (6) Could not resolve host: internal.site.company.com

and

 nslookup: can't resolve 'internal.site.company.com`

Context

While this should not matter, in the essence of giving more context to the problem, this issue is occurring on and behind a docker-machine (tested using a docker-machine on both virtualbox and parallels to be exact). The docker-machine and containers it hosts all have the correct IP address of the desired internal DNS server in their /etc/resolv.conf. The IP address of the desired URL is also reachable from the machines which cannot resolve the name. As touched on above, the address is an internal site and our DNS server is also internal. The site is reachable and resolvable from the computer where docker-machine is installed.

Questions

Which brings me to the questions...

1) Under the hood, what are dig and host doing differently than both cURL and nslookup?

2) What could possibly be preventing a browser or curl from resolving the URL the way both host and dig are successfully resolving the name?

Setup

dig -v: DiG 9.11.1

host -v: host 9.11.1

curl -V: curl 7.49.1

docker version: Version 17.06.0-ce-mac19 (18663) Channel: stable

 Boot2Docker version 17.06.0-ce, build HEAD : 0672754

已采纳解答

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

I would expect curl to us the resolver library which will use the name service providers listed in the /etc/nsswitch.conf hosts specification in order. If this does not include DNS, DNS resolution will not occur. nslookup is not documented to use this file, but from your experience it appears it may. Often this data is cached by a name service caching daemon. If the daemon, is failing you may get this kind of issue even if the other configurations are correct.

host and dig are pure DNS lookup programs. They both resolve names only via DNS. They will not resolve names using files or other non-DNS providers. I would expect them to use the information in /etc/resolv.conf directly.

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

资料来源与适用范围

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

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

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