centos网卡子接口配置(带vlan)
1.检查OS是否加载802.1q模块
[root@agent network-scripts]# modinfo 8021q
filename: /lib/modules/5.4.200-1.el7.elrepo.x86_64/kernel/net/8021q/8021q.ko
version: 1.8
license: GPL
alias: rtnl-link-vlan
srcversion: 634123A919317BAF16A45A8
depends: mrp,garp
retpoline: Y
intree: Y
name: 8021q
vermagic: 5.4.200-1.el7.elrepo.x86_64 SMP mod_unload modversions
2.如果没有加载如何加载802.1q模块
modprobe 8021q ###加载模块
lsmod | grep 8021q ##检查模块是否正常加载
3.父接口eth3随意配置,子接口eth3.1000如下配置
[root@agent network-scripts]# cat ifcfg-eth3.1000
TYPE=vlan
PHYSDEV=eth3
BOOTPROTO=static
NAME=eth3.1000
DEVICE=eth3.1000
ONBOOT=yes
IPADDR=172.31.255.249
PREFIX=30
GATEWAY=172.31.255.250
VLAN=yes
VLAN_ID=1000
3.配置完后重启网络服务
service network restart
3.配置成功后可看到如下文件
[root@agent network-scripts]# ls /proc/net/vlan/
config eth3.1000
[root@agent network-scripts]# cat /proc/net/vlan/config
VLAN Dev name | VLAN ID
Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD
eth3.1000 | 1000 | eth3
[root@agent network-scripts]# cat /proc/net/vlan/eth3.1000
eth3.1000 VID: 1000 REORDER_HDR: 1 dev->priv_flags: 1021
total frames received 12258
total bytes received 4891918
Broadcast/Multicast Rcvd 0
total frames transmitted 7825
total bytes transmitted 821754
Device: eth3
INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0
EGRESS priority mappings: