问题描述:
系统:ubuntu 19.10
发现问题:装好系统后wifi没有问题,大概一个月后wifi抽风了,顶部栏wifi图标变成了一个问号,如果这样能用也好。但是不能打开网页,百度都打不开。在终端里面Ping了一下百度,有时能Ping通,但丢包严重;再者根本就Ping不通,错误提示:Temporary failure in name resolution,域名解析失败。然后百度,发现了一篇文章,虽然没有从这个文章直接解决,但一个评论帮我解决了这个问题。从这个评论中得到三个链接:🔗1,🔗2,🔗3;
- 链接1解决了问题,说明了:ubuntu默认安装的DNS解析工具systemd-resolved存在的问题,以及它的替代者:unbound
- 链接2说明wifi问号是一个bug
- 链接3说明wifi问号问题不仅仅在ubuntu,其它linux发行版也存在。
解决方法:
Step1:安装unbound:
sudo apt-get install unbound
如果系统域名解析失败或不能成功联网,可以在/etc/resolv.conf 文件中指定一个DNS,可以用114.114.114.114;
具体步骤:
1 sudo vim /etc/resolv.conf
2 删除文件中的内容,添加一行:nameserver 114.114.114.114
Step2:禁用默认的域名解析工具systemd-resolved并停止正在运行着的程序
1 sudo systemctl disable systemd-resolved.service
2 sudo systemctl stop systemd-resolved.service
Step3:配置NetworkManager使其使用unbound作为系统的域名解析工具
打开/etc/NetworkManager/NetworkManager.conf加入一行如下图:
紧跟plugins=…下面一行加上dns=unbound.
Step4:启用新安装的域名解析工具unbound,并配置其配置文件
虽然安装后默认启用,但为了以防万一,手动启用:
1 sudo systemctl enable unbound-resolvconf
2 sudo systemctl enable unbound
3 sudo vim /etc/unbound/unbound.conf,在其配置文件追加以下manual中的示例配置文件内容,man unbound.conf 查看其manual页
directory:"/etc/unbound"
username: unbound
# make sure unbound can access entropy from inside the chroot.
# e.g. on linux the use these commands (on BSD, devfs(8) is used):
# mount --bind -n /dev/random /etc/unbound/dev/random
# and mount --bind -n /dev/log /etc/unbound/dev/log
chroot: "/etc/unbound"
# logfile: "/etc/unbound/unbound.log" #uncomment to use logfile.
pidfile: "/etc/unbound/unbound.pid"
# verbosity: 1 # uncomment and increase to get more logging.
# listen on all interfaces, answer queries from the local subnet.
interface: 0.0.0.0
interface: ::0
access-control: 10.0.0.0/8 allow #允许网卡通过哪个网段的流量,根据需要填写。
Step5:配置DNS,从manual页查看配置,man unbound
从man的结果看,要使用本机的unbound程序来做域名解析,需要在/etc/resolv.conf中加入一行:nameserver 127.0.0.1;接下来sudo vim /etc/resolv.conf,加进去进行了。但是在/etc/resolv.conf中所做的编辑会在重启机器后被覆盖。打开resolv.conf:
得知resolv.conf由resolvconf程序产生,我们可以查看resolvconf的manual页,man 8 resolvconf:
从resolvconf的manual页中找到/etc/resolvconf/resolvconf.d/tail文件,加入它里面的内容会被追加到/etc/resolv.conf文件中,因此我们需要编辑的是/etc/resolvconf/resolvconf.d/tail文件,在其中加入DNS的键值对:nameserver 127.0.0.1; Note: 在实际测试时发现只加入127.0.0.1会有一定几率不起作用,因此我们需要再加入至少一个能用的DNS,我搜集了以下:
- 腾讯的公用免费DNS: 119.29.29.29(首选)、182.254.116.116(备选)
- 阿里的公用免费DNS: 233.5.5.5(首选)、233.6.6.6(备选)
- 国内移动、电信和联通通用的公用免费DNS: 114.114.114.114
- Cloudflare的公用免费DNS: 1.1.1.1(首选)、1.0.0.1(备选)
Step6:重启系统使更改生效
sudo init 6
Note: 如果重启系统后发现搜索不到wifi,重启network-manager服务
sudo systemctl restart network-manager.service
问题描述:
系统:ubuntu 19.10
发现问题:装好系统后wifi没有问题,大概一个月后wifi抽风了,顶部栏wifi图标变成了一个问号,如果这样能用也好。但是不能打开网页,百度都打不开。在终端里面Ping了一下百度,有时能Ping通,但丢包严重;再者根本就Ping不通,错误提示:Temporary failure in name resolution,域名解析失败。然后百度,发现了一篇文章,虽然没有从这个文章直接解决,但一个评论帮我解决了这个问题。从这个评论中得到三个链接:🔗1,🔗2,🔗3;
- 链接1解决了问题,说明了:ubuntu默认安装的DNS解析工具systemd-resolved存在的问题,以及它的替代者:unbound
- 链接2说明wifi问号是一个bug
- 链接3说明wifi问号问题不仅仅在ubuntu,其它linux发行版也存在。
解决方法:
Step1:安装unbound:
sudo apt-get install unbound
如果系统域名解析失败或不能成功联网,可以在/etc/resolv.conf 文件中指定一个DNS,可以用114.114.114.114;
具体步骤:
1 sudo vim /etc/resolv.conf
2 删除文件中的内容,添加一行:nameserver 114.114.114.114
Step2:禁用默认的域名解析工具systemd-resolved并停止正在运行着的程序
1 sudo systemctl disable systemd-resolved.service
2 sudo systemctl stop systemd-resolved.service
Step3:配置NetworkManager使其使用unbound作为系统的域名解析工具
打开/etc/NetworkManager/NetworkManager.conf加入一行如下图:
紧跟plugins=…下面一行加上dns=unbound.
Step4:启用新安装的域名解析工具unbound,并配置其配置文件
虽然安装后默认启用,但为了以防万一,手动启用:
1 sudo systemctl enable unbound-resolvconf
2 sudo systemctl enable unbound
3 sudo vim /etc/unbound/unbound.conf,在其配置文件追加以下manual中的示例配置文件内容,man unbound.conf 查看其manual页
directory:"/etc/unbound"
username: unbound
# make sure unbound can access entropy from inside the chroot.
# e.g. on linux the use these commands (on BSD, devfs(8) is used):
# mount --bind -n /dev/random /etc/unbound/dev/random
# and mount --bind -n /dev/log /etc/unbound/dev/log
chroot: "/etc/unbound"
# logfile: "/etc/unbound/unbound.log" #uncomment to use logfile.
pidfile: "/etc/unbound/unbound.pid"
# verbosity: 1 # uncomment and increase to get more logging.
# listen on all interfaces, answer queries from the local subnet.
interface: 0.0.0.0
interface: ::0
access-control: 10.0.0.0/8 allow #允许网卡通过哪个网段的流量,根据需要填写。
Step5:配置DNS,从manual页查看配置,man unbound
从man的结果看,要使用本机的unbound程序来做域名解析,需要在/etc/resolv.conf中加入一行:nameserver 127.0.0.1;接下来sudo vim /etc/resolv.conf,加进去进行了。但是在/etc/resolv.conf中所做的编辑会在重启机器后被覆盖。打开resolv.conf:
得知resolv.conf由resolvconf程序产生,我们可以查看resolvconf的manual页,man 8 resolvconf:
从resolvconf的manual页中找到/etc/resolvconf/resolvconf.d/tail文件,加入它里面的内容会被追加到/etc/resolv.conf文件中,因此我们需要编辑的是/etc/resolvconf/resolvconf.d/tail文件,在其中加入DNS的键值对:nameserver 127.0.0.1; Note: 在实际测试时发现只加入127.0.0.1会有一定几率不起作用,因此我们需要再加入至少一个能用的DNS,我搜集了以下:
- 腾讯的公用免费DNS: 119.29.29.29(首选)、182.254.116.116(备选)
- 阿里的公用免费DNS: 233.5.5.5(首选)、233.6.6.6(备选)
- 国内移动、电信和联通通用的公用免费DNS: 114.114.114.114
- Cloudflare的公用免费DNS: 1.1.1.1(首选)、1.0.0.1(备选)