【问题标题】:Localhost address in the Virtual Machine虚拟机中的 localhost 地址
【发布时间】:2012-06-05 09:38:40
【问题描述】:

我在服务器上使用虚拟机。 我的VM本地IP是192.168.1.10

我正在尝试实现一些需要我编辑此链接中提供的/etc/hosts 的东西

http://www.thatisjava.com/java-tech/55200/

我遇到了类似的问题,我的控制台显示

RTP--- :DataAddress: /192.168.1.10
ControlAddress: /192.168.1.10
DataPort: 42050
ControlPort: 42051
java.io.IOException: Local Data AddressDoes not belong to any of this hosts local interfaces
java.io.IOException: Local Data AddressDoes not belong to any of this hosts local interfaces
at org.speechforge.cairo.rtp.RTPConsumer.init(RTPConsumer.java:181)
    at org.speechforge.cairo.rtp.RTPConsumer.<init>(RTPConsumer.java:95)
    at org.speechforge.cairo.rtp.server.RTPStreamReplicator.<init>    (RTPStreamReplicator.java:69)

还有更多。

给出的问题的答案是

我解决了这个问题。问题是 JMF 似乎使用 InetAddress.getAllByName() 仅返回(至少在我的情况下) 单个 IP 地址,无论我在我的计算机上定义了多少个地址 接口。问题是通过放置我的 IP 地址来解决的 想要由会话管理器使用到 /etc/hosts 中。应该是第一个 在 /etc/hosts 中的行,否则使用匹配的另一行。

很遗憾,我无法理解他想要表达的意思。我的/etc/hosts阅读

127.0.0.1    localhost
127.0.1.1       SparkVM104

所以我应该用我的192.168.1.10 更改127.0.0.1

或者我应该创建一个像127.0.0.1/192.168.1.10这样的别名

或者我应该将192.168.1.10 粘贴到顶部作为

192.168.1.10
127.0.0.1    localhost
127.0.1.1       SparkVM104

感谢任何帮助。

问候。

【问题讨论】:

    标签: java linux networking jmf


    【解决方案1】:

    /etc/hosts 的格式是

    IP_address canonical_hostname [aliases...]
    

    (请参阅http://linux.die.net/man/5/hosts),因此要首先列出 192.168.1.10,/etc/hosts 文件必须如下所示:

    192.168.1.10    SomeHostName    SomeOtherHostName
    127.0.0.1       localhost    
    

    【讨论】:

    • 您的推荐与您的引用不一致。
    • 引用中的示例显示localhost 映射到127.0.0.1,外部主机名映射到外部IP 地址。这是有效的配置。你的不会。
    • 我重新阅读了手册页,但没有找到明确声明禁止对回送接口使用别名的段落。它实际上适用于 Ubuntu 11.10 和 MacOS X 10.7。尽管如此,我还是更改了示例,因为我明白您的观点,并且希望能提供指向讨论该问题的某种文档或 RFC 的指针。快速的 Google 搜索不是很成功。
    【解决方案2】:

    在 /etc/hosts 中,localhost 应该映射到 127.0.0.1 而不是其他任何东西,而您的外部主机名应该映射到您的外部 IP 地址而不是其他任何东西。一些 Linux 发行版被声明违反了这条规则,它破坏了一切。

    【讨论】:

      猜你喜欢
      • 2010-11-18
      • 2021-10-26
      • 1970-01-01
      • 2011-08-20
      • 1970-01-01
      • 2011-01-11
      • 2018-07-09
      • 2020-07-13
      • 2012-09-14
      相关资源
      最近更新 更多