[root@bogon net]# modprobe --first-time 8021q
[root@bogon net]# lsmod | grep 8021
8021q 33208 0
garp 14384 1 8021q
mrp 18542 1 8021q
[root@bogon net]#
在 /etc/sysconfig/network-scripts/
目录中配置 VLAN 接口。配置文件名应为上级接口加上 .
字符再加上 VLAN ID 号码。例如:如果 VLAN ID 为 100,上级接口为 ens33,那么配置文件名应为 ifcfg-ens33.100
[root@bogon network-scripts]# vim ifcfg-ens33.100
DEVICE=ens33.100
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
VLAN=yes
[root@bogon network-scripts]# systemctl restart network
注:如果需要在同一接口 eth0 中配置第二个 VLAN,比如 VLAN ID 200,请添加名为 ens33.200
的新文件,文件中包含 VLAN 配置详情。
知识补充:
各种模块文件已经存在 /lib/modules/3.10.0-957.el7.x86_64/kernel/ 中,用的时候只需要加载即可
vlan信息文件存在 /proc/net/vlan/ 这里
原文链接:Centos7.6配置802.1Q VLAN 标记或网卡子接口,转载请注明来源!