I am confused by the way I have to set up virtual switches in Linux. I proceeded as follows:
ip link add name br0 type bridge
ip link set br0 up
This should create a virtual switch called br0. Now, let's suppose I have a physical network device called eth0 and a tap device vnet0 created by KVM/qemu on my machine. The tap device is automatically attached to br0 (by configuration) and eth0 can be added by hand:
ip link set eth0 master br0
Both devices should now be attached to the switch br0.
I assigned the IP address 192.168.1.1 to eth0 and 192.168.1.2 to the network interface inside the virtualization. Of course the tap interface itself doesn't know anything about this address.
If I had exactly this setting with a physical switch instead of a virtual one, I would expect to be able to ping the address 192.168.1.2 from the host system. However, this IP cannot be reached via ping:
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
From 192.168.1.2 icmp_seq=1 Destination Host Unreachable
...
Why is that?
I expected eth0 to send an ARP request into all Ethernet segments it's part of. This is the physical one, but also the one defined by br0. The ARP request should have been answered by vnet0 with it's MAC address.
The solution I found was to assign an IP address to br0 as well:
ip addr add 192.168.1.3/24 dev br0
Now the ping works fine.
macvlan
andopen vswitch
. This may be the source of your confusion.