无法访问vagrant中的主机名

时间:2015-07-21 17:11:29

标签: vagrant virtualbox ip-address hostname

我的流浪文件如下所示:

Vagrant.configure(2) do |config|  
  config.vm.box = "chef/centos-7.0"  

#cent71 will be the server  
  config.vm.define :cent71 do |cent71|  
    cent71.vm.hostname = "cent71.nv.server"  
    cent71.vm.network :private_network, ip: "192.168.70.101"  
  end  
end

虽然我可以在主机的网络浏览器上访问192.168.70.101:8080,但我无法通过cent71.nv.server访问它:8080
我应该改变什么?

1 个答案:

答案 0 :(得分:1)

您需要在主机的/ etc / hosts文件中添加一个条目(我假设你使用的是mac或linux机器,不知道在windows上做什么)。

它看起来应该如下所示。

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost

# your mapping right here
192.168.70.101       cent71.nv.server