CentOS 7 linux bridge 配置vlan

一、实例

物理网卡:eth0(已经提前将网卡名称改为eth0)
linux bridge:brvlan10,brvlan20
vlan接口:eth0.10,eth0.20

二、配置过程

1、下载vconfig、加载8021q模块并验证

[root@localhost ~]# yum install -y vconfig
[root@localhost ~]# modprobe 8021q
[root@localhost ~]# lsmod | grep 802
8021q                  33208  0 
garp                   14384  1 8021q
mrp                    18542  1 8021q
[root@localhost ~]# 

2、添加网卡接口

[root@localhost ~]# vconfig add eth0 10
[root@localhost ~]# vconfig add eth0 20

3、检查/proc/net/vlan目录

[root@localhost ~]# ls /proc/net/vlan/
config  eth0.10  eth0.20
[root@localhost ~]# 

4、配置brvlan10、brvlan20
进入/etc/sysconfig/network-scripts

[root@localhost network-scripts]# cat ifcfg-brvlan10
TYPE=Bridge
BOOTPROTO=static
PROXY_METHOD=none
BROWSER_ONLY=no
IPV4_FAILURE_FATAL=no
NAME=brvlan10
DEVICE=brvlan10
ONBOOT=yes
[root@localhost network-scripts]# cat ifcfg-brvlan20
TYPE=Bridge
BOOTPROTO=static
PROXY_METHOD=none
BROWSER_ONLY=no
IPV4_FAILURE_FATAL=no
NAME=brvlan20
DEVICE=brvlan20
ONBOOT=yes
[root@localhost network-scripts]# 

5、配置eth0.10,eth0.20

[root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-eth0.10 
[root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-eth0.20 

具体配置:

[root@localhost network-scripts]# cat ifcfg-eth0.10 
TYPE=Vlan
VLAN=yes
NAME=eth0.10
DEVICE=eth0.10
ONBOOT=yes
BRIDGE=brvlan10
BOOTPROTO=static
[root@localhost network-scripts]# cat ifcfg-eth0.20 
TYPE=VLAN
VLAN=yes
BOOTPROTO=static
NAME=eth0.20
DEVICE=eth0.20
ONBOOT=yes
BRIDGE=brvlan20
[root@localhost network-scripts]# 

6、重启网络服务

[root@localhost network-scripts]# systemctl restart network

参考文章:

https://blog.csdn.net/yinqingwang/article/details/8867518
http://blog.51cto.com/4153087/2089390

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(linux)