#modprobe 8021q 用命令 lsmod | grep 8021q 来检查
以配置网卡eth0为例,添加vlan号:1002
=========================================
cd /etc/sysconfig/network-scripts/
vi ifcfg-eth0
把IP地址信息删掉,将ONBOOT设置为yes,将BOOTPROTO设置为none。NM_CONTROLLED改为no。
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
===========================================
#vconfig add eth0 1002 1002为vlan号,根据实际vlan配置 通过命令 ls /proc/net/vlan 查看
=============================================
cp ifcfg-eth0 ifcfg-eth0.1002
vi ifcfg-eth0.1003 配置IP信息。
修改DEVICE=eth0.1003
IPADDR=10.128.3.116
NETMASK=255.255.255.0
最后重启network,service network restart
测试一下:
ifconfig查看ifcfg-eth0.1003网卡配置是否正确
ping下光口地址对应的网关:
ping 10.128.3.254
=====================================================
两个网段:
B列的服务器:10.128.2.0 vlan: 1002
C列的服务器:10.128.3.0 vlan: 1003
-------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
命令:
modprobe 8021q
vconfig add eth0 1003
cd /etc/sysconfig/network-scripts/
echo modprobe 8021q >> /etc/rc.local
echo vconfig add eth0 1003 >> /etc/rc.local
cd /etc/sysconfig/network-scripts/
sed -i "s/ONBOOT=no/ONBOOT=yes/g" ifcfg-eth0
sed -i "s/NM_CONTROLLED=yes/NM_CONTROLLED=no/g" ifcfg-eth0
sed -i "s/BOOTPROTO=dhcp/BOOTPROTO=none/g" ifcfg-eth0
cp ifcfg-eth0 ifcfg-eth0.1003
vi ifcfg-eth0.1003
service network restart