我尝试使用Vagrant VMWare Fusion插件,但是(无论我做什么)在我的私有VMWare网络上设置静态IP地址,VM只能获得DHCP地址。
我已将此添加到我的Vagrant配置文件中:
server1.vm.network "private_network", ip: "192.168.13.120"
但是,它会被忽略并发出动态DHCP地址。我正在使用hashicorp / precise64基本图像。
以下是我用来测试的Vagrant文件的完整列表。
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64_vmware.box"
# Turn off shared folders
config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
# Begin server1
config.vm.define "server1" do |server1|
server1.vm.hostname = "server1"
server1.vm.provider "vmware_fusion" do |v|
v.vmx["numvcpus"] = "1"
v.vmx["memsize"] = "512"
end
server1.vm.provider "virtualbox" do |v|
v.customize [ "modifyvm", :id, "--cpus", "1" ]
v.customize [ "modifyvm", :id, "--memory", "512" ]
end
server1.vm.network "private_network", ip: "192.168.13.120"
end
# End server1
....................................
end
这就是我的VMWare私有界面的配置方式:
vmnet8: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:50:56:c0:00:08
inet 192.168.13.1 netmask 0xffffff00 broadcast 192.168.13.255
答案 0 :(得分:4)
/Library/Preferences/VMware\ Fusion/networking
并为IP所属的适配器禁用DHCP。例如:
...
answer VNET_2_DHCP no
answer VNET_2_HOSTONLY_NETMASK 255.255.255.0
answer VNET_2_HOSTONLY_SUBNET 172.17.8.0
answer VNET_2_VIRTUAL_ADAPTER yes
...
sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli —stop
sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli —configure
sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli —start
sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli —status
这对我的情况有帮助,这与你的情况非常相似。
server.vm.network :private_network, ip: 172.17.8.100
使用DHCP,我有类似的东西:
inet 172.17.8.131/24 brd 172.17.8.255 scope global dynamic enp0s18
关闭DHCP后,将为vm分配已定义的专用IP地址:
inet 172.17.8.100/24 brd 172.17.8.255 scope global enp0s18
让我知道它是怎么回事。