1

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.

1

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

  • Hi Daniel, you are spot on. Yes, I was using nslookup for testing. As per your suggestion, did a ping and it does resolve to 127.0.0.1. Guess all is well then :-) Thanks a ton.... appreciate your help. – Mangesh Mar 28 '18 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.