What is Vagrant doing behind the scenes to the host and guest machine when it sets up a private network with a fixed IP (http://docs.vagrantup.com/v2/networking/private_network.html)?
Vagrant.configure("2") do |config|
config.vm.network "private_network", ip: "192.168.50.4"
end
Back in Vagrant 1.0.x it is called Host-only Networking, it is a feature of VirtualBox, which allows multiple virtual machines to communicate with each other through a network via the host machine. The network created by host-only networking is private to the VMs involved and the host machine. The outside world cannot join this network.
Behind the scene, VirtualBox creates a new virtual interface ("loopback") on the host which appears next to the existing network interfaces.
VirtualBox even provide a built-in DHCP server for host-only networking (Private Networking) if no static IPs have been assigned. It can be configured in File - Preferences - Network.
See more at =>
On the host side, Vagrant does nothing. As far as I know Vagrant never touches host network configuration.
On the guest side, the current provider implements the network configuration logic. Here is what the VirtualBox provider does:
https://github.com/mitchellh/vagrant/blob/master/plugins/providers/virtualbox/action/network.rb
Basically the implementation is composed of two sequential steps:
configure_networks
capability.As an example, here is the implementation for the configure_networks
capability on Debian-based Linux OS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With