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
Boppity Bop
  • 722
  • 3
  • 11
  • 29
  • 1
    Does this answer your question? [What is this IP address: 169.254.169.254?](https://serverfault.com/questions/427018/what-is-this-ip-address-169-254-169-254) – ceejayoz Jan 25 '21 at 20:17
  • nope. i dont care what it is. my question is - why it is NOT my IP since I just installed dns locally – Boppity Bop Jan 25 '21 at 20:33
  • please share your /etc/resolv.conf. your OS doesn't have to use your local dns server unless you tell your OS to use the local DNS server. – Adil Jan 25 '21 at 20:44
  • see my "answer" - some serious magic is in place! :) – Boppity Bop Jan 25 '21 at 20:45
  • 1
    I just saw your answer. what's wrong with this output? you are using the internal dns of gcp. it resolves the domain through upper/root dns server (recursion). what do you want to see? do you want to see your local server's ip when you query `nslookup google.com` ? and please share your /etc/resolv.conf – Adil Jan 25 '21 at 20:50
  • yes i want to use my local DNS not google one. i expect it to cache requests. – Boppity Bop Jan 25 '21 at 20:54

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.

Boppity Bop
  • 722
  • 3
  • 11
  • 29
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
  • 159
  • 1
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
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://serverfault.com/help/whats-reputation) you will be able to [comment on any post](https://serverfault.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/525619) – bjoster Jul 21 '22 at 18:34