环境
操作系统:Centos7.9
网卡信息: eth0 192.168.1.10 用于管理
eth1 业务网口,连接华为换机g0/0/10 trunk模式
业务vLan ID:vlan10
kvm虚拟机:test01
华为交换机配置
int g0/0/10
port link-type trunk
port trunk allow-pass vlan 2 to 4094
操作系统配置
检查8021q模块
检查 Kernel 是否加载了 VLAN 子接口模块,若没有,则加载
lsmod | grep 8021q
临时加载
modprobe 8021q
永久加载
chmod +x /etc/rc.local
vim /etc/rc.local
/sbin/modprobe -a 8021q
网卡配置
cd /etc/sysconfig/network-scripts/
eth1网口配置
vim ifcfg-eth1
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
DEVICE=eth1
创建VLAN子接口配置文件
vim ifcfg-eth1.10
TYPE=Vlan
ONBOOT=yes
VLAN=yes
DEVICE=brvlan10
NAME=brvlan10
BRIDGE=brvlan10
创建网桥配置文件
vim ifcfg-brvlan10
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=none
NAME=brvlan10
DEVICE=brvlan10
重启网卡服务
systemctl restart network
查看网桥信息
brctl show
查看vlan配置信息
more /proc/net/vlan/config
kvm虚拟机xml文件修改
kvm 配置文件
virsh edit test01
<interface type='bridge'>
<mac address='52:54:00:34:26:d1'/>
<source bridge='brvlan10'/>
<target dev='vnet0'/>
<model type='virtio'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>