Hi all,
I'm running vagrant 1.0.2 on ruby 1.9.3 in an RVM on OSX 10.7.3 and cannot get bridged networking working non-interactively. I dove into the code a bit, but nothing jumps out at me.
This is the Vagrantfile I am using to repro:
Vagrant::Config.run do |config|
config.vm.box = "lucid64"
config.vm.box_url = "http://files.vagrantup.com/lucid64.box"
config.vm.network :bridged, :bridge => 'en1'
end
Steps to repro (assuming you have rvm set up)
rvm use --create 1.9.3@vagrant-repro
gem install vagrant
VAGRANT_LOG=DEBUG vagrant up
Output will be the following, which seems self-contradictory.
DEBUG network: Bridge was directly specified in config, searching for: en1
INFO interface: info: Specific bridge 'en1' not found. You may be asked to specify which network to bridge to.
[default] Specific bridge 'en1' not found. You may be asked to specify which network to bridge to.
INFO interface: info: Available bridged network interfaces:
[default] Available bridged network interfaces:
INFO interface: info: 1) en1: Wi-Fi (AirPort)
1) en1: Wi-Fi (AirPort)
INFO interface: info: 2) en0: Ethernet
2) en0: Ethernet
INFO interface: info: 3) p2p0
3) p2p0
INFO interface: ask: What interface should the network bridge to?
Thanks for any help resolving this,
Ah, the issue is you need to make it this: en1: Wi-Fi (AirPort)
I'm thinking of relaxing this a bit so that only the beginning needs to match, however.
For posterity, this command should now be:
config.vm.network :public_network, :bridge => 'en1: Wi-Fi (AirPort)'
Works like a charm on Mountain Lion.
Making this match on just the beginning part would be wonderful, because then I can do this at the top of my Vagrantfile:
INTERNET_INTERFACE = %x[
route get 8.8.8.8 | grep interface | head -1 | awk -F' ' '{print $2}'
]
...and have it automatically bridge to my "internet" interface regardless of whether I'm on wifi or a cable, which is Almost Always What I Want. (It might even be a sane default for Vagrant itself when public_network is specified...)
Was the change to relax this a bit ever done? Using the long name makes dynamic bridge selection impossible.
贼 血呼啦慢
I have had success with the following:
INTERNET_INTERFACE = %x(vboxmanage list bridgedifs | grep `route get 8.8.8.8 | grep interface | head -1 | awk -F' ' '{print $2}'` | grep -v VBoxNetworkName | awk -F 'Name: *' '{print $2}').strip
config.vm.network "public_network", bridge: "#{INTERNET_INTERFACE}"
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
I have had success with the following: