How to access Vagrant Box in public network

前端 未结 5 1255
挽巷
挽巷 2021-01-30 17:02

I had created on e box inside vagrant. In the Vagrantfile, I had given the network as

     Create a private network, which allows host-only access to the machine
         


        
5条回答
  •  闹比i
    闹比i (楼主)
    2021-01-30 17:52

    I was unable to figure this out using anything I read (which was hours and hours of research). Instead, this is how I figured it out:

    Below is my Vagrantfile. The important part for me was config.vm.network :public_network. After reloading vagrant with vagrant reload, I chose the first option of the 4 available bridged network interfaces (I’m not sure if I chose the correct one by luck, or if any would have worked, I’ll experiment), then sshed into the vagrant box with vagrant ssh, did ifconfig, chose one of the 3 ip addresses that it output, pasted that into my browser, and it worked.

    The thing no one else seemed to talk about was sshing into the vagrant box and finding one of the ip addresses there. I hope maybe this helps some other networking newb in the future.

    # -*- mode: ruby -*-
    # vi: set ft=ruby :
    
    Vagrant.configure(2) do |config|
      config.vm.box = "bahmni-team/bahmni"
      config.vm.box_check_update = true
      config.ssh.insert_key = false
      config.vm.network :public_network
    
      config.vm.synced_folder "..", "/bahmni", :owner => "vagrant"
      config.vm.provider "virtualbox" do |v|
         v.customize ["modifyvm", :id, "--memory", 4092, "--cpus", 2, "--name", "Bahmni-RPM"]
      end
    end
    

提交回复
热议问题