一个局域网,两台Ubuntu 18.04的例子(参考):

1
2
3
4
5
6
7
8
9
10
11
12
13
Vagrant.configure("2") do |config|
config.vm.define "alpha" do |alpha|
alpha.vm.box = "ubuntu/bionic64"
alpha.vm.network "private_network", ip: "10.0.0.10"
alpha.vm.hostname = "alpha"
end

config.vm.define "beta" do |beta|
beta.vm.box = "ubuntu/bionic64"
beta.vm.network "private_network", ip: "10.0.0.11"
beta.vm.hostname = "beta"
end
end

官网的例子:

1
2
3
4
5
6
7
8
9
10
11
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: "echo Hello"

config.vm.define "web" do |web|
web.vm.box = "apache"
end

config.vm.define "db" do |db|
db.vm.box = "mysql"
end
end

官网文档