2

At home I run a Raspberry Pi with PiHole. Every device obtain its IP via DHCP and some devices have a reserved address. The router is configured to offer my Raspberry Pi as primary DNS, for every device this works well, except for my laptop with Ubuntu.

Quite often (like every day) my DNS is changed to my second DNS option. I can revert this change with resolvectl dns <interface> <ip>, but IMHO this should not happen. If I assign a primary DNS, it should be the one used, not matter what, unless it cannot be reached.

What could be the reason for having Ubuntu changing my primary DNS?

Update:

This is what the logs says about the automatic change. Aparently, there is no reason to pickup the second DNS over the first.

enter image description here

Manuel
  • 938
  • 11
  • 20
  • 1
    Your networking logs should have the answer to that question. The system will not do something like this without logging the reason for it – matigo Dec 27 '21 at 13:21
  • You could hard code the desired DNS entry in netplan probably. See https://askubuntu.com/questions/1383165/nameserver-goes-missing-from-etc-resolv-conf/1383180#1383180 – user10489 Dec 27 '21 at 13:22
  • @matigo, I have added the logs with the change. I do not see in the logs any reason for the preference of my second DNS over the first. If you have a suggestion for a different search on the logs, please let me know. – Manuel Dec 28 '21 at 16:16
  • @user10489. Thanks, but that is not the point of my question. – Manuel Dec 28 '21 at 16:17
  • Please read the answer I linked. netplan, network manager, and systemd all mess with resolv.conf unless you either disable it or configure what you want through one of those. – user10489 Dec 28 '21 at 17:27
  • @user10489. I read the answer, but my question is "why my DNS of preference, as indicated by DHCP, is not respected". I do not want to make an exception with my laptop and hardcode the DNS, the rest of the network is using my first DNS, except Ubuntu. I want to understand why. – Manuel Dec 29 '21 at 17:23
  • Likely it is using the local caching dns server, which is itself using one or both of the DNS servers provided by dhcp. – user10489 Dec 29 '21 at 21:00
  • I'm experiencing the same problem with Ubuntu 22.04 but I don't have those lines in my logs. Sadly this is driving me insane! My router doesn't have hairpining, so I rely on DNS to reach the local server and if Ubuntu decides to switch it, then many of my services are gone. – Felipe Jan 27 '23 at 19:56

0 Answers0