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
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