gpt4 book ai didi

networking - Vagrant:如何在 Vagrantfile 中配置多个网卡?

转载 作者:行者123 更新时间:2023-12-03 06:55:09 25 4
gpt4 key购买 nike

官方文档仅给出1个IP的示例:

http://docs.vagrantup.com/v2/networking/private_network.html

Vagrant.configure("2") do |config|
config.vm.network "private_network", ip: "192.168.50.4"
end

谷歌搜索我只能找到 1 个多个 IP 的示例:

https://groups.google.com/forum/#!topic/vagrant-up/hqtdOEjjlsw

Vagrant::Config.run do |config|
config.vm.define :web001 do |config|
config.vm.box = "base"
config.vm.forward_port("http", 5000, 8881)
config.vm.forward_port("ssh", 22, 2222)
config.vm.host_name = "web001.example.com"
config.vm.network("33.33.33.10")
config.vm.network("33.33.33.20", {:adapter=>2})
end
end

但这对我不起作用......

任何帮助将不胜感激......

最佳答案

使用 Vagrant 1.6.1 和 Virtualbox 的专用网络,您只需重复 config.vm.network 定义即可创建多个专用 IP:

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"

config.vm.network "private_network", ip: "192.168.50.4"
config.vm.network "private_network", ip: "192.168.50.5"
config.vm.network "private_network", ip: "192.168.50.6"
config.vm.network "private_network", ip: "192.168.50.7"

end

关于networking - Vagrant:如何在 Vagrantfile 中配置多个网卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23957752/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com