1.网卡上联到trunk端口
2.编辑网卡配置文件,cat /etc/sysconfig/network-scripts/ifcfg-eth0,内容如下:
# Generated by VMWare customization engine. DEVICE=eth0 ONBOOT=yes
2.cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.202 #新建vlan202子接口文件
cat /etc/sysconfig/network-scripts/ifcfg-eth0.202,内容如下:
PHYSDEV=eth0 VLAN=YES TYPE=Vlan VLAN_ID=202 NAME=eth0.202 REORDER_HDR=yes GVRP=no MVRP=no ONBOOT=yes DEFROUTE=yes IPV4_FAILURE_FATAL=yes BOOTPROTO=none IPADDR=10.10.202.13 NETMASK=255.255.255.0 GATEWAY=10.10.202.254
2.重启网卡服务,如果报错则 systemctl restart NetworkManager。如果之前该机器配置过网卡,则还要删掉默认路由,vim /etc/sysconfig/network 删除默认网关行