【问题标题】:Vagrant not adhering to static ip definition in vagrant fileVagrant 不遵守 vagrant 文件中的静态 ip 定义
【发布时间】:2020-01-07 19:27:07
【问题描述】:

流浪者版本:2.2.5 提供者:Hyper-V 操作系统:Windows 10、1809

在我的 vagrantfile 中指定一个 ipv4 地址后,在使用“vagrant up”时它不会分配它,它会分配另一个地址

我尝试将地址更改为不同的范围,使用不同的适配器等,但它仍然不遵守 Vagrantfile 中指定的内容。

流浪文件:

Vagrant.configure("2") do |config|
    config.vm.define "kube-1" do |ctl|
        ctl.vm.box = "generic/ubuntu1804"
        ctl.vm.hostname = "kube-1"
        ctl.vm.network "private_network", ip: "172.18.72.210", bridge: "Default Switch"
        ctl.vm.synced_folder ".", "/vagrant", disabled: true
        ctl.vm.provider "hyperv" do |vb|
            vb.memory = 2048
            vb.cpus = 2
        end
    end
end

输出:

Bringing machine 'kube-1' up with 'hyperv' provider...
==> kube-1: Verifying Hyper-V is enabled...
==> kube-1: Verifying Hyper-V is accessible...
==> kube-1: Importing a Hyper-V instance
    kube-1: Creating and registering the VM...
    kube-1: Successfully imported VM
    kube-1: Configuring the VM...
==> kube-1: Starting the machine...
==> kube-1: Waiting for the machine to report its IP address...
    kube-1: Timeout: 120 seconds
    kube-1: IP: 172.18.72.197
==> kube-1: Waiting for machine to boot. This may take a few minutes...
    kube-1: SSH address: 172.18.72.197:22
    kube-1: SSH username: vagrant
    kube-1: SSH auth method: private key
    kube-1: Warning: Remote connection disconnect. Retrying...
    kube-1:
    kube-1: Vagrant insecure key detected. Vagrant will automatically replace
    kube-1: this with a newly generated keypair for better security.
    kube-1:
    kube-1: Inserting generated public key within guest...
    kube-1: Removing insecure key from the guest if it's present...
    kube-1: Key inserted! Disconnecting and reconnecting using new SSH key...
==> kube-1: Machine booted and ready!
==> kube-1: Setting hostname...

我原以为它会查看 Vagrantfile(根据文档)并分配我指定的 IP 地址,即使它与现有范围重叠(正如文档所建议的那样!)

我从来没有遇到过 vagrant 的问题,但话又说回来,我从来不需要静态分配地址……叹息!

任何帮助调查/解释正在发生的事情将不胜感激!

【问题讨论】:

    标签: vagrant vagrantfile vagrant-windows


    【解决方案1】:

    ip: "172.18.72.210" 是公共 IP - 您需要从 Private Network 中选择一个 IP 也许您想设置为 172.16.72.210

    【讨论】:

    • 我相信分配给私有 IP 地址空间的 172.16.0.0/12 涵盖了我正在使用的范围,172.18.72.x 所以不确定是这个!
    • IP 地址 172.17.72.210 由 AT&T Services, Inc. 提供,属于 CDIR(Classless Inter-Domain Routing)172.0.0.0/12(范围 172.0.0.0 到 172.15.255.255) .
    猜你喜欢
    • 2016-07-12
    • 2014-01-06
    • 1970-01-01
    • 2023-04-06
    • 2018-03-02
    • 1970-01-01
    • 1970-01-01
    • 2016-12-18
    • 1970-01-01
    相关资源
    最近更新 更多