linux安装VLAN,系统怎么划分VLAN打标签上交换机

前几天公司一台物理机需要连接公网,但是公网需要网卡打标签上去。

由于没有做过linux主机划分VLAN的操作,因此去查了一下,需要利用vconfig这个命令。

但是纠结的是,系统源中没有这个包。(很坑爹的一件事,找了很久才知道)

最后解决的办法是找到了第三方源:

rpm -e epel-release
#首先卸载以前装的epel 以免影响
wget -P /etc/yum.repos.d/  http://mirrors.aliyun.com/repo/epel-6.repo
# 下载阿里提供的epel 
yum makecache
#更新缓存
yum -y install vconfig

 利用这个顺利的装上了vconfig这个命令。

打标签的话也很简单,分为这几步:

1.安装vlan(vconfig)和加载8021q模块
#aptitude install vlan
#modprobe 8021q
或:
#yum install vconfig
#modprobe 8021q
#lsmod |grep -i 8021q
2.先将VLAN划分出来,注意这个是在物理网卡上做的
#vconfig add eth0 100
#vconfig add eth0 200 在eth0接口上配置两个VLAN
#vconfig set_flag eth0.100 1 1
#vconfig set_flag eth0.200 1 1
#设置VLAN的REORDER_HDR参数,默认就行了。 可以使用cat /proc/net/vlan/eth0.100查看eth0.100参数 配置网络信息
#ifconfig eth0 0.0.0.0
#ifconfig eth0.100 192.168.100.50 netmask 255.255.255.0 up
#ifconfig eth0.200 192.168.200.50 netmask 255.255.255.0 up
删除VLAN命令
#vconfig rem eth0.100 #vconfig rem eth0.200 
原文地址:https://www.cnblogs.com/sexiaoshuai/p/7171449.html