# Nodelocal DNS Cache can not resolve /etc/hosts each node

**URL:** <https://discuss.kubernetes.io/t/nodelocal-dns-cache-can-not-resolve-etc-hosts-each-node/21233>\
**Category:** General Discussions\
**Tags:** coredns, network\
**Created:** [September 9, 2022, 7:53am UTC](https://discuss.kubernetes.io/t/nodelocal-dns-cache-can-not-resolve-etc-hosts-each-node/21233 "2022-09-09T07:53:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marco210](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/marco210/32/10792_2.png) [@marco210](https://discuss.kubernetes.io/u/marco210)\
**Post date:** [September 9, 2022, 7:53am UTC](https://discuss.kubernetes.io/t/nodelocal-dns-cache-can-not-resolve-etc-hosts-each-node/21233/1 "2022-09-09T07:53:08Z")

</div>

Asking for help? Comment out what you need so we can get more information to help you!

Each `/etc/hosts` node have local domain xx.xx.xx.xx [harbor.io](http://harbor.io). Before install Nodelocal DNS Cache, in another pod I can `dig harbor.io` and return ip in `/etc/hosts` .

```auto
dig harbor.io

; <<>> DiG 9.9.5-9+deb8u19-Debian <<>> harbor.io
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10551
;; 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:
;harbor.io. IN A

;; ANSWER SECTION:
harbor.io. 30 IN A xx.xx.xx.xx

;; Query time: 0 msec
;; SERVER: 10.96.0.10#53(10.96.0.10)
;; WHEN: Fri Sep 09 07:18:10 UTC 2022
;; MSG SIZE rcvd: 63

```

When I run Nodelocal DNS Cache follow file `https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/dns/nodelocaldns/nodelocaldns.yaml` and replace follow:

```auto
kubedns = 10.96.0.10
domain = cluster.local
localdns = 169.254.0.10
sed -i "s/ __PILLAR__ LOCAL __DNS__ /$localdns/g; s/ __PILLAR__ DNS __DOMAIN__ /$domain/g; s/ __PILLAR__ DNS __SERVER__ /$kubedns/g" nodelocaldns.yaml

```

then `dig harbor.io` return another ip address:

```auto
; <<>> DiG 9.9.5-9+deb8u19-Debian <<>> harbor.io
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34507
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;harbor.io. IN A

;; ANSWER SECTION:
harbor.io. 30 IN A 204.232.175.78

;; Query time: 481 msec
;; SERVER: 10.96.0.10#53(10.96.0.10)
;; WHEN: Fri Sep 09 07:15:15 UTC 2022
;; MSG SIZE rcvd: 63

```

In another pod add config

```auto
dnsConfig:
    nameservers:
    - 169.254.0.10
    searches:
    - default.svc.cluster.local
    - svc.cluster.local
    - cluster.local
    options:
    - name: ndots
      value: '2'

```

### Cluster information:

```auto
Kubernetes version: v1.23.7
Installation method: kubeadm
Host OS: Ubuntu 20.04 LTS
CNI and version: calico v3.23.1
CRI and version: docker://20.10.12

```
