gpt4 book ai didi

Vagrant 无法为 box 分配静态 ip

转载 作者:行者123 更新时间:2023-12-02 00:55:11 28 4
gpt4 key购买 nike

我的 Vagrant 文件中有以下内容。

config.vm.network "private_network", ip: "192.168.33.12"

当我“vagrant up”时,vagrant 正在分配 127.0.0.1。我不确定是什么原因造成的。下面是完整的轨迹。

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2200
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => C:/vm2
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.

最佳答案

你在这里看到的

default: SSH address: 127.0.0.1:2200

不是您的 VM IP 地址 - 这只是为了让 vagrant 使用可用端口(在您的情况下为 2200)通过 ssh 进入该框。 vagrant 在您的 VM 上配置 eth0 接口(interface)以与主机通信

登录到 VM 并运行 ifconfig,您将看到(至少)2 个可用接口(interface),其中 eth0 位于 10.0.2.15 上,eth1 位于 192.168 上。 33.12

关于Vagrant 无法为 box 分配静态 ip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36210856/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com