代码之家  ›  专栏  ›  技术社区  ›  KZiovas

VirtualBox VM未获取用Vagrant指定的已定义IP地址

  •  0
  • KZiovas  · 技术社区  · 2 年前

    我有一份流浪汉档案:

    # -*- mode: ruby -*-
    
    # vi: set ft=ruby :
    
    # All Vagrant configuration is done below. The "2" in Vagrant.configure
    # configures the configuration version (we support older styles for
    # backwards compatibility). Please don't change it unless you know what
    # you're doing.
    Vagrant.configure("2") do |config|
      
      #Box settings
      config.vm.box = "ubuntu/bionic64"
      config.vm.hostname = "vagrant.demo"
    
      #Networks settings
      # config.vm.network "forwarded_port", guest: 22, host: 2222
      # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
      config.vm.network "private_network", ip: "192.168.56.4"
      # config.vm.network "public_network"
      
      #Provider settings
      config.vm.provider "virtualbox" do |vb|
        vb.memory = 2048
        vb.cpus = 2  
        vb.name = "vagrant.demo"
    
      end
    

    在我执行命令之后 vagrant up 命令我使用ssh连接到vm vagrant ssh 并检查vm是否具有已定义的IP地址,但我只看到以下内容:

    Welcome to Ubuntu 18.04.6 LTS (GNU/Linux 4.15.0-173-generic x86_64)
    
     * Documentation:  https://help.ubuntu.com
     * Management:     https://landscape.canonical.com
     * Support:        https://ubuntu.com/advantage
    
      System information as of Thu Mar 31 14:39:57 UTC 2022
    
      System load:  0.24              Processes:             106
      Usage of /:   2.8% of 38.71GB   Users logged in:       0
      Memory usage: 8%                IP address for enp0s3: 10.0.2.15
      Swap usage:   0%
    

    这个 192.168.56.4 ip地址未按预期显示。知道少了什么吗?

    我用 Vagrant 6.1.32 在…上 Ubuntu 20.04.3 .

    0 回复  |  直到 2 年前
        1
  •  2
  •   KZiovas    2 年前

    因此,解决办法是降级到 VirtualBox 6.1.26 .参见讨论 here