Page 1 of 1

KVM trunk to switch

Posted: 2020/04/10 11:02:34
by atux_null
i have a server with one NIC that i run KVM and it works fine. I have a managed switch that it has vlans and i would like to add it as trunk to the centos KVM server. So each guest machine will have its own vlan. Iam stuck with the configuration of the KVM. how do i assign the trunk and the vlan to each guest, please?

Re: KVM trunk to switch

Posted: 2020/04/10 21:08:52
by jlehtone
There are multiple ways to do that.

You have switch and host. One cable between them. The switch sends traffic of multiple LANs to that cable. Traffic is tagged, so the host can separate the LANs. Trunk is on the cable.

What to do at the host?

If you had SR_IOV support on the NIC, then you could create VFs and assign them to guests. You could do the filtering/tagging in the VF so that the guest receives untagged traffic of one LAN.

You could have a software bridge on the host and attach all the guests to the bridge. Every guest would receive all the tagged traffic. The guest could handle all the VLANs that it is interested in.

You could have a software bridge on the host with vlan filtering per "port" of the bridge. A guest receives untagged traffic of one LAN.

You could create vlan interface on the host for each VLAN. Then create one bridge for each VLAN and attach vlan interface to the bridge. A bridge receives untagged traffic of one LAN. Attach guest to that bridge.

Re: KVM trunk to switch

Posted: 2020/04/11 16:18:16
by atux_null
hi. thanks for the reply. that's the idea i am looking for, but i am stuck with the config of the Linux host
-to see the trunk to the switch
-assign VLAN to guest machine from the KVM config

Re: KVM trunk to switch

Posted: 2020/04/11 18:57:53
by jlehtone
atux_null wrote:
2020/04/11 16:18:16
-to see the trunk to the switch
What is there to see? Stuff comes from the wire. Every packet hopefully has some vlan tag. The host needs vlan interfaces only if it needs to be a member of some LANs.

I did list four approaches for the guests. At least two of them have nothing about vlans in the KVM config.