Nslookup (or dig) using default nameserver at

All the HashiCorp examples I have found use explicitly as the nameserver in their dig/nslookup cmdline examples.


There is one example which doesn’t use it explicitly, but makes no mention as to how to set it up as default.

(This above cmd is inside the Docker container, so it might be OK to skip that, but that still doesn’t answer, how a simple nslookup or dig commands will automatically hit on the base machine (or outside the container)).

What I am alluding to is that, I could not find the setup/configuration needed to put as the first nameserver as default as part of HashiCorp docs.

So, the question is:
What is the HashiCorp recommended of setting the first nameserver to, assuming Consul is running at and we would be forwarding 538600.

Example DNSMasq configuration used from here:

I feel the missing piece is the DHCP client bit which would add as the first nameserver.

Example: (for dhclient)

    cat >> /etc/dhcp/dhclient.conf <<EOF
prepend domain-name-servers;

The DHCP client setup then allows the following commands to work without requiring the explicit nameserver:

$> nslookup foobar.service.consul

Name: foobar.service.consul
Address: 10.b.c.d
Name: foobar.service.consul
Address: 10.b.c.d
Name: foobar.service.consul
Address: 10.b.c.d

This would also allow raw_exec tasks to refer to each other using just the service name syntax, right?


Hi @shantanugadgil, apologies for the very delayed reply here. You’re correct, the majority of the examples on the DNS forwarding guide do not explicitly state that needs to be added as a nameserver (or be the only name server) in /etc/resolv.conf.

I’ll make a note of this and will try to get this updated over the next week.

Thanks for bringing this to my attention.

1 Like

Hi @shantanugadgil,

A sentence has been added to the prerequisites to state that nameserver must be added to /etc/resolv.conf when using Consul DNS forwarding with BIND, dnsmasq, or Unbound.