Ubuntu – Ubuntu 18.04 DNS resolution fails after a while

18.04dnsnetworkingserver

When I ping google.com on my Ubuntu 18.04, it gives me

ping: google.com: Temporary failure in name resolution

I would then proceed to run

sudo service systemd-resolved start

My /etc/resolv.conf has a symbolic link as shown

/etc/resolv.conf -> /run/systemd/resolve/stub-resolv.conf

The content is as follow

# 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 "systemd-resolve --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

My question is after running sudo service systemd-resolved start, it would work for a while (Maybe couple of hours), then when i ping google.com again, it would give the name resolution error. How can I permanently enable my system to resolve name resolution? I believe it is something to do with the systemd-resolved? Have been experiencing this over a couple of days. Thanks

— Update —

A hackish way would be to set up sudo crontab to restart the service every few hours.

Best Answer

There is a known bug with resolved stub service, see https://github.com/systemd/systemd/issues/10298

The workaround I found was to change the symlink for /etc/resolv.conf to point to /run/systemd/resolve/resolv.conf

It seems to be a problem that affects static routes. I didn't have the problem when using DHCP.

Related Question