6

For some reason, my DNS seems to be set to 127.0.0.53. It's not really a problem, since my local (i.e. on my laptop) DNS seems to redirect DNS requests to the default gateway. But I would like it to not go that way. I suppose I must have installed some DNS server at some time in the past...

When I run $ nslookup, default server is always 127.0.0.53.

I found a post suggesting that I set DNSStubListener=no in /etc/systemd/resolved.conf, but this resulted in no DNS requests coming through. I could of course enter my default gateway manually, but then I would have to change it every time I brought my laptop to work.

Any suggestions?

EDIT: Adding the "hosts" line of /etc/nsswitch.conf:

hosts:          files mdns4_minimal [NOTFOUND=return] dns
OZ1SEJ
  • 1,323
  • 1
    Your DND server is not actually 127.0.0.53. Look at this question on Unix &Linux: https://unix.stackexchange.com/questions/612416/why-does-etc-resolv-conf-point-at-127-0-0-53 – Nmath Apr 24 '21 at 16:08
  • 1
    Please add to your post the "hosts" line of /etc/nsswitch.conf ..; Adding the libnss-resolve package alters this and might fix some local name lookups. – ubfan1 Apr 24 '21 at 16:11
  • 1
    It's working the way it's supposed to. Don't mess with it. Do resolvectl status | grep -i "DNS Serve" to see what DNS Servers that you're actually using. – heynnema Apr 24 '21 at 23:29
  • @heynnema: Is this default Ubuntu behavior? – OZ1SEJ Apr 25 '21 at 11:05
  • 2
    Yes. Everybody's /etc/resolv.conf shows 127.0.0.53. It's all managed by systemd-resolved. Using my prior command you'll see what real DNS servers it all points to. I see too many people trying to manually edit /etc/resolv.conf (even though it says not to in the file), thinking that they can "fix" an unbroken DNS system. – heynnema Apr 25 '21 at 12:41
  • @heynnema Ah - thank you. Can't you write this as an answer, so that I may mark it as the correct one? – OZ1SEJ Apr 25 '21 at 15:03
  • @OZ1SEJ Done. Thanks! – heynnema Apr 25 '21 at 15:37

1 Answers1

15

The DNS Servers are managed by systemd-resolved, or by dnsmasq (if you have that installed).

If dnsmasq is installed, you must edit /etc/systemd/resolved.conf, else you'll have two DNS mechanisms fighting for port 53, so...

change:

#DNSStubListener=yes

to this:

DNSStubListener=no

/etc/resolv.conf normally contains 127.0.0.53, which is the local address for the local DNS mechanism. Do NOT manually edit this file (it says so right in the file itself).

To view what actual DNS servers are being used, do this...

resolvectl status | grep -i "DNS Serve"

More than likely it'll report 192.168.0.1 (the address of your router, or the DNS servers of your VPN service, if you use a VPN). Your router will probably use your ISP's DNS servers, unless you've manually changed that in your router's admin config page (highly recommended).

heynnema
  • 73,937
  • How much ever we try to suppress systemd-resolved, sometimes systemd command listens on 53. Any ideas? Im hardly able to find anything relevant. Almost everything talks about systemd-resolved. Unsure of how to suppress systemd from listening on it provided all the stublisteners have been handled. As systemd is intertwined with the overall system setup, unsure how the overall process goes on, which might have some ramifications on the entire setup. – Shyam R Oct 16 '24 at 16:38
  • @ShyamR What problem are you trying to solve? – heynnema Oct 16 '24 at 17:26
  • need to stop systemd from listening on port 53 [which wasnt even supposed to be done by it. I guess they want to keep tabs on DNS requests if at all ppl block systemd-resolved]. Then whats the point of this whole drama? – Shyam R Oct 17 '24 at 07:11
  • @ShyamR Are you having a problem that /etc/resolv.conf contains 127.0.0.53? That's the way it works. Please start a new question with your details. – heynnema Oct 17 '24 at 13:38
  • My point is very simple. Already theres systemd-resolved to allow users to set the configuration in /etc/systemd/resolved.conf which lets to remove stublisteners. So Im not quite sure why systemd process keeps listening on 53. Theres not much in this to create another question as its completely related to this. lsof -i :53 gives tcp/udp listeners for systemd command Though after stopping systemd-resolved, that processname doesn't appear in active listeners – Shyam R Oct 17 '24 at 15:11
  • any ideas to stop systemd main init process to listen on any of the sockets/ports? As if systemd-resolved is being stopped the main process keeps listening on some of the ports. Is there a overall config that can be placed to control the overall system setup? – Shyam R Nov 16 '24 at 16:39
  • @ShyamR I don't know how to help you. – heynnema Nov 16 '24 at 16:55