Oh my host I have a physical interface eth0 which is already in a bridge br0.
I already have some libvirt-managed KVM VMs which I bridge to my LAN via br0. When the VMs start, a tuntap interface is added to the host called vnetX which is then bridged into br0.
I would like to be able to add Vagrant VMs to this pre-existing bridge as well, so that the Vagrant-created VM is networked via tap interface in the same way as the existing VMs.
cool. as soon as you implement this feature i will happy to accept it.
Had the same problem...
This is how I solved it:
machine.vm.network :public_network,
:dev => 'br0',
:type => 'bridge'
:type sets the
and
https://github.com/pradels/vagrant-libvirt/blob/master/lib/vagrant-libvirt/action/create_network_interfaces.rb#L68
To be more verbose: Below is an example where libvirt creates a TUN/TAP device and adds it to the specified bridge:
...
...
For me, it sufficed to use the public_network xml template. It lacks the target, alias and address tags, but works nonetheless.
I was able to create the bridge interface using something similar to what you did above, but for some reason I still get an eth0 interface to the default nat interface.
<interface type='network'>
<mac address='52:54:00:1c:12:99'/>
<source network='vagrant-libvirt' bridge='virbr1'/>
<target dev='vnet3'/>
<model type='virtio'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</interface>
<interface type='bridge'>
<mac address='52:54:00:be:e6:9f'/>
<source bridge='br0'/>
<target dev='vnet4'/>
<model type='virtio'/>
<alias name='net1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</interface>
and because i get the default nat interface on eth0 vagrant can't do anything since the interface never comes up, and eth1 doesn't get built since it's missing ifcfg-eth1 files.
config.vm.define :test_vm do |test_vm|
test_vm.vm.box = "mycentosvagrant"
test_vm.vm.network :public_network, :dev => "br0", :type => "bridge"
end
I have been reading all the different configurations suggested including the:
machine.vm.network :public_network,
:dev => 'br0',
:type => 'bridge'
with no success. I have been using KVM/libvirt for years, setting up lots of different VMs with a bridge to the rest of my network, most using Chef. This is my first time trying to use Vagrant. This should be one of the most common use cases, yet it seems that everyone is banging their heads against the wall. It would be nice if there were a set of example VagrantFile(s) for the most common configurations, one of which should be a VM that has a bridged interface to the network the host is connected to.
I have created a custom Ubuntu 14.04 LTS box which deploys, but it only has an eth0 interface to the default virtual network. Attempting to add the bridged interface either does nothing, says it can't find the eth1 interface, gets a virDomainCreateWithFlags failed error, gets stuck at Waiting for SSH, or any of a number of other errors.
I finally got it working. The above configuration is correct. My problem was missing an additional entry in the /etc/network/interfaces file of the guest image (Ubuntu 14.04 LTS). By adding:
# The bridge network interface
auto eth1
iface eth1 inet dhcp
the eth1 interface was found and used. The problem occurred because the Vagrant required private network management interface was using eth0.
This is working just fine with:
machine.vm.network :public_network,
:dev => 'br0',
:type => 'bridge'
In vagrant 1.8.1. It even creates the eth1 stanza to bring it up at boottime.
So, closing as I don't see a bug here.
Most helpful comment
This is working just fine with:
In vagrant 1.8.1. It even creates the
eth1stanza to bring it up at boottime.So, closing as I don't see a bug here.