A versão 1.1 do Vagrant foi lançada. A documentação que você está lendo é para o Vagrant 1.0.x. Leia mais sobre o Vagrant 1.1 no anúncio de lançamento. Acesse agora a documentação da versão 1.1.

Documentation for the Vagrant Experimental Series (1.x)

You're viewing the documentation for the experimental version of Vagrant (the 1.x series). The current stable series is 1.0.x and the documentation can be found here. You can learn more about the Vagrant versioning scheme here.

config.vm.network

Configuration key: config.vm.network

This configuration directive is used to configure networks available on the virtual machine. Currently, two types of networks can be used: host-only and bridged. The rest of this documentation page will assume basic knowledge of these features.

Host Only Networks

Host only neworks can be defined by providing only a simple IP:

Vagrant::Config.run do |config|
  # ...
  config.vm.network :hostonly, "10.11.12.13"
end

This will configure a host only network on the virtual machine that is assigned a static IP of “10.11.12.13.”

Other options are available for host only networks and may be passed in as an options hash for the 3rd parameter. The available options are:

  • :adapter - The adapter number of the host only network to apply the network configuration to.
  • :auto_config - If false, then Vagrant will not attempt to automatically configure this network on the guest OS.
  • :mac - The MAC address to assign to this network adapter.
  • :netmask - The subnet mask for this network.

Bridged Networks

Bridged networks can be defined very easily:

Vagrant::Config.run do |config|
  # ...
  config.vm.network :bridged
end

This will enable a bridged network adapter and ask during the configuration process what network to bridge to.

Other options are available for bridged networking, and may be passed in as an options hash for the 2nd parameter. The available options are:

  • :adapter - The adapter number of the host only network to apply the network configuration to.
  • :bridge - The full name of the network to bridge to. If this is specified, then Vagrant will not ask the user.
  • :mac - The MAC address to assign to this network adapter.