0

I am in the process of making our application into smaller services. I add the new services on a back end server (i.e. not accessible to public) and then make entries in /etc/hosts file of our web servers. Sample entry

10.160.x.xx newservice.mydomain.com    

This approach works. But if I test the service from the web server, I see that ping works, not nslookup. So ping newservice.mydomain.com is successful, not nslookup newservice.mydomain.com
Why is it so? How can I make nslookup also work?

Jayadevan
  • 148
  • 8

1 Answers1

1

nslookup asks the DNS servers, and they have no knowledge of you local hosts file, so they won't resolve the entries contained within it. If you want your hosts file to be accessible via DNS lookups, you have to use a DNS server which has knowledge about it (for example, systemd-resolved can be configured to parse the file).

However, using a hosts entry seems redundant here, as each compute engine instance can be resolved using the default Google cloud DNS server (169.254.169.254). The name of each compute engine is [INSTANCE_NAME].[ZONE].c.[PROJECT_ID].internal (more info about the internal DNS is available here), so you should be able to access your servers by that name.

Lacek
  • 7,233
  • 24
  • 28