All the HashiCorp examples I have found use 127.0.0.1
explicitly as the nameserver in their dig/nslookup cmdline examples.
Example:
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 127.0.0.1
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 127.0.0.1
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 127.0.0.1
, assuming Consul is running at 127.0.0.1:8600
and we would be forwarding 53
→ 8600
.
Example DNSMasq configuration used from here:
I feel the missing piece is the DHCP client bit which would add 127.0.0.1
as the first nameserver.
Example: (for dhclient)
cat >> /etc/dhcp/dhclient.conf <<EOF
prepend domain-name-servers 127.0.0.1;
EOF
The DHCP client setup then allows the following commands to work without requiring the explicit nameserver:
$> nslookup foobar.service.consul
Server: 127.0.0.1
Address: 127.0.0.1#53
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?