ubuntu无法解析域名的问题

包含网卡/无线网的网络问题和ADSL/校园网/宽带拨号支持及代理/共享等网络使用问题
winecoding
帖子: 10
注册时间: 2016-06-06 12:38
系统: windows

ubuntu无法解析域名的问题

#1

帖子 winecoding »

在lab top上装了 ubuntu 16。04 安装过程一切正常。 也连上了 家里的wireless, 直接 ping IP address都是work的, 譬如 ping 8.
8.8.8 但 ping google.com 就不work了.

代码: 全选

>nslookup www.google.com
;; connection timed out; no servers could be reached

>ping www.cnn.com
ping : unknown host www.cnn.com
Google 了很多solution,主要都是为了改/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
      nameserver 127.0.1.1
cao627
帖子: 992
注册时间: 2007-12-05 10:57
系统: ubuntu14.04
来自: 金山

Re: ubuntu无法解析域名的问题

#2

帖子 cao627 »

Nameserver N改小写。
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: ubuntu无法解析域名的问题

#3

帖子 poloshiao »

把下面指令 複製 貼進終端機 執行
1. sudo ls -al /etc | grep resolv.conf
2. sudo cat /etc/resolvconf/resolv.conf.d/head
把結果全部直接 選取/複製/貼上來
winecoding
帖子: 10
注册时间: 2016-06-06 12:38
系统: windows

Re: ubuntu无法解析域名的问题

#4

帖子 winecoding »

这是这些命令的输出,谢谢

代码: 全选

[b]sudo ls -al /etc |grep resolv.conf[/b]
lrwxrwxrwx   1 root root      29 Jun  5 18:55 resolv.conf -> ../run/resolvconf/resolv.conf

[b]sudo  cat /etc/resolvconf/resolv.conf.d/head[/b]
# 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


[b] sudo cat /etc/resolv.conf[/b]
# 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
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 68.94.156.1
nameserver 68.94.157.1

poloshiao 写了:把下面指令 複製 貼進終端機 執行
1. sudo ls -al /etc | grep resolv.conf
2. sudo cat /etc/resolvconf/resolv.conf.d/head
把結果全部直接 選取/複製/貼上來
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: ubuntu无法解析域名的问题

#5

帖子 poloshiao »

sudo ls -al /etc |grep resolv.conf
lrwxrwxrwx 1 root root 29 Jun 5 18:55 resolv.conf -> ../run/resolvconf/resolv.conf
1. /etc/resolv.conf 的內容 實際上 就是 /run/resolvconf/resolv.conf 的內容
sudo 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
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 68.94.156.1
nameserver 68.94.157.1
2. 在 /etc/resolv.conf 編輯內容 就是 編輯 /run/resolvconf/resolv.conf 的內容
sudo 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
3. 目前沒有有效的內容

4. 每次重新開機 都會讀取 許多網路設定檔內容 用來重新更新 /run/resolvconf/resolv.conf 的內容 也就是 /etc/resolv.conf 的內容
4-1. 其中 包含讀取 /etc/resolvconf/resolv.conf.d/head 的內容

5. 意思是
5-1. 編輯 /etc/resolv.conf 只有一次性有效 重開機就無效了
5-2. 要重開機還有效 需要把
nameserver 127.0.1.1
nameserver 68.94.156.1
nameserver 8.8.8.8
加到
/etc/resolvconf/resolv.conf.d/head
再重開機
5-3. /etc/resolv.conf 的 nameserver 最好限於 3 個以內
第 4 個以後的 nameserver 被讀取的機會比較小
5-4. nameserver 127.0.1.1
最好排在第一個
winecoding
帖子: 10
注册时间: 2016-06-06 12:38
系统: windows

Re: ubuntu无法解析域名的问题

#6

帖子 winecoding »

谢谢你的帮助。 我按照你的建议重新做了一遍,

代码: 全选

sudo cat /etc/resolvconf/resolv.conf/head[/b]
# 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 127.0.1.1
nameserver 8.8.8.8
nameserver 68.94.156.1
但是

代码: 全选

ping google.com
后的结果仍然是

代码: 全选

ping: unknown host google.com
请帮忙再看看。还需要系统的什么信息。
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: ubuntu无法解析域名的问题

#7

帖子 poloshiao »

試試
ping -c 3 forum.ubuntu.org.cn
ping google.com
在大陸 有些域名無法 ping
nameserver 127.0.1.1
nameserver 8.8.8.8
nameserver 68.94.156.1
修正為
nameserver 127.0.1.1
nameserver 68.94.156.1
nameserver 8.8.8.8
winecoding
帖子: 10
注册时间: 2016-06-06 12:38
系统: windows

Re: ubuntu无法解析域名的问题

#8

帖子 winecoding »

我不在大陆,所以应该不是这方面的问题

代码: 全选

ping -c 3  forum.ubuntu.org.cn
ping: unknown host forum.ubuntu.org.cn
winecoding
帖子: 10
注册时间: 2016-06-06 12:38
系统: windows

Re: ubuntu无法解析域名的问题

#9

帖子 winecoding »

我又把这几个命令run了一遍, 很奇怪, 为什麽/etc/resolv.conf最后会有一个多出来的

代码: 全选

nameserver 8.8.8.8

代码: 全选

[b]cat /etc/resolvconf/resolv.conf.d/head[/b]
# 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 127.0.1.1
nameserver 68.94.156.1
nameserver 8.8.8.8

[b]cat /etc/resolvconf/resolv.conf.d/tail[/b]

[b]cat /etc/resolvconf/resolv.conf.d/base 
[/b]
[b]cat /etc/resolv.conf[/b]
# 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 127.0.1.1
nameserver 68.94.156.1
nameserver 8.8.8.8

nameserver 8.8.8.8
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: ubuntu无法解析域名的问题

#10

帖子 poloshiao »

我不在大陆,
ping -c 3 forum.ubuntu.org.cn
ping: unknown host forum.ubuntu.org.cn
1. 把下面指令 複製 貼進終端機 執行
ping -c 3 192.157.242.155
把下面指令 複製 貼進終端機 執行
为什麽/etc/resolv.conf最后会有一个多出来的
nameserver 8.8.8.8
2. 可能你還在
NM-Applet

/etc/network/interfaces
或 其它地方 又設定了 8.8.8.8
2-1. 不過 多一個 影響不大
將來發現了 再移除即可
winecoding
帖子: 10
注册时间: 2016-06-06 12:38
系统: windows

Re: ubuntu无法解析域名的问题

#11

帖子 winecoding »

代码: 全选

ping -c 3 192.157.242.155
PING 192.157.242.155 (192.157.242.155) 56(84) bytes of data.

--- 192.157.242.155 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2017ms

nslookup 192.157.242.155
;; connection timed out; no servers could be reached

有趣的是, 我又试了一下

代码: 全选

ping google.com
发现它竟能工作

代码: 全选

PING google.com (216.58.194.206) 56(84) bytes of data.
64 bytes from 216.58.194.206: icmp_seq=2 ttl=52 time=70.6 ms
64 bytes from 216.58.194.206: icmp_seq=18 ttl=52 time=75.0 ms
64 bytes from 216.58.194.206: icmp_seq=21 ttl=52 time=67.4 ms
。 但把这个窗口关了, 再重新试, 就又不工作了

代码: 全选

ping google.com
ping: unknown host google.com
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: ubuntu无法解析域名的问题

#12

帖子 poloshiao »

ping -c 3 192.157.242.155
PING 192.157.242.155 (192.157.242.155) 56(84) bytes of data.
--- 192.157.242.155 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2017ms
nslookup 192.157.242.155
;; connection timed out; no servers could be reached
1. 如果這個一直不通 就表示網路硬件或軟件 還沒設定好
如果這個有時通有時不通 就表示網路硬件或軟件 不穩定
意思是 不是無法解析域名 引起的
有趣的是, 我又试了一下
ping google.com
发现它竟能工作
2. whois 216.58.194.206 | grep NetName
確認這個 IPv4 是屬於 google.com
但把这个窗口关了, 再重新试, 就又不工作了
3. 如果你是從右上方 NM-Applet 設定連線
重新安裝 network-manager 有關套件看看
3-1. 先看看 目前已經安裝哪些 network-manager 有關套件 ?
sudo dpkg -l | grep network-manager
3-2. 然後利用
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install --reinstall network-manager-套件名稱
重新安裝
3-2-1. 這的 network-manager-套件名稱 指 3-1 顯示的已安裝 network-manager 有關套件
3-3. 重新開機
winecoding
帖子: 10
注册时间: 2016-06-06 12:38
系统: windows

Re: ubuntu无法解析域名的问题

#13

帖子 winecoding »

代码: 全选

sudo apt-get update
没法完成,因为域名无法解析,

代码: 全选

Connecting to us.archive.ubuntu.com] [Connecting to security.ubuntu.com]
Err:1 http://us.archive.ubuntu.com/ubuntu xenial InRelease                  
  Temporary failure resolving 'us.archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu xenial-security InRelease           
  Temporary failure resolving 'security.ubuntu.com'
0% [Connecting to us.archive.ubuntu.com]

代码: 全选

whois
也不工作

代码: 全选

whois 216.58.194.206| grep NetName
The program 'whois' is currently not installed. You can install it by typing:
sudo apt install whois


sudo apt install whois

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package whois is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'whois' has no installation candidate

真不知道怎么办了
cao627
帖子: 992
注册时间: 2007-12-05 10:57
系统: ubuntu14.04
来自: 金山

Re: ubuntu无法解析域名的问题

#14

帖子 cao627 »

你说ping 8.8.8.8是通的
那么ping 8.8.8.8 看看丢包率是多少。可能是丢包率太高导致的。
上次由 cao627 在 2016-06-09 15:50,总共编辑 1 次。
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: ubuntu无法解析域名的问题

#15

帖子 poloshiao »

Connecting to us.archive.ubuntu.com] [Connecting to security.ubuntu.com]
Err:1 http://us.archive.ubuntu.com/ubuntu xenial InRelease
Temporary failure resolving 'us.archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu xenial-security InRelease
Temporary failure resolving 'security.ubuntu.com'
0% [Connecting to us.archive.ubuntu.com]
1. 使用文字編輯程式 打開 /etc/hosts
加上這一行
91.189.91.23 us.archive.ubuntu.com # 注意 中間空一格
1-1. 儲存
1-2. 然後
sudo apt-get update
看看 能否順利更新 還是出現其它錯誤訊息

2. 補充
2-1. 91.189.91.23 就是 us.archive.ubuntu.com 域名解析後的 IPv4
2-2. 換句話說 /etc/hosts 就是先在你本機內的 進行域名解析
找不到 才往外尋找 域名解析
2-2-1. 如果你已經知道某個域名解析後的 IPv4
依照 1 的方法 加在 /etc/hosts
你的本機就使用 /etc/hosts 來解析該域名 不會再往外尋找解析
回复