Solution:
If you can ping external IP addresses directly (like
ping 8.8.8.8) but
ping google.com returns "Temporary failure in name resolution" or "Name or service not known", your internet is fine, but your DNS resolver is broken.
Step 1: Check your Nameservers
In Linux, DNS servers are typically defined in the
resolv.conf file. Read it by running:
cat /etc/resolv.conf
Look for lines that say
nameserver [IP_Address]. If it is empty or points to a dead local IP, DNS will fail.
Step 2: The Quick Temporary Fix
You can manually add a reliable public DNS server to test.
1Edit the file (requires root): sudo nano /etc/resolv.conf
2Add this line at the top: nameserver 8.8.8.8
3Save and exit (Ctrl+O, Enter, Ctrl+X).
4Try ping google.com again.
Step 3: The Permanent Fix
Modern Linux systems overwrite
/etc/resolv.conf automatically using
systemd-resolved or
NetworkManager. If the temporary fix worked, you must configure the DNS permanently in your active network manager:
Ubuntu/Netplan: Edit /etc/netplan/*.yaml, add nameservers: addresses: [8.8.8.8, 1.1.1.1], then run sudo netplan apply.NetworkManager (GUI): Open nm-connection-editor, edit the connection, go to IPv4 Settings, and add DNS servers.systemd-resolved: Edit /etc/systemd/resolved.conf, uncomment DNS= and set it to DNS=8.8.8.8, then run sudo systemctl restart systemd-resolved.