/etc/resolv.conf not set on reboot

Asked by tomdean

# uname -rv
5.11.0-43-generic #47~20.04.2-Ubuntu SMP Mon Dec 13 11:06:56 UTC 2021
# lsb_release -d
Description: Ubuntu 20.04.3 LTS
# systemd-resolve --status| grep "DNS Server"
  Current DNS Server: 192.168.1.1
         DNS Servers: 192.168.1.1
  Current DNS Server: 192.168.1.1
         DNS Servers: 192.168.1.1
# ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 39 May 10 2021 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
# grep nameserver /etc/resolv.conf
nameserver 127.0.0.53
# grep DNS /etc/systemd/resolved.conf
DNS=192.168.1.1

I have two Ubuntu 20.04 systems that have the same problem. Local hosts are not resolved. Global hosts are.
# ping answers.launchpad.net
PING answers.launchpad.net (91.189.89.225) 56(84) bytes of data.
# ping meerkat
ping: meerkat: Temporary failure in name resolution

If I add 'nameserver 192.168.1.1' to /etc/resolv.conf locat hosts are resolved - no errors.

I thought systemd created /run/systemd/resolve/stub-resolv.conf using /etc/systemd/resolved.conf

What do I change to fix this?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
actionparsnip
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

Are you using a GUI system or is it a server?
If you ping "meerkat.local" does it resolve OK?

Revision history for this message
tomdean (tomdean) said :
#2

I am using both as GUI systems.

# ping meerkat
ping: meerkat: Temporary failure in name resolution

# ping meerkat.local
PING meerkat.local (192.168.1.143) 56(84) bytes of data.
...

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#3

OK then use the FQDN or add a search name to your DNS configuration

Revision history for this message
tomdean (tomdean) said :
#4

Adding 'nameserver 192.168.1.1' fixes the problem. But, this overwritten at boot. How do I get this into some conf file?

systemd-resolve --status shows
  Current DNS Server: 192.168.1.1
         DNS Servers: 192.168.1.1
  Current DNS Server: 192.168.1.1
         DNS Servers: 192.168.1.1
          DNS Domain: ~.
                      xxxxxxxxx.com

Something seems to be missing from the initial install. I have this problem on 2 systems, 1 new and 1 old.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#5

If you add a DNS search domain of "local" then this will be appended to all searches first and you'll resolve the name OK

Revision history for this message
tomdean (tomdean) said :
#6

I tried adding the search name local. Maybe I did it wrong. How do I do this from the command line?

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#7

In network manager you should be able to set additional search domains and just add the word "local"

Revision history for this message
tomdean (tomdean) said :
#8

As near as I can tell, Domains is set in /etc/systemd/resolved.conf
I added
  Domains=local xxxxxxxx.com

# cat /etc/resolv.cong
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad
search local wavecable.com

This did not fix the problem.

Revision history for this message
tomdean (tomdean) said :
#9

After changing /etc/systemd/resolved.conf,
# sudo service systemd-resolved restart

Revision history for this message
tomdean (tomdean) said :
#10

On 12/21/21 10:55 AM, tomdean wrote:
> Your question #699922 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/699922
>
> You gave more information on the question:
> After changing /etc/systemd/resolved.conf,
> # sudo service systemd-resolved restart
>

In the past 24 hours, something triggered a remake of /etc/resolv.conf
actually (run/systemd/resolve/stub-resolv.conf)

 > cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
...
# See man:systemd-resolved.service(8) for details about the supported
modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad
search local wavecable.com

 > uptime
  12:30:21 up 8 days, 1:11, 2 users, load average: 0.36, 0.32, 0.28

I have a script to make a workaround:

 > cat ~/bin/fix-dns.sh
#!/bin/sh

sudo sed -i -e '/nameserver/a nameserver 192.168.1.1'
/run/system/resolve/stub-resolv.conf

Surely, I am not the only person using a router and its nameserver
192.168.1.1

I need a fix for this. This system is essentially that installed from
the DVD image.

After a normal install from the DVD image, I converted to vanilla-gnome:
===============================================
Remove Unbuntu desktop and snap. install vanilla gnome
for f in /dev/loop*; do sudo umount $f; done
sudo apt purge snapd
sudo apt install gnome-session
reboot
sudo apt install vanilla-gnome-desktop vanilla-gnome-default-settings
sudo apt clean
sudo apt autoremove
reboot

Right click on background and select background picture
Gnome Tweaks Tool
   applications
     app menu yaru-dark
     cursor Yaru
     Icons Yaru
     Sound Yaru
   extensions
     enable user themes
restart gnome tweaks tool
   appearance
     shell yaru-dark
   extensions
     enable desktop icons
            places status indicator
            removable drive indicator
            ubntu appindicators
            workspace indicator
   Top Bar
     enable clock, weekday, date, seconds
   Window Titlebars
     enable maximize and minimize
exit gnome tweak tool
firefox
   gnome shell extensions
   click here to allow extensions, continue, add, OK
   install open weather Change to Silverdale
     dash to dock
     sound input and output
   exit firefox
Gnome Tweaks Tool
   extensions
     dash to dock select bottom and 32px icons,disable autohide
        appearance shrink dash
=======================================================
I do not see anything that should effect DNS.

Tom Dean

Revision history for this message
tomdean (tomdean) said :
#11

On 12/29/21 12:55 PM, tomdean wrote:

I have to edit /etc/resolv.conf every day to fix this. On more than one
machine.

What configuration setting controls writing
/run/systemd/resolve/stub-resolv.conf? I have read the man pages and can
not discover where to configure this.

Tom Dean

Revision history for this message
Best actionparsnip (andrew-woodhead666) said :
#12

Doesn't Ubuntu use netplan now? You could try the config files there....

Revision history for this message
tomdean (tomdean) said :
#13

Strange happenings...

I did `sudo apt update` and `sudo apt upgrade`. I did not see anything strange in the proposed downloads, so I upgraded 63 packages. After a reboot, everything worked. 'nameserver 192.168.1.1' is NOT in /etc/resolv.conf.

> sudo service netplan status returns 'Unit netplan.service could not be found.'

192.168.1.1 is in /etc/systemd/resolved.conf and has been for two weeks. I had to fix-dns a dozen times since then. This adds 'nameserver 192.168.1.1' to /etc/resolv.conf, a link to /run/resolvconf/resolv.conf.

Code rot?

Some not obviously related code change in the upgrade most likely.

AAAAARRRRRRRRGGGGGGHHHHHHHHHHHHHHHHHHHHHHHHHHH