127.0.0.1和127.0.1.1有什么不同?

2,512 views
Skip to first unread message

Xi Shen

unread,
Nov 10, 2011, 9:38:55 PM11/10/11
to Shanghai Linux User Group
Hi,

Ubuntu 11.10安装后,在/etc/hosts里有两条记录:
localhost 127.0.0.1
mybox 127.0.1.1

为什么要这样配置呢?安全需要?


--
Regards,
David Shen

http://about.me/davidshen
https://twitter.com/#!/davidshen84

juju

unread,
Nov 10, 2011, 11:30:22 PM11/10/11
to sh...@googlegroups.com
于 2011/11/11 10:38, Xi Shen 写道:
> Hi,
>
> Ubuntu 11.10安装后,在/etc/hosts里有两条记录:
> localhost 127.0.0.1
> mybox 127.0.1.1
>
> 为什么要这样配置呢?安全需要?
>
>
虽然都是本地回环地址,但程序不是监听0.0.0.0而是127.0.0.1或者127.0.1.1即
只监听一个ip地址,那么就有用了

Xi Shen

unread,
Nov 10, 2011, 11:48:37 PM11/10/11
to sh...@googlegroups.com
我替这个问题是因为我在启动hbase standalone的时候出现connection
refused的错误。原因是zookeeper是用我的机器名mybox。把两个ip都配置成127.0.0.1就没这个问题。

出现connection refuse错误,感觉是放火墙的问题。但是如果两个都是本地回路,防火墙应该不会影响啊。


2011/11/11 juju <juju...@jujusoft.net>:

--

Marlon Yao

unread,
Nov 11, 2011, 8:13:02 AM11/11/11
to sh...@googlegroups.com
我觉得配置成两个IP地址没什么原因,至少archlinux就将主机名和localhost都映射到127.0.0.1上。主机名是必须要映射的,archlinux的文档是这么说的:
https://wiki.archlinux.org/index.php/Beginners'_Guide

Add your hostname, coinciding with the one specified in /etc/rc.conf, as an alias, so that it looks like this:

127.0.0.1   localhost.localdomain   localhost yourhostname
Warning: This format, including the "localhost" and your actual host name, is required for program compatibility! So, if you have named your computer "arch", then that line above should look like this:
127.0.0.1   localhost.localdomain   localhost arch
Errors in this entry may cause poor network performance and/or certain programs to open very slowly, or not work at all. This is a very common error for beginners.

至于你的问题,可能是因为服务器只在127.0.0.1监听,而使用mybox时反向解析成127.0.1.1,所以连不上。

2011/11/11 Xi Shen <david...@gmail.com>

Xi Shen

unread,
Nov 11, 2011, 8:21:08 AM11/11/11
to sh...@googlegroups.com

这样的话可能是我配置的问题。我用的是默认配置。hbase启动时默认监听127.0.0.1,然后取得我的机器名后,又用我的机器名访问服务。

谢谢。

Regards,
David Shen

weibin li

unread,
Nov 14, 2011, 9:29:52 AM11/14/11
to sh...@googlegroups.com
hosts文件是主机名别名文件吧?用来做提供主机名和ip地址的映射作用? 好像么有什么特别大的用途,有了DNS,很少关注hosts文件了,因为我在/etc/host.conf中 配置的顺序是order  bind,hosts

2011/11/11 Xi Shen <david...@gmail.com>



--
-----------------------------------------------------------
Shanghai Linux User Group
Jacky.Li    
-----------------------------------------------------------

Reply all
Reply to author
Forward
0 new messages