Search code examples
dnsconsulnslookupdigconsul-health-check

why server can't find pihole.service.consul: NXDOMAIN and how can I fix this?


I have following configuration for consul.

{
  "service": {
    "name": "pihole",
    "Address": "192.168.0.15",
    "tags": [
      "pi"
    ],
    "port": 8165,
    "check": {
      "args": [
        "curl",
        "192.168.0.15"
      ],
      "interval": "10s"
    }
  }
}

using dig i get no error now,

$ dig @127.0.0.1 -p 8600 pihole.service.consul

; <<>> DiG 9.9.7-P3 <<>> @127.0.0.1 -p 8600 pihole.service.consul
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 63573
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;pihole.service.consul.     IN  A

;; ANSWER SECTION:
pihole.service.consul.  0   IN  A   192.168.0.15

;; Query time: 0 msec
;; SERVER: 127.0.0.1#8600(127.0.0.1)
;; WHEN: Sun Aug 30 23:02:34 BST 2020
;; MSG SIZE  rcvd: 66

but when I do nslookup, i get the error server can't find pihole.service.consul: NXDOMAIN

$ nslookup pihole.service.consul
Server:     192.168.0.15
Address:    192.168.0.15#53

** server can't find pihole.service.consul: NXDOMAIN

I actually have a pihole running at this ip address 192.168.0.15 on the consul health check is passing.

2020-08-30T23:10:58.707+0100 [DEBUG] agent: Check status updated: check=service:pihole status=passing

Solution

  • In the command dig @127.0.0.1 -p 8600 pihole.service.consul you explicitly instructed host to use server 127.0.0.1 and port 8600.

    Nslookup uses nameserver from your /etc/resolv.conf file and port 53 by default.

    You can try

    nslookup pihole.service.consul 127.0.0.1 -port=8600