8

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.

  • As you say, starting the systemd-resolved can recover your situation, can you update the output of systemctl status systemd-resolved – alfred Feb 16 '20 at 06:51
  • When i restart it, it becomes active. but after a couple of hours it becomes inactive. How can i make this permanent? thanks – Ninja Dude Feb 17 '20 at 03:18
  • resolved, not networkd...you paste networkd state. You can update your question with those output, it is easier to see. – alfred Feb 17 '20 at 15:21
  • systemd-resolved.service - Network Name Resolution Loaded: loaded (/lib/systemd/system/systemd-resolved.service; enabled; vendor preset: enabled) Drop-In: /etc/systemd/system/systemd-resolved.service.d └─override.conf Active: failed (Result: start-limit-hit) since Tue 2020-02-18 01:16:03 +08; 8h ago Process: 2951 ExecStart=/lib/systemd/systemd-resolved (code=exited, status=0/SUCCESS) Main PID: 2951 (code=exited, status=0/SUCCESS) Status: "Shutting down..." – Ninja Dude Feb 18 '20 at 01:24
  • I have editied the output of systemctl status systemd-resolved – Ninja Dude Feb 18 '20 at 01:25
  • Looks like resolved service is shut down by unknown reason. Can you update journalctl -u systemd-resolved output to your question, not comments? – alfred Feb 18 '20 at 02:31

4 Answers4

2

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.

Kevin Bowen
  • 19,615
  • 55
  • 79
  • 83
0

Have you tried to change the DNS server to some different server, Like google DNS 8.8.8.8 8.8.4.4 and see the problems still happened?

To change the DNS server permanently DNS set to systemd's 127.0.0.53 - how to change permanently?

Tejas Lotlikar
  • 2,945
  • 5
  • 17
  • 26
  • I have tried to edit /run/systemd/resolve/stub-resolv.conf and changed it to 8.8.8.8 but i still encounter the issue. I am getting my ip via dhcp – Ninja Dude Feb 14 '20 at 09:24
  • Are there others device like your phone ...etc occur the same problems or just ubuntu ? – Lê Minh Quân Feb 14 '20 at 09:37
0

I remember having same issue caused by NetworkMonitor that override my DNS settings and crashed resolved.

So what to do here is:

grep resolved /var/log/syslog

Also you can try to see any error reports

grep error /var/log/syslog

The last command may return a bunch of lines so sort it out. If you'll find something pleas post it here.

As a variant, you can set NetworkMonitor to just ignore DNS altogether from DHCP and use a manually defined entirely.

Credit goes to lauc.exon.nod

Here is the command to modify an existing connection.

nmcli con mod <connectionName> ipv4.dns "8.8.8.8 8.8.4.4"

connectionName can be found by command: nmcli con. In the question case, it might be "System eth0"

If you want to ignore automatically configured nameservers and search domains, ie the settings passed from DHCP.

nmcli con mod <connectionName> ipv4.ignore-auto-dns yes

Finally, to enable the changes, bring the connection down then up:

nmcli con down <connectionName>
nmcli con up <connectionName>

Verify with cat /etc/resolv.conf. You should not edit /etc/resolv.conf manually as it is generated by NetworkManager service, it is likely to get overridden at any given time.

Kaim
  • 71
0

Check out launchpad bugs 1727237,1805027,1804487. After an NXDOMAIN error (check your dmesg output), the DNS resolution falls back to a more limited UDP based protocol, and may randomly fail on well-known names. The workaround which worked for me was to add the libnss-resolve package, which altered the /etc/nsswitch.conf hosts line to better handle certain queries.

ubfan1
  • 17,838