DNS Resolution Sequence
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 220.127.116.11 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:
Modified the /etc/hosts file so that these domains point to localhost (127.0.0.1), however, that has no effect.
Modified the /etc/cloud/templates/hosts.redhat.tmpl file and inserted the entries there, yet the lookup happens on the DO DNS server.
Ensured that the /etc/nsswitch.conf states that the resolution order is “files” followed by “DNS”.
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.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×