Preface
When using Ubuntu, you sometimes encounter an error of "Cannot resolve domain name". This is usually due to DNS configuration issues, unstable network connections, or unavailable mirror sources. This article will explain in detail how to solve this problem.
1. Check the network connection
First, make sure your network connection is normal. You can check the network status by following the command:
ping -c 4
If you can receive a reply normally, it means there is no problem with the network connection. If you cannot connect, please check your network settings.
2. Change DNS settings
If the network connection is normal but the domain name is still not resolved, you can try changing the DNS server. Use the following steps to change DNS settings:
2.1 Edit /etc/
Open the terminal and edit with a text editor/etc/
document:
sudo nano /etc/
Add or modify the following content in the file:
nameserver 8.8.8.8 nameserver 8.8.4.4
This will use Google's public DNS server. Save and exit (in nano, pressCtrl + X
, and then pressY
Confirm to save).
2.2 Permanently save DNS settings (optional)
Ubuntu may reset after restart/etc/
. You can install it using the following commandresolvconf
to ensure that the DNS settings remain unchanged:
sudo apt install resolvconf
Then edit/etc/resolvconf//head
document:
sudo nano /etc/resolvconf//head
Add the following:
nameserver 8.8.8.8 nameserver 8.8.4.4
Save and exit, and update the configuration:
sudo resolvconf -u
3. Change the software source
If the problem remains the same, it may be due to the problem with the source server. You can try changing the software source.
3.1 Edit the software source list
Open the software source list file:
sudo nano /etc/apt/
Put the original oneReplace with other available mirror sources, such as:
- Alibaba Cloud Mirror Source:
deb /ubuntu/ focal main restricted universe multiverse deb /ubuntu/ focal-updates main restricted universe multiverse deb /ubuntu/ focal-security main restricted universe multiverse deb /ubuntu/ focal-backports main restricted universe multiverse
- Tsinghua University mirror source:
deb /ubuntu/ focal main restricted universe multiverse deb /ubuntu/ focal-updates main restricted universe multiverse deb /ubuntu/ focal-security main restricted universe multiverse
3.2 Update the package list
After saving and exiting the editor, update the package list:
sudo apt update
4. Restart the network service
If the modification still fails to resolve, try restarting the network service:
sudo systemctl restart NetworkManager
5. Other solutions
If none of the above methods solve the problem, you can consider:
- Check router settings to make sure the DNS server is configured correctly.
- Restarting the computer, sometimes restarting can solve some network problems.
- Try using other networks, such as mobile phone hotspots, to verify that it is a network problem.
6. Conclusion
Through the above steps, the problem of "cannot resolve domain names" should be solved. If the problem persists, consider further troubleshooting the network connection or seeking professional help. Hope this article can help you solve the problem smoothly.
This is the article about the solution to the problem of "cannot resolve domain names" in Ubuntu. For more related contents of Ubuntu, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!