7

Using vagrant 1.7.2 on OSX (MacBook Pro), Ubuntu 14.04 guests, VirtualBox 4.3.26. Mac is connected to the world via standard WiFi interface.

I want the Vagrant boxes to use the bridged network on the local LAN as their primary (and only) interface. This is required for experimenting with tcptraceroute, which doesn't do the right thing through the NAT'ed network. What I have now in my Vagrantfile is:

Vagrant.configure(2) do |config|
  config.vm.provider "virtualbox"
  config.vm.network "public_network", bridge: "en0: Wi-Fi (AirPort)"
  config.vm.box = 'ubuntu/trusty64'
end

And what I get inside the Vagrant box is:

$ ip -o -4 a
1: lo    inet 127.0.0.1/8 scope host lo\       valid_lft forever preferred_lft forever
2: eth0    inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0\       valid_lft forever preferred_lft forever
3: eth1    inet 172.16.69.16/24 brd 172.16.69.255 scope global eth1\       valid_lft forever preferred_lft forever

(172.16.69/24 is my LAN address). If I manually take down eth0 and switch the default route to 172.16.69.1 then I can use the VirtualBox as I want to:

# ifdown eth0
Internet Systems Consortium DHCP Client 4.2.4
Copyright 2004-2012 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/08:00:27:56:a8:46
Sending on   LPF/eth0/08:00:27:56:a8:46
Sending on   Socket/fallback
DHCPRELEASE on eth0 to 10.0.2.2 port 67 (xid=0x69745103)
# route add -net default gw 172.16.69.1
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use    Iface
0.0.0.0         172.16.69.1     0.0.0.0         UG    0      0        0 eth1
172.16.69.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1

And now tcptraceroute works right.

My question is - how can I configure Vagrantfile to avoid bringing up the eth0 interface as a NAT'ed interface and just bring it up as a single, bridged interface?

I tried playing around with config.vm.network "private_network" as partly explained in http://docs.vagrantup.com/v2/virtualbox/networking.html but as far as I followed all it did was to add interfaces to the box, not replace the default NAT'ed inetface on eth0.

migrated from serverfault.com Aug 15 '15 at 13:20

This question came from our site for system and network administrators.

7

You can try to add the adapter: 1 to the config. Although I still find some problem with it. See if it will help you starts from somewhere.

Example:

config.vm.network "public_network", bridge: "Broadcom BCM5709C", adapter: "1", ip: "192.168.x.xx"

You will still have the eth1 which is host-only network...

  • Thanks. Adding "adapter: '1'" did what I wanted - the VirtualBox came up with exactly one adapter eth0 which is bridged on my LAN and having an IP which it received from the DHCP on my modem. Vagrant itself failed because it was trying to connect to it over my "host-only" network but that's another issue. – Amos Shapira Oct 9 '15 at 11:00
  • Did you manage to solve the vagrant failing to connect issue? – Hawxby Oct 17 '16 at 9:45
  • @Hawxby since it was a one-off experiment I didn't bother to find a solution for it. I just manually ssh'ed into the instance to do my experiments. – Amos Shapira Oct 23 '16 at 23:01

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.