我正在尝试通过一个Vagrantfile创建两个虚拟机:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.box_version = "1707.01"
config.vm.define "inf-vm-01" do |node|
config.vm.hostname = "inf-vm-01"
config.vm.network "public_network", bridge: "en0: Wi-Fi (AirPort)", ip: "192.168.1.121"
end
config.vm.define "inf-vm-02" do |node|
config.vm.hostname = "inf-vm-02"
config.vm.network "public_network", bridge: "en0: Wi-Fi (AirPort)", ip: "192.168.1.122"
end
end
如您所见,我想在每台客户机和主机之间建立桥梁。问题是第二个虚拟虚拟机有一个额外的桥。这是 ip addr :
的输出 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:ad:a0:96 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0
valid_lft 86303sec preferred_lft 86303sec
inet6 fe80::5054:ff:fead:a096/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:1b:8e:eb brd ff:ff:ff:ff:ff:ff
inet 192.168.1.121/24 brd 192.168.1.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe1b:8eeb/64 scope link
valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:e1:d5:bc brd ff:ff:ff:ff:ff:ff
inet 192.168.1.122/24 brd 192.168.1.255 scope global eth2
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fee1:d5bc/64 scope link
valid_lft forever preferred_lft forever
我的流浪档案有什么问题?
答案 0 :(得分:0)
你有一个错误的Vagrantfile,你在一个块中使用config.vm.network
,因此它对文件有效。你应该这样写(注意我在块中使用node1和node2变量)
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.box_version = "1707.01"
config.vm.define "inf-vm-01" do |node1|
node1.vm.hostname = "inf-vm-01"
node1.vm.network "public_network", bridge: "en0: Wi-Fi (AirPort)", ip: "192.168.1.121"
end
config.vm.define "inf-vm-02" do |node2|
node2.vm.hostname = "inf-vm-02"
node2.vm.network "public_network", bridge: "en0: Wi-Fi (AirPort)", ip: "192.168.1.122"
end
end
您还可以阅读vagrant doc,特别是Defining Multiple Machines章