Article directory
background introduction
I recently bought a Dell workstation and built an Ubuntu 20.04 system. When I used it, I found that the Ubuntu 20.04 system often freezes when accessing the Internet (the Internet access method is a wired network, and I use a Gigabit Ethernet port and a Gigabit network cable).
I used a network speed test tool speedtest-cli
to conduct a test, and the effect was not satisfactory (it is very good when it is good, and it is particularly bad when it is not); when using it, it ping www.baidu.com
often prompts that the domain name cannot be resolved temporarily.
Try the solution:
- Change the Gigabit Ethernet cable and use the Gigabit Ethernet port: it doesn’t work, and the problem of internet lag still exists.
- Turn off IPv6: According to online information, the Ubuntu system freezes because IPV6 is enabled. After I turn off IPV6, the network speed does not change much. It should be invalid. At least the problem of Internet freezes still exists.
- Configure DNS: Try to modify DNS resolution, refer to the article: Reasons why ubuntu often disconnects, drops, and cannot access the Internet , but finds that the configuration file does not take effect. After the modification, restart the computer and restore the original DNS configuration.
After consulting a lot of information, my judgment is that the problem is still in DNS resolution. Therefore, follow the idea of configuring DNS resolution to make DNS resolution effective.
solution
1) Back up the original /etc/resolv.conf file:
cd /etc/
sudo mv resolv.conf resolv.conf.bak # 将原有的resolv.conf文件,备份为resolv.conf.bak文件
2) Modify the /etc/systemd/resolved.conf file, and add the IP address resolved by DNS to the content of the file:
sudo vim /etc/systemd/resolved.conf # 使用sudo获取最高权限,使用vim编辑/etc/systemd/目录下的resolved.conf配置文件
3) Add DNS content:
Change #DNS to: DNS=114.114.114.114 8.8.8.8, note that two DNS-analyzed IP addresses are added here, namely 114.114.114.114
and 8.8.8.8
, and the two IP addresses are separated by spaces.
#DNS
DNS=114.114.114.114 8.8.8.8
4) Create a soft link:
sudo ln -s /run/systemd/resolve/resolv.conf /etc/ # 相当于建了一个快捷方式
5) Restart the service:
systemctl restart systemd-resolved.service;