Private Networks
General Vagrant doc page: Private Networks.
Private networking by the Parallels provider is fully compatible with the basic Vagrant approach.
In order to implement a private network, the Parallels provider configures the internal Host-Only network.
DHCP
The easiest way to use a private network is to allow the IP address to be assigned via DHCP.
Vagrant.configure("2") do |config|
config.vm.network "private_network", type: "dhcp"
end
This will automatically assign an IP address from the reserved address space.
The IP address can be determined by using vagrant ssh
to SSH into the virtual
machine and using the appropriate command-line tool to find the IP, such as
ifconfig
.
Static IP
You can also specify a static IP address for the machine. This lets you access the Vagrant managed machine using a static (known) IP address. The Vagrantfile for a static IP address should look like this:
Vagrant.configure("2") do |config|
config.vm.network "private_network", ip: "192.168.50.4"
end
It is a responsibility of the user to ensure that the static IP address does not conflict with any other machines on the same network.
While you can choose any IP address, you should use an IP from the reserved private address space. These addresses are guaranteed to never be publicly routable, and most routers actually block traffic from going to them from the outside world.