Score:0

Netplan nameservers settings not used without resolv.conf entry

cn flag

I read here that you're usually not supposed to edit resolv.conf, since it is managed by other services. The server is running Ubuntu 22.04.1 LTS.

However, the DNS on my server is not working unless I put the following line in my resolv.conf

nameserver 127.0.0.53

If I emtpy resolv.conf or remove the file entirely, I can no longer ping google.com. I don't understand this, as I read here:

If this file does not exist, only the name server on the local machine will be queried

I want to use netplan to configure my network, and in my netplan config there's an entry for the nameservers. My netplan configuration looks like this:

# This is the network config written by 'subiquity'
network:
  version: 2
  renderer: networkd
  ethernets:
    ens160:
      dhcp4: no
      addresses: [10.0.0.5/24]
      nameservers:
        search: [my.domain.com]
        addresses: [1.1.1.1, 8.8.8.8]
      routes:
        - to: default
          via: 10.0.0.254

There was a file called /etc/systemd/resolved.conf but it has since been removed.

How can I have working DNS without manually editing the resolv.conf file?

ru flag
Did you disable resolvconf / resolved's stub file? Did you uninstall resolved? Does `/run/systemd/resolve/resolv.conf` exist? If you run `sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf` does stuff work again?
John Stoneman avatar
cn flag
1. I don't know how. 2. No. 3. Yes. 4. Probably, but is that the way it is supposed to be set up?
ru flag
That's one of the things that SystemD / ResolveD should be doing on its own. It's possible that with no `/etc/systemd/resolved.conf` it's not picking it up, but it should not have been deleted, if it was deleted it's likely something else is installed taking over (resolvconf for instance) but that's not typical.
chili555 avatar
cn flag
Possibly helpful: https://askubuntu.com/questions/1150239/run-resolvconf-resolv-conf-ubuntu-18-04/1150294#1150294 Welcome to Ask Ubuntu.
John Stoneman avatar
cn flag
@ThomasWard if you respond with an answer, I can resolve this question.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.