如何使 vagrant ssh 的 IP 地址与 VM 的 IP 地址相同? [英] How to make IP address for vagrant ssh the same as for the VM?

查看:32
本文介绍了如何使 vagrant ssh 的 IP 地址与 VM 的 IP 地址相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使 vagrant ssh 的 IP 地址与 VM 的 IP 地址相同?我需要更改/添加什么到我的清单(Vagrant 配置文件)?

How can I make IP address for vagrant ssh the same as for the VM? What would I need to change/add to my manifest (Vagrant config files) ?

再解释一下我的情况:在我的/etc/hosts 文件中,我设置了本地域以映射到 VM 的 IP 地址 192.168.56.105 - 这是在 Vagrant 设置中配置的内容,这有效.

To explain my situation a little more: In my /etc/hosts file, I've setup local domains to map to the IP address of the VM as 192.168.56.105 - this is what is configured in the Vagrant setup, this works.

然而 vagrant ssh 尝试连接到 127.0.0.1

However vagrant ssh tries to connect to 127.0.0.1

为什么会这样?

我的流浪 ssh 详细信息是(当输出到文件时):

My vagrant ssh details are (when outputted to a file):

<代码>主机默认主机名 127.0.0.1用户无业游民端口 2222UserKnownHostsFile/dev/nullStrictHostKeyChecking 否密码认证 否IdentityFile/Users/rdavis/.vagrant.d/insecure_private_key身份只有是日志级别致命

推荐答案

我的具体问题的根本原因是端口冲突(与我正在使用的其他 VM).感谢我的同事发现了这一点.

My specific problem had a root cause in port collision (with other VMs I'm using). Full credit to my colleague for spotting this.

Vagrant 检测端口冲突,但在您的 Vagrantfile 配置中,您必须对此做一些事情,即

Vagrant detects port collision but in your Vagrantfile config you have to do something about it i.e.

auto_correct: true

https://docs.vagrantup.com/v2/networking/forwarded_ports.html

这意味着我可以一次运行多个虚拟机而不会出现此问题.

This means that I can run more than one VM at a time without this issue.

这篇关于如何使 vagrant ssh 的 IP 地址与 VM 的 IP 地址相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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