How to access Vagrant Box in public network

前端 未结 5 1258
挽巷
挽巷 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
    2021-01-30 17:31

    Uncomment the line in Vagrantfile

    config.vm.network :public_network

    The file will look like below

    VAGRANTFILE_API_VERSION = "2"
    
    Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
      config.vm.box = "box_name"
      config.vm.network :public_network
    end
    

    Save it, restart the VM by using vagrant reload.

    For VirtualBox, it'll use Bridged mode for networking. Which means the VM will acquire an IP address from the DHCP server for the VLAN.

    You can also set the VLAN IP with: config.vm.network :public_network, ip: "192.168.0.160"

    Refer to => Public Network

提交回复
热议问题