winstonsee / huhamhire-hosts

Automatically exported from code.google.com/p/huhamhire-hosts
GNU General Public License v3.0
0 stars 0 forks source link

IPv6 的 localhost 记录导致系统域名解析发生问题 #116

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
您使用的hosts文件版本:1.4.4
您使用的操作系统:Linux/Fedora 19
网络环境(IPv4/IPv6):WLan=IPv4+IPv6, Loopback=IPv4

有关问题的其他描述:

数据库中的如下记录

::1 localhost ip6-localhost ip6-loopback

将导致 localhost 被解析至 ::1 而不是 127.0.0.1 由于配置了 
/etc/hosts 记录,在没有指定 getaddrinfo 
参数的情况下所有程序将得到非预期的结果。

经查证, Fedora 自带的 hosts 文件配置对 ::1 是如下的定义

::1 localhost6

请求更详细的调查

Original issue reported on code.google.com by ImAndr...@gmail.com on 19 Feb 2014 at 4:48

GoogleCodeExporter commented 9 years ago
应该是目前的设置还不够全面,确实在 IPv6 的 hosts 
中没有加入 localhost6 的指向,后续会考虑进行修正 :-)

建议现在可以尝试使用自定义 hosts 
模块的方式来添加这一条目,可以参考:
https://hosts.huhamhire.com/viewpost-591.html
以及开发文档中的:
https://hosts.huhamhire.com/document/intro.html#user-customized-hosts

BTW,问下有尝试过启用 IPv6 的回环网卡吗?

感谢您的反馈

Original comment by hujunx...@gmail.com on 20 Feb 2014 at 1:41

GoogleCodeExporter commented 9 years ago
可能需要修正当前已有的记录

::1 localhost ip6-localhost ip6-loopback

到

::1 localhost6 ip6-localhost ip6-loopback

因为 ::1 localhost ip6-localhost ip6-loopback 覆盖了 127.0.0.1 localhost 
的记录……

Original comment by ImAndr...@gmail.com on 20 Feb 2014 at 7:58

GoogleCodeExporter commented 9 years ago
Debian 下的写法是:
127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
我考虑在目前的方案上增加一条:
127.0.0.1       localhost
hosts 文件会自动自上而下进行正确索引

Original comment by hujunx...@gmail.com on 20 Feb 2014 at 8:12

GoogleCodeExporter commented 9 years ago
查了一下

::1             localhost ip6-localhost ip6-loopback

确实是从 Debian 来的(不过貌似只是说 IPv6 Capable 
的条件)所以能不能把这块也独立出一个分类~

Original comment by ImAndr...@gmail.com on 20 Feb 2014 at 8:17

GoogleCodeExporter commented 9 years ago
如果可以通过在目前 localhost 条目的上方增加:

127.0.0.1       localhost

来解决这个问题的话,可能暂时不会考虑将其独立作为一个��
�类。毕竟 Fedora 这只是 Red Hat 
体系下的一个发行版而已,如果要针对每一个 Linux 
发行版定制的话会非常麻烦。

后续应该还是以优先考虑可以在各发行版下兼容的方案为主��
�

Original comment by hujunx...@gmail.com on 20 Feb 2014 at 8:29

GoogleCodeExporter commented 9 years ago
是不是应该让程序保留发行版自己生成的记录,而不再去产��
�一份另外的记录呢?

Original comment by ImAndr...@gmail.com on 20 Feb 2014 at 8:37

GoogleCodeExporter commented 9 years ago
这样也是一个办法,而且可以解决部分情况下的文件权限变��
�问题。

目前采用的先生成独立文件,后覆盖的方案,主要是为了防��
�在程序修改 hosts 
文件过程中出现问题后,可能会对产生不可预知的影响。

如果是保留原有 hosts 
中的内容,必须要解决原有条目的去留问题。全部保留的话��
�无法实现 hosts 
的更新功能,筛选不合理的话还不如使用直接生成一份 hosts 
文件的方案。

也许考虑将用户自定义内容进一步提高优先级是个可操作的��
�法

Original comment by hujunx...@gmail.com on 20 Feb 2014 at 8:47

GoogleCodeExporter commented 9 years ago
在需要更新的 Section 
上留个标记就好了?【好像还没有这种惯例的样纸】

Original comment by ImAndr...@gmail.com on 20 Feb 2014 at 8:52

GoogleCodeExporter commented 9 years ago
仅仅根据 Section 
来判断,应该不能处理所有的特殊情况~~如果后面要这么干的
话需要找一个更加完美的解决方案

Original comment by hujunx...@gmail.com on 20 Feb 2014 at 9:00