简体   繁体   中英

Vagrant how to set network type so that its attached to bridge adapter on Virtual Box

I am using Vagrant to created Virtual Box images. Can anyone tell me the configuration I can set that the Virtual Box VM Network that attaches the VM to a Bridged Adapter before starting up.

I can set the following configuration in my Vagrantfile , but it sets the Network adapter to NAT not bridged adapter that I need.

config.vm.network :public_network

Thank you

I am installing vagrant on ubuntu 10.04 with Virtualbox VirtualBox 4.1.24 from https://www.virtualbox.org/wiki/Linux_Downloads and then downloaded recent version of vagrant.

$ vagrant -v
Vagrant version 1.2.2

$ dpkg -l virtualbox*
ii  virtualbox-4.1 4.1.26-84997~U Oracle VM VirtualBox

In order to use bridge network and specifically wifi i just added the line below inside Vagrantfile

 config.vm.network :public_network, :public_network => "wlan0"

When you will do

 $ vagrant up

You will see option asking for device for bridge interface you can use 1 for wlan0. Hope it helps.

Vagrant will setup a default NAT network, you can add a bridge network by uncommenting the following line in Vagrantfile:

config.vm.network "public_network"

However, if you have multiple network devices in your host, You can specify which one to use by the bridge parameter:

config.vm.network "public_network", bridge: 'en4: AX88179 USB 3.0 to Gigabit Ethernet'

I had the same issue today, what I have really done using Vagrant 2.2.0, use this directive inside my Vagrantfile:

config.vm.network "public_network", bridge: "wlp3s0: Wi-Fi (Hackathon)"

it is also possible to use:

config.vm.network "public_network"

and Vagrant will ask whether you use WLAN or nic!IF THE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM