15

I am running KVM on RHEL6, and I have created several virtual machines in it. Issuing ifconfig command to the host system command line shows a list of virbr0, virbr1... and vnet0, vnet2... Are they the IP addresses of the the guest OS? What are the differences between virbr# and vnet#?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
xczzhh
  • 389
  • 3
  • 5
  • 12

2 Answers2

31

Those are network interfaces, not IP addresses. A network interface can have packets from any protocol exchanged on them, including IPv4 or IPv6, in which case they can be given one or more IP addresses.

virbr are bridge interfaces. They are virtual in that there's no network interface card associated to them. Their role is to act like a real bridge or switch, that is switch packets (at layer 2) between the interfaces (real or other) that are attached to it just like a real ethernet switch would.

You can assign an IP address to that device, which basically gives the host an IP address on that subnet which the bridge connects to. It will then use the MAC address of one of the interfaces attached to the bridge.

The fact that their name starts with vir doesn't make them any different from any other bridge interface, it's just that those have been created by libvirt which reserves that name space for bridge interfaces

vnet interfaces are other types of virtual interfaces called tap interfaces. They are attached to a process (in this case the process runnin the qemu-kvm emulator). What the process writes to that interface will appear as having been received on that interface by the host and what the host transmits on that interface is available for reading by that process. qemu typically uses it for its virtualized network interface in the guest.

Typically, a vnet will be added to a bridge interface which means plugging the VM into a switch.

Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501
  • Thank you so much for the answer! But, if `virbr` is a bridge interface, and as bridges are layer two devices, what does it need an IP address for(there are IP addresses following every virbr# interfaces)? – xczzhh Oct 25 '12 at 08:33
  • I've updated the answer. The idea is to give the host an IP address on that network. – Stéphane Chazelas Oct 25 '12 at 10:58
  • Thank you again for the reply. I know that two different guest OS created by KVM can share the same `virbr`, but what if I have a third guest OS which is connected to a different `virbr`, and these two `virbr`s are in different IP networks, what should I do so that these two networks can communicate with each other? – xczzhh Oct 25 '12 at 11:46
  • the same thing you'd do with real switches. Some machine, typically the host since it's got an IP address on both networks would route between the two networks. It probably does so by default, but maybe you need to change the firewall configuration on the host. – Stéphane Chazelas Oct 25 '12 at 11:58
  • Yeah, I've tried, but the problem is that OS A can ping OS B, but OS B cannot ping OS A. Do you know what might be the problem...? Thank you again :) – xczzhh Oct 25 '12 at 12:41
  • Check the route table on all hosts the firewall (log and configuration) on all hosts. sniff the traffic on the virtual interfaces to see where the packets are lost, how they are transformed. – Stéphane Chazelas Oct 25 '12 at 13:37
  • Thank you for the patience. Your knowledge on this field is so deep that I cannot help but admire you. :). Another question, the `ifcfg-vnet0` file shows that vnet0 is _also_ of the TYPE of `Bridge`. And some article says that `virbr` is for **bridged networks** and `vnet` is used for **NAT networks**. Is there really such a different here? Thank you. – xczzhh Oct 26 '12 at 13:40
  • vnet interfaces are created when virtualized guest starts (on CentOS/RHEL & libvirt), there is no need to create them manually or by some config file. Just connect guest virtual KVM machine to the bridge and when guest starts, vnet interface is created to the correct bridge. – Milan Kerslager Mar 11 '19 at 18:27
-1

Virbr# are virtual bridges (Switches).

Vnet# are NICs of running virtual machines, seen from host machine (physical machine). It means that, from your physical machine, you can see your virtual machines NICs when they are running.

you can check this by executing "ip a" command from your physical and virtual machine.

Omar SADI
  • 1
  • 1