redhat7  官网配置参考:

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/sec-Configure_802_1Q_VLAN_Tagging_Using_the_Command_Line.html



1, yum install -y vconfig

2, modprobe 8021q

   lsmod | grep 8021q

3, 复制ifcfg-eth0到ifcfg-eth0.100,注意eth0是必须启用的,但不需要填写IP地址,就像交换机一样。

   关键点:将ONBOOT设置为yes,将BOOTPROTO设置为none


   

DEVICE=ethX
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes

4, 编辑ifcfg-eth0.4文件,将ONBOOT设置为yes,将BOOTPROTO设置为static或dhcp,

   就像配置普通的网卡一样进行配置,配置结束后重启网络,利用ping检查网络是否畅通

   

DEVICE=ethX.192
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.1
PREFIX=24
NETWORK=192.168.1.0
VLAN=yes

5, /etc/init.d/network  restart


6,echo "modprobe 8021q"  >> /etc/rc.local