In this video, we troubleshoot DNS resolution issues on Ubuntu using basic terminal tools and configuration edits.
We explore:
/etc directory inspection
grep configuration checks
editing .conf files with nano
adding custom nameservers
restarting services
Sometimes, even after applying changes, errors like:
“Having trouble finding that site” or “Cannot connect to server” may still appear.
This happens because modern Ubuntu systems often use systemd-resolved or network managers that override manual DNS settings, meaning changes in .conf files may not always apply immediately or persist.
A system reboot can temporarily resolve the issue by reloading services and configurations correctly.
If the issue returns:
Check if systemd-resolved is active
Verify /etc/resolv.conf symlink behavior
Ensure no network manager is overriding DNS
Try setting DNS directly in NetworkManager settings
Understanding how DNS is handled internally is key to applying a consistent and stable fix.
Important Notes:
In modern Ubuntu versions (18.04 and later), DNS is managed by systemd-resolved and NetworkManager. This is why simply editing /etc/resolv.conf often fails: the system automatically overwrites your manual changes upon reboot or reconnection.
Here is how to diagnose and fix DNS issues once and for all:
1. Running a Quick Diagnosis
Before changing any files, check which DNS servers your system is actually using:
Command: resolvectl status
Look for "Current DNS Server" under your active interface (such as wlan0 or eth0).
2. The Quick Fix (Emergency Mode)
If you need to get back to work immediately and want to stop Ubuntu from overwriting your settings, use the immutability trick:
2.1. Edit the file: sudo nano /etc/resolv.conf
2.2. Add your preferred DNS: nameserver 8.8.8.8 (Google) or nameserver 1.1.1.1 (Cloudflare).
2.3. Lock the file so the system cannot touch it: sudo chattr +i /etc/resolv.conf
Note: If you ever need to edit it again, unlock it first with: sudo chattr -i /etc/resolv.conf
3. The Proper Way (Permanent Solutions)
For Desktop Users: Go to Settings and then Network, click the gear icon for your connection, go to the IPv4 tab, toggle Automatic DNS to OFF, and enter 8.8.8.8, 1.1.1.1. Click Apply and toggle the connection Off and then On.
For Server Users (Netplan): Edit your configuration file in /etc/netplan/*.yaml. Add the nameservers section under your interface and specify the addresses. Then apply the changes with: sudo netplan apply.
4. Clear the Cache
After any change, ensure your system is not using old, broken data by flushing the DNS cache:
Command: sudo resolvectl flush-caches
Pro Tip: If you see the error "Temporary failure in name resolution," your /etc/resolv.conf might be a broken symbolic link. Deleting the file and restarting the systemd-resolved service often recreates the correct link automatically.
Educational and informational content only.
#Ubuntu #DNS #Linux