Ubuntu 14.04 中的 DNS 问题

Ubuntu 14.04 中的 DNS 问题

我在 Ubuntu 14.04.2 LTS trusty 中有时会遇到 DNS 解析问题。

我已经使用网络管理器配置了系统,使其能够使用静态 IP 分配。我也尝试过更改 DNS 服务器地址,但当出现此问题时,我无法通过 URL 访问任何网站,只能通过 IP 访问。

在遇到这个问题时,我尝试过

  • 停止 dnsmasq 服务
  • 删除 dnsmasq
  • 重启网络服务
  • 重启网络管理器
  • nslookup 到 google、yahoo 等域名

转储脚本的输出

###### Start of debugging information for resolvconf ######
### ls -l /etc/resolvconf
total 16
-rw-r--r-- 1 root root  172 Dec 13  2012 interface-order
drwxr-xr-x 2 root root 4096 May 21 11:02 resolv.conf.d
drwxr-xr-x 2 root root 4096 May 21 10:57 update.d
drwxr-xr-x 2 root root 4096 Jul 23  2014 update-libc.d
### cat /etc/resolvconf/interface-order
# interface-order(5)
lo.inet*
lo.dnsmasq
lo.pdnsd
lo.!(pdns|pdns-recursor)
lo
tun*
tap*
hso*
em+([0-9])?(_+([0-9]))*
p+([0-9])p+([0-9])?(_+([0-9]))*
eth*
ath*
wlan*
ppp*
*
### ls -l /etc/resolvconf/resolv.conf.d
total 8
-rw-r--r-- 1 root root   1 May 19 10:08 base
-rw-r--r-- 1 root root 151 Dec 13  2012 head
### cat /etc/resolvconf/resolv.conf.d/base

### cat /etc/resolvconf/resolv.conf.d/head
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
### ls -l /etc/resolvconf/run
ls: cannot access /etc/resolvconf/run: No such file or directory
### ls -l /run/resolvconf
total 4
-rw-r--r-- 1 root root   0 Jun 10 12:41 enable-updates
drwxr-xr-x 2 root root  60 Jun 10 12:42 interface
-rw-r--r-- 1 root root 170 Jun 10 12:42 resolv.conf
### cat /run/resolvconf/enable-updates
### cat /run/resolvconf/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
### ls -l /run/resolvconf/interface
total 4
-rw-r--r-- 1 root root 19 Jun 10 12:42 NetworkManager
### cat /run/resolvconf/interface/NetworkManager
nameserver 8.8.8.8
### ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 29 May 21 11:09 /etc/resolv.conf -> ../run/resolvconf/resolv.conf
### lsattr /etc/resolv.conf
lsattr: Operation not supported While reading flags on /etc/resolv.conf
### cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
### cat /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile,ofono
#dns=dnsmasq

no-auto-default=E0:69:95:AB:91:5A,

[ifupdown]
managed=false
###### End of debugging information for resolvconf ######

我无法通过执行所有这些操作来解决问题。但唯一的解决方案是重新启动我的计算机。

请帮助我,因为它会因重新启动系统和随时失去连接而完全卡住我的整个工作。

非常感谢您的帮助。

凯文。

答案1

我按照以下步骤操作,我的问题解决了。

  • 删除 dnsmasq:

    apt-get remove --purge dnsmasq
    
  • dns=dnsmasq通过输入#来注释掉/etc/NetworkManager/NetworkManager.conf

  • 注释掉本地DNS地址。

  • prepend domain-name-servers 127.0.0.1;通过输入#进行注释/etc/dhcp/dhclient.conf

  • 更新resolvconf

    resolvconf -u
    
  • 重新开始network-manager 或者重启系统:

    service network-manager restart
    

答案2

尝试这个

注释掉/etc/NetworkManager/NetworkManager.conf以下行dns=dnsmasq

sudo nano /etc/NetworkManager/NetworkManager.conf

[main]
plugins=ifupdown,keyfile,ofono
#dns=dnsmasq

并重新启动 NetworkManager 服务。

sudo restart network-manager

然后

sudo rm -f /etc/resolv.conf  # Delete the symbolic link

sudo nano /etc/resolv.conf

    # Content of static resolv.conf
    nameserver 8.8.4.4
    nameserver 8.8.8.8

这样你的电脑将无需dnsmasqDNS 服务器即可解析名称/etc/resolv.conf

相关内容