虚拟机中的本地主机地址

时间:2012-06-05 09:38:41

标签: java linux networking jmf

我在服务器上使用虚拟机。 我的本地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

我应该使用127.0.0.1

更改192.168.1.10

或者我应该创建一个像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

感谢任何帮助。

问候。

2 个答案:

答案 0 :(得分:0)

/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    

答案 1 :(得分:0)

在/ etc / hosts中,localhost应映射到127.0.0.1而不是其他任何内容,并将外部主机名映射到外部IP地址,而不是其他任何内容。据称,某些Linux发行版违反了这一规则,并且会破坏所有内容。