我正在使用Vagrant配置在VirtualBox下运行的CentOS 6.5和Ubuntu Trusty64 VM。我正在使用Vagrantfiles来设置主机名和IP,但我注意到当我启动它们时,两台机器都在拿起一个域名,然后找到进入SSL密钥的域名。主机是Windows 7,虚拟机正在从中获取域。我怎样才能防止这种情况,最好只使用Vagrantfiles?
以下是Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# See README.md for details
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos65-base"
config.vm.define "server1" do |server1|
server1.vm.hostname = "server1"
server1.vm.network "private_network", ip: "172.16.0.201"
end
end
答案 0 :(得分:1)
每个主机都有一个Vagrantfile:
Vagrant.configure(2) do |config|
config.vm.box = "PUT YOUR BOX NAME HERE"
# Define the vagrant machine name. Display it with: 'vagrant status'
config.vm.define "PUT YOUR MACHINE NAME HERE"
# Define the hostname.
config.vm.hostname = "PUT YOUR HOSTNAME HERE"
end
两者兼有,CentOS 6.6& 7和Ubuntu 14.04& 14.10正在使用正确的主机名。您还可以使用以下内容添加域:
hostname = 'servername'
domain = 'example.com'
Vagrant.configure(2) do |config|
config.vm.box = "PUT YOUR BOX NAME HERE"
# Define the vagrant machine name. Display it with: 'vagrant status'
config.vm.define "PUT YOUR MACHINE NAME HERE"
# Define the hostname.
config.vm.define hostname + '.' + domain
end
同样,这是每个主机一个Vagrantfile。
答案 1 :(得分:0)
你是否尝试过我的建议?
config.vm.define :server1 do |config|
config.vm.hostname = "server1.example.com"
config.vm.network :private_network, ip: "172.16.0.201"
end