多个 Vagrant VM 可以通过 VM 主机名进行通信吗? [英] Can Multiple Vagrant VMs communicate by VM hostname?

查看:55
本文介绍了多个 Vagrant VM 可以通过 VM 主机名进行通信吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Vagrant 管理多个 VM.网络配置为私有,IP 地址已设置,主机名已分配.如下面的 Vagrantfile 所示.

I am managing multiple VMs with Vagrant. Networks are configured as private, ip addresses have been set and hostnames are assigned. As shown in the Vagrantfile below.

VM 可以通过 IP 地址相互通信,但我想知道如何允许 VM 使用分配的主机名进行通信.IE.如何使 ping comtest2comtest1 工作?

The VMs can communicate with each other via the IP address, but I would like to know how to allow VMs to communicate using their assigned hostname. I.e. How to make ping comtest2 work from comtest1?

流浪文件:

Vagrant.configure("2") do |config|

  config.vm.define "comtest1" do |comtest1|
    comtest1.vm.box = "precise32"
    comtest1.vm.hostname = "comtest1"
    comtest1.vm.network "private_network", ip: "192.168.10.21"
  end

  config.vm.define "comtest2" do |comtest2|
    comtest2.vm.box = "precise32"
    comtest2.vm.hostname = "comtest2"
    comtest2.vm.network "private_network", ip: "192.168.10.22"
  end

end

推荐答案

使用 https://github.com/欺骗 DNS 解析adrienthebo/vagrant-hosts ?

这篇关于多个 Vagrant VM 可以通过 VM 主机名进行通信吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆