How to find the Vagrant IP?

前端 未结 12 1268
余生分开走
余生分开走 2021-01-30 08:17

I have been developing an automated deployment using Capistrano and using Vagrant as my test virtual server.

The thing is, I need the IP of Vagrant to \"ssh

12条回答
  •  既然无缘
    2021-01-30 08:58

    By default, a vagrant box doesn't have any ip address. In order to find the IP address, you simply assign the IP address in your Vagrantfile then call vagrant reload

    If you just need to access a vagrant machine from only the host machine, setting up a "private network" is all you need. Either uncomment the appropriate line in a default Vagrantfile, or add this snippet. If you want your VM to appear at 172.30.1.5 it would be the following:

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

    Learn more about private networks. https://www.vagrantup.com/docs/networking/private_network.html

    If you need vagrant to be accessible outside your host machine, for instance for developing against a mobile device such as iOS or Android, you have to enable a public network you can use either static IP, such as 192.168.1.10, or DHCP.

    config.vm.network "public_network", ip: "192.168.1.10"

    Learn more about configuring a public network https://www.vagrantup.com/docs/networking/public_network.html

提交回复
热议问题