How To Manually Add A New Interface To A Bridge Device?

Home » CentOS-Virt » How To Manually Add A New Interface To A Bridge Device?
CentOS-Virt 7 Comments

Maybe my google-fu is failing me, but I have spent the past couple hours looking at how to add a vnet? Device to my KVM host running CentOS 6, and for the life of me I can’t get this going.

From all my research if I want to add a device I should just do ‘brctl addif br1 vnet14’ if I want to add a vnet14 to bridge br1. When I do this, I
get:

# brctl addif br0 vnet14

interface vnet14 does not exist!

If I run a ‘brctl show’ I get the following:

# brctl show

bridge name bridge id STP enabled interfaces

br0 8000.00237dd22a4c no eth0

vnet0

vnet10

vnet11

vnet13

vnet2

vnet3

vnet4

vnet6

vnet8

br1 8000.00237dd22a50 no eth1

vnet1

vnet12

vnet5

vnet7

vnet9

Needless to say the existing vnet?? Devices are in use on guest VM‘s currently.

When I create a new VM using virt-install, I usually add the following to my command line:

network=bridge:br0 —network=bridge:br1

I messed up building a new VM, and only added the br0 interface to the VM, but need the br1 interface as well. So my question is, or a pointer to how I can add that br1 interface to my existing VM, and create the needed vnet14
interface for it to attach to?

If anyone can explain how to do this, or give me a good pointer on where the info is on how to do this, it would sure be a huge help..

Thanks.

7 thoughts on - How To Manually Add A New Interface To A Bridge Device?

  • I would stop the VM, edit its definition file (that’s an XML file) and then start it up. But be careful: After you edit the XML file, you need to execute a command so KVM re-reads that file. I forgot that command, but you can look it up on Google.

  • Tried that as well, but this has to be something that gets set at the OS level and loaded, as if you look at dmesg output, you can see all the vnet?? nodes as the OS comes online. So the question is, what is virt-install doing that creates the needed vnet interface that is part of the bridge. I really had to kill and reload the VM just to load a second interface..

  • You most definitely do not need to destroy and re-create a VM just to add a 2nd network interface.

    I don’t think those vnet interfaces got created by the host OS. I
    believe those are created by KVM (or libvirt) when you start a VM. I
    could be wrong though. But I just checked on my CentOS 6 KVM host machine and I see as many vnet interfaces as many VMs are currently running (or if one VM has two virtual network cards then of course that VM results two vnet interfaces shown on the host). Here the relevant part from one such VM’s XML file (those XML files are under the
    /etc/libvirt/qemu directory on my CentOS host ) :




    As you can see, there are two interfaces defined in this VM’s XML file.

  • How do you decide what MAC address to use for that VM interface? As I just tried to change the MAC to some other value close, like I made
    ’52:54:00:34:e1:21′ into say ’52:54:00:34:e1:32′, and when I try and load it in, I get the following:

    error: XML error: Attempted double use of PCI Address ‘0:0:4.0’

    Here is one of my network entries:

  • The MAC address you gave is fine. I use random MAC addresses just like you did.

    Your PCI bus address also has to be unique within a given VM. I’m sorry, I forgot to mention that. Look at my configuration example I sent. These are emulated (virtual) network cards attached to the emulated (virtual)
    PCI bus of the virtual machine. Two network cards cannot have the same MAC address and they cannot be on the same PCI bus address either. Your VM’s are emulated physical machines with their own BIOS, etc.

    Zoltan

  • BTW, adding a 2nd virtual nic to a guest can also be done with command line tools (I just googled this for you) :
    https://kashyapc.fedorapeople.org/virt/add-network-card-in-guest.txt
    ( It came up as 1st result when I searched for: virsh add network interface to existing guest )

    But if you look at the bottom of this guide, they also mention that if something goes wrong, they resort to using virsh edit just like I
    suggested to you. See, I prefer to edit a configuration file rather then issuing long and complicated commands on the CLI. However, being able to add a 2nd nic to a live guest is nice though and that could only be achieved with the CLI command. As you can see, you can even add nic’s to a VM without having to reboot it.

    Zoltan

  • That is exactly what I was looking for, and worked perfectly, and will now be added to my notes on working with VM’s. I figured it was a matter of me just not using the right search words in google, but damn if I could find that page, and I tried.

    Using the info on that page, I added an interface, and it’s live and running..