Tuesday 27 March 2018

networking - How to force Vagrant to have a single, bridged, network interface


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.



Answer



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...


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...