如何在Vagrant for NFS中创建仅限主机的网络?

时间:2016-06-24 22:03:52

标签: networking vagrant

我在文档中找不到有关此错误消息的任何信息:

NFS requires a host-only network to be created.
Please add a host-only network to the machine (with either DHCP or a
static IP) for NFS to work.

这是我的Vagrant配置:

Vagrant.configure(2) do |config| 
 config.vm.box = "localbox" 
 config.vm.network "public_network", hostonly: "192.168.33.10"
 config.vm.synced_folder ".", "/var/www",  
    :nfs => true, 
    :mount_options =>['noacl,nolock,vers=3,udp,noatime,nodiratime,rsize=32768,wsize=32768']

当被问及时,我选择了我的机场连接(Wi-Fi(AirPort))。

我在Vagrant文​​档中找不到hostonly的单一用法。

使用Vagrant 1.7.4

我的目标只是能够从我家中的其他计算机(和我的手机)访问我家中一台计算机上运行的VM。

2 个答案:

答案 0 :(得分:7)

如果您想拥有NFS和公共/网桥,请尝试以下方法:

Vagrantfile

config.vm.network "private_network", ip: "192.168.10.100"
config.vm.network "public_network", ip: "192.168.20.200"

config.vm.network "private_network", ip: "192.168.10.100"
config.vm.network "public_network", ip: "192.168.20.200", bridge: "en1: Wi-Fi (AirPort)"

答案 1 :(得分:2)

在您的Vagrantfile中将hostonly替换为ip

config.vm.network "public_network", ip: "192.168.33.10"