zhjianfu / openerdns

Automatically exported from code.google.com/p/openerdns
0 stars 0 forks source link

使用后有的 Python 3 的程序会无法联网 #54

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
不敢说所有的 Python 3 
程序,不过我使用的几个都由出现这样的情况,它们来自不��
�的作者:

you-get https://github.com/soimort/you-get
pip2arch https://github.com/bluepeppers/pip2arch
pypi-cli https://github.com/sloria/pypi-cli

我的系统是 Arch Linux。

自己测试了一番,使用 urllib.request.open() 
方法打开一个地址,就会出现跟上述程序一样的错误,似乎��
�无法进行域名解释:

import urllib.request
res = urllib.request.urlopen('http://python.org/')

URLError                                  Traceback (most recent call last)
<ipython-input-2-173277cdc209> in <module>()
----> 1 res = urllib.request.urlopen('http://python.org/')

/usr/lib/python3.4/urllib/request.py in urlopen(url, data, timeout, cafile, 
capath, cadefault)
    151     else:
    152         opener = _opener
--> 153     return opener.open(url, data, timeout)
    154 
    155 def install_opener(opener):

/usr/lib/python3.4/urllib/request.py in open(self, fullurl, data, timeout)
    453             req = meth(req)
    454 
--> 455         response = self._open(req, data)
    456 
    457         # post-process response

/usr/lib/python3.4/urllib/request.py in _open(self, req, data)
    471         protocol = req.type
    472         result = self._call_chain(self.handle_open, protocol, protocol +
--> 473                                   '_open', req)
    474         if result:
    475             return result

/usr/lib/python3.4/urllib/request.py in _call_chain(self, chain, kind, 
meth_name, *args)
    431         for handler in handlers:
    432             func = getattr(handler, meth_name)
--> 433             result = func(*args)
    434             if result is not None:
    435                 return result

/usr/lib/python3.4/urllib/request.py in http_open(self, req)
   1213 
   1214     def http_open(self, req):
-> 1215         return self.do_open(http.client.HTTPConnection, req)
   1216 
   1217     http_request = AbstractHTTPHandler.do_request_

/usr/lib/python3.4/urllib/request.py in do_open(self, http_class, req, 
**http_conn_args)
   1190         except OSError as err: # timeout error
   1191             h.close()
-> 1192             raise URLError(err)
   1193         else:
   1194             r = h.getresponse()

URLError: <urlopen error [Errno -2] Name or service not known>

http://python.org/ 
这个地址在浏览器是可以打开的,如果换回其他的 DNS,比如 
Google 的这种情况就会消失。

Original issue reported on code.google.com by riverrin...@gmail.com on 23 Jun 2014 at 9:37

GoogleCodeExporter commented 9 years ago
额,发现不知是 Python 3,Python 2 也一样。。。。

Original comment by riverrin...@gmail.com on 23 Jun 2014 at 9:41

GoogleCodeExporter commented 9 years ago
能否抓取 udp 53端口的包,发过来看看,就清楚了。

Original comment by opene...@gmail.com on 25 Jun 2014 at 12:56

GoogleCodeExporter commented 9 years ago
请问是这样么?

sudo tcpdump -i enp2s0 -n udp dst port 53                             
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp2s0, link-type EN10MB (Ethernet), capture size 65535 bytes
12:52:54.288223 IP 172.18.194.64.50824 > 42.120.21.30.53: 20357+ A? python.org. 
(28)
12:52:54.288277 IP 172.18.194.64.50824 > 42.120.21.30.53: 26350+ AAAA? 
python.org. (28)
12:52:54.328500 IP 172.18.194.64.42747 > 42.120.21.30.53: 29267+ A? python.org. 
(28)
12:52:54.328555 IP 172.18.194.64.42747 > 42.120.21.30.53: 30676+ AAAA? 
python.org. (28)
12:53:46.680943 IP 172.18.194.64.52819 > 42.120.21.30.53: 27134+ A? 
pypi.python.org. (33)
12:53:46.680980 IP 172.18.194.64.52819 > 42.120.21.30.53: 50657+ AAAA? 
pypi.python.org. (33)
12:53:46.730310 IP 172.18.194.64.60022 > 42.120.21.30.53: 4146+ A? 
pypi.python.org. (33)
12:53:46.730364 IP 172.18.194.64.60022 > 42.120.21.30.53: 50076+ AAAA? 
pypi.python.org. (33)
^C
8 packets captured
8 packets received by filter
0 packets dropped by kernel

172.18.194.64 是我在内网(我是校园网)的ip,上面是我直接在 
python 里用 urllib 和 运行 pypi-cli https://github.com/sloria/pypi-cli 
时抓取的结果

Original comment by riverrin...@gmail.com on 27 Jun 2014 at 4:53

GoogleCodeExporter commented 9 years ago
这个是用
sudo tcpdump -i enp2s0 -n udp dst port 53 -w dns
保存的结果

Original comment by riverrin...@gmail.com on 27 Jun 2014 at 5:03

Attachments: