2015-10-16 44 views
0

我试图在我的运行Yosemite的Mac OSX上使用Vagrant运行我们的构建服务器(Jenkins)的本地设置。我一直在环顾四周,我已经看到服务必须监听所有接口(0.0.0.0或者::: :)的要求。如何从Mac OSX连接到Vagrant中的服务器?

我有Vagrant启动和运行,詹金斯也运行。以下是sudo netstat -tulpn输出:

tcp  0  0 0.0.0.0:22    0.0.0.0:*    LISTEN  965/sshd   
tcp  0  0 0.0.0.0:57349   0.0.0.0:*    LISTEN  653/rpc.statd 
tcp  0  0 0.0.0.0:111    0.0.0.0:*    LISTEN  591/rpcbind  
tcp6  0  0 :::22     :::*     LISTEN  965/sshd   
tcp6  0  0 :::57689    :::*     LISTEN  2205/java  
tcp6  0  0 :::35586    :::*     LISTEN  2205/java  
tcp6  0  0 :::33991    :::*     LISTEN  653/rpc.statd 
tcp6  0  0 :::111     :::*     LISTEN  591/rpcbind  
tcp6  0  0 :::8080     :::*     LISTEN  2205/java  
udp  0  0 0.0.0.0:111    0.0.0.0:*       591/rpcbind  
udp  0  0 0.0.0.0:60038   0.0.0.0:*       653/rpc.statd 
udp  0  0 0.0.0.0:6057   0.0.0.0:*       496/dhclient  
udp  0  0 0.0.0.0:765    0.0.0.0:*       591/rpcbind  
udp  0  0 127.0.0.1:829   0.0.0.0:*       653/rpc.statd 
udp  0  0 0.0.0.0:68    0.0.0.0:*       496/dhclient  
udp6  0  0 :::111     :::*        591/rpcbind  
udp6  0  0 :::57046    :::*        653/rpc.statd 
udp6  0  0 :::5353     :::*        2205/java  
udp6  0  0 :::765     :::*        591/rpcbind  
udp6  0  0 :::52531    :::*        496/dhclient  
udp6  0  0 :::33848    :::*        2205/java 

詹金斯正在侦听端口8080,并听取::::(IPv6的全部)。我可以curl localhost:8080并得到响应,而虚拟机内部,而是从我的主机我得到如下:

* Rebuilt URL to: localhost:8080/ 
* Trying ::1... 
* connect to ::1 port 8080 failed: Connection refused 
* Trying 127.0.0.1... 
* Connected to localhost (127.0.0.1) port 8080 (#0) 
> GET/HTTP/1.1 
> Host: localhost:8080 
> User-Agent: curl/7.43.0 
> Accept: */* 
> 
* Empty reply from server 
* Connection #0 to host localhost left intact 
curl: (52) Empty reply from server 

我还试图让Java来使用IPv4,这样的监听地址的地址绑定然而0.0.0.0我得到相同的结果。

以下是我/etc/hosts文件的输出:

127.0.0.1 localhost 

# The following lines are desirable for IPv6 capable hosts 
::1 ip6-localhost ip6-loopback 
fe00::0 ip6-localnet 
ff00::0 ip6-mcastprefix 
ff02::1 ip6-allnodes 
ff02::2 ip6-allrouters 
ff02::3 ip6-allhosts 

从我到目前为止一切都读的是安装理所应当的,但我一定是做错了什么。你们能帮我搞定吗?

如果您需要了解更多信息,请让我知道,我会在这里发布。

干杯, Alexei Blue。

回答

1

你从客户需要forward port到主机,以便在您的Vagrantfile添加此

config.vm.network "forwarded_port", guest: 8080, host: 8080 

确保通过vagrant reload重新载入你的虚拟机采取生效,你就可以从你的主机

访问
+0

我感到非常愚蠢,因为在发布问题并重新查看netstat输出后,大约2秒后我得出了相同的结论。所以是的,我已经开始在端口8080詹金斯,但我没有转发端口通过我的主机哈哈。谢谢你的回答弗雷德里克,我做了改变,然后运行流浪汉重新加载 - 配置,以确保一个干净的构建。 –

+0

发生这种事:) –