Please refer to the following link:
https://developers.redhat.com/blog/2017/09/14/vlan-filter-support-on-bridge/
This article shows how to turn on the vlan filter of the bridge under linux
Starting from linux 3.8, linux supports the opening of vlan filter on the bridge, this function can make the linux bridge close to the switching function of a real switch, and supports vlan awareness, with the SVI virtual interface, it can be on the same bridge Complete the VLAN isolation and routing process between VLANs without creating a separate network bridge for each VLAN network
Assuming that there is a bridge br0, the command to open a bridge's vlan filter is as follows:
ip link set br0 type bridge vlan_filtering 1 # echo 1 > /sys/class/net/br0/bridge/vlan_filtering bridge vlan add dev veth0 vid 100 pvid untagged master bridge vlan add dev veth1 vid 200 pvid untagged master
Set the VLAN sub-interface command as follows:
ip link add link br0 name br0.100 type vlan id 100 ip addr add 192.168.10.1/24 dev br0.100 ip link add link br0 name br0.200 type vlan id 200 ip addr add 192.168.11.1/24 dev br0.200
VM1 and VM2 Point to the default gateway:
ip route rep default via 192.168.10.1 ip route rep default via 192.168.11.1
Node: The above commands have not been tested and perfected, and come from external sources
Confirm the command as follows:
set interfaces bridge br1 member interface eth0 vlan 10 pvid set interfaces bridge br1 member interface eth0 vlan 10 untagged set interfaces bridge br1 vif 10 address 10.1.1.1/24