Bridged NetworkingBridged networking is another type of networking that VirtualBox provides which causes the virtual machine to appear as another physical device on your network. Your virtual machine will ask for an IP from the network via DHCP and will be visible just like any other machine. Vagrant exposes this feature in a straightforward and easy to use way. Supported Operating SystemsSince setting up bridged networking requires configuring the OS to use the new interface, this is a guest-specific behavior. Currently, Vagrant supports a small set of operation systems. If you'd like another OS supported, you can add it yourself using a custom guest or you can get in touch with a Vagrant developer and assist us in adding it to the core. Enabling a Bridged NetworkEnabling a bridged network on a virtual machine managed by Vagrant is simple enough, using a single configuration directive in the Vagrantfile:
The above will tell Vagrant to setup a bridged network interface. Vagrant will always setup this bridged interface as adapter #3 on the virtual machine. This can be overridden as well, see below for more information. Specifying a Bridged Network interfaceSometimes you may want to specify the host’s network interface in your You may inspect the bridged adapters VirtualBox can use by running:
Then you may use the
Not All Networks Work!Some networks will not work properly with bridged networking. Specifically, I've found that hotel networks, airport networks, and generally public-shared networks have configurations in place such that bridging does not work. You can tell if the bridged networking worked successfully by seeing if the virtual machine was able to get an IP address on the bridged adapter. Determining the IP of the Virtual MachineUnlike host-only networks, Vagrant does not know the IP that the bridged network will receive a priori. Instead, it is up to your network to lease your virtual machine an IP via DHCP. Because of this, the IP address can only be determined by SSHing into the virtual machine and inspecting the adapters yourself. For example, on an Ubuntu-powered virtual machine, by running
In the above output, we can see that |
|