Name resolution fails but the network is up
Pings to an IP work and pings to a name do not. On systemd machines /etc/resolv.conf is often a symlink to a stub resolver, which changes where to look.
What you see
curl and apt fail with "Temporary failure in name resolution". `ping 1.1.1.1` works, `ping google.com` does not.
What is actually wrong
No nameserver configured, a stub resolver that has no upstream, a VPN or container that rewrote resolv.conf, or search domains resolving names to the wrong place.
Codes and articles
Fixes (2)
Fix systemd-resolved's upstream
resolv.conf points at 127.0.0.53. The real configuration is not in that file.
Ask resolved what it is actually using per interface.
resolvectl statusEditing /etc/resolv.conf on a resolved system is pointless — it is generated, and your edit is overwritten on the next network change. This command shows the configuration that matters.
Test resolution through the stub and directly, to separate the two.
resolvectl query example.comdig +short example.com @1.1.1.1
If the upstream is empty or wrong, set it on the interface.
sudo resolvectl dns eth0 10.0.0.10 10.0.0.11sudo resolvectl domain eth0 example.local
Make it permanent in the network configuration rather than at runtime. On Ubuntu with netplan:
sudo nano /etc/netplan/01-netcfg.yamlsudo netplan apply
Flush the cache and re-test.
sudo resolvectl flush-cachesgetent hosts example.com
Confirm the symlink is intact — a VPN client that replaced it with a static file causes intermittent failures.
ls -l /etc/resolv.conf
resolvectl status | grep -A3 'Current DNS'Repair a plain resolv.conf setup
The machine is not using the systemd stub.
Look at the current configuration and the resolution order.
cat /etc/resolv.confgrep '^hosts' /etc/nsswitch.conf
Test the nameserver directly to see whether it is the server or the client.
dig +short example.com @10.0.0.10dig +short example.com @1.1.1.1
Add a working nameserver.
printf 'nameserver 10.0.0.10\nnameserver 1.1.1.1\nsearch example.local\noptions timeout:2 attempts:2\n' | sudo tee /etc/resolv.confThe timeout and attempts options matter more than they look: the defaults are 5 seconds and 2 attempts per server, so one dead nameserver stalls every lookup for ten seconds.
Stop NetworkManager or dhclient overwriting it, if that is what keeps happening.
grep -r 'dns=' /etc/NetworkManager/NetworkManager.confMake it immutable only as a last resort, and remember you did.
sudo chattr +i /etc/resolv.confThis will confuse the next person badly, including you in six months. Prefer configuring the thing that rewrites the file.
getent hosts example.com && curl -sS -o /dev/null -w '%{http_code}\n' https://example.comRelated faults
Where this stops. This write-up was written and checked by hand. It says what each step changes, how to confirm it worked and how to reverse it, and anything destructive is flagged before you reach it. If it does not match what your machine is doing, search the Support Centre for the exact code or message — and when something needs a person, get in touch.