0

I just installed bind on CentOS 8 using: linuxapt.com/blog/caching-dns-server-on-centos-8 and nslookup google.com` shows:

Server:         169.254.169.254
Address:        169.254.169.254#53

Non-authoritative answer: Name: google.com Address: 172.217.15.78 Name: google.com Address: 2607:f8b0:4004:810::200e

bind config:

listen-on port 53 { 127.0.0.1; any; };
allow-query { localhost; any; };
allow-query-cache { localhost; any; };
recursion yes;

169.254.169.254 is not my IP. Am I missing something?

EDIT there is this in my /etc/hosts 169.254.169.254 metadata.google.internal # Added by Google - i dont understand how does it affect dns

resolve config:


# Generated by NetworkManager
search us-east4-c.c.haawks.internal c.haawks.internal google.internal
nameserver 169.254.169.254

4 Answers4

1

apparently (on GCP machines) command sudo systemctl restart NetworkManager.service overrides /etc/resolv.conf every time and my nameserver is lost.. not sure why but its a different question.

1

By default, NetorkManager is running and it will write /etc/resolv.conf with the settings received via DHCP.

As you run a local DNS server, you don't want that, and you basically want to always use 127.0.0.1 as nameserver. You need to tell NetworkManager that you want that:

add /etc/NetworkManager/conf.d/90-dns-none.conf with

[main]
dns=none

And issue systemctl reload NetworkManager. See also man NetworkManager.conf.

Afterwards edit /etc/resolv.conf to your liking.


Btw, you could have also marked the file as readonly with chattr -i /etc/resolv.conf followed by systemctl reload NetworkManager. Similar result.

Or, you could replace /etc/resolv.conf with a symlink to the actual file with nameserver 127.0.0.1, followed by systemctl reload NetworkManager. That also tells NetworkManager to stay away.

thaller
  • 169
0

Make sure that your local DNS can resolve the domains. You can test your local DNS server through the dig command:

dig google.com @127.0.0.1

If it works then, open this file: /etc/sysconfig/network-scripts/ifcfg-eXX

and add your local DNS server to this file:

DNS1=127.0.0.1

Then restart your NetworkManager. It is going to update your /etc/resolv.conf file.

Adil
  • 249
  • 1
  • 8
0

On Centos7 to persist /etc/resolve.conf on reboot add #prevents DHCP from overwriting the /etc/resolv.conf file

PEERDNS=no

to /etc/sysconfig/network-scripts/ifcfg-adapter_name_file

Source :Linux Bible by Negus

Caesarius
  • 1
  • 1