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

DNS Resolution Sequence in Digital Ocean Droplets

· 52CE 我爱测

I have setup multiple domains on my droplet and they cross-reference each other. Currently, when I do a nslookup for these domains from within the droplet, the DNS resolution is handled by 67.207.67.3 which is Digital Ocean's DNS…

问题原文

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

I have setup multiple domains on my droplet and they cross-reference each other. Currently, when I do a nslookup for these domains from within the droplet, the DNS resolution is handled by 67.207.67.3 which is Digital Ocean's DNS server and it happily points to the same droplet (localhost) via the public IP.

To save on the lookup time and speed up the "page loading time" of the pages cross-referencing these domains, I tried the following steps but I am drawing a complete blank:

Trying to Save these 235ms of DNS Lookup Time

  1. Modified the /etc/hosts file so that these domains point to localhost (127.0.0.1), however, that has no effect.

  2. Modified the /etc/cloud/templates/hosts.redhat.tmpl file and inserted the entries there, yet the lookup happens on the DO DNS server.

  3. Ensured that the /etc/nsswitch.conf states that the resolution order is "files" followed by "DNS".

  4. Restarted the networking service post all changes. Tried rebooting as well... Still no luck.

What am I missing? How do I change the name resolution precedence so that it first looks up the hosts file and if an entry is not found, it then looks up the DNS servers?

I do see the nameserver entries in /etc/network/interfaces and /etc/resolv.conf, however, I am not sure if modifying them will yield any results.

Any pointers will be well appreciated. Thanks in advance.

已采纳解答

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

I am guessing you are testing with nslookup/host/dig?
Those have the effect of not looking up into /etc/nsswitch.conf and asking the DNS first, as they are a DNS diagnostic tools.

Try a ping to the domain it should resolve to 127.0.0.1 as per /etc/hosts.
All other daemons should also resolve to 127.0.0.1, if they don't please paste the contents of /etc/nsswitch.conf and /etc/hosts

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

资料来源与适用范围

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

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

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