博达交换机VLAN隔离配置[S3224]

Switch_config#show run

Building configuration...

Current configuration:

!

ervice timestamps log date

ervice timestamps debug date

!

!

interface FastEthernet0/1                   //端口1

witchport mode trunk                      //设定成trunk模式,允许端口属于多个vlan

witchport pvid 2                              //数据入端口时加上vlan1的tag

witchport trunk vlan-allowed 1,24      //端口可以属于vlan1和24

witchport trunk vlan-untagged 1,24   //数据出端口时去除tag1和tag24

!

interface FastEthernet0/2                  //端口2

witchport mode trunk                     //设定成trunk模式

witchport pvid 2                             //数据入端口时加上vlan2的tag

witchport trunk vlan-allowed 2,24     //端口同时可属于vlan2和24

witchport trunk vlan-untagged 2,24  //数据出端口时去除tag2和tag24

!

interface FastEthernet0/3                  //同上

witchport mode trunk

witchport pvid 3

witchport trunk vlan-allowed 3,24

witchport trunk vlan-untagged 3,24

!

interface FastEthernet0/4

witchport mode trunk

witchport pvid 4

witchport trunk vlan-allowed 4,24

witchport trunk vlan-untagged 4,24

!

interface FastEthernet0/5

witchport mode trunk

witchport pvid 5

witchport trunk vlan-allowed 5,24

witchport trunk vlan-untagged 5,24

!

interface FastEthernet0/6

witchport mode trunk

witchport pvid 6

witchport trunk vlan-allowed 6,24

witchport trunk vlan-untagged 6,24

!

interface FastEthernet0/7

witchport mode trunk

witchport pvid 7

witchport trunk vlan-allowed 7,24

witchport trunk vlan-untagged 7,24

!

interface FastEthernet0/8

witchport mode trunk

witchport pvid 8

witchport trunk vlan-allowed 8,24

witchport trunk vlan-untagged 8,24

!

interface FastEthernet0/9

witchport mode trunk

witchport pvid 9

witchport trunk vlan-allowed 9,24

witchport trunk vlan-untagged 9,24

!

interface FastEthernet0/10

witchport mode trunk

witchport pvid 10

witchport trunk vlan-allowed 10,24

witchport trunk vlan-untagged 10,24

!         

interface FastEthernet0/11

witchport mode trunk

witchport pvid 11

witchport trunk vlan-allowed 11,24

witchport trunk vlan-untagged 11,24

!

interface FastEthernet0/12

witchport mode trunk

witchport pvid 12

witchport trunk vlan-allowed 12,24

witchport trunk vlan-untagged 12,24

!

interface FastEthernet0/13

witchport mode trunk

witchport pvid 13

witchport trunk vlan-allowed 13,24

witchport trunk vlan-untagged 13,24

!

interface FastEthernet0/14

witchport mode trunk

witchport pvid 14

witchport trunk vlan-allowed 14,24

witchport trunk vlan-untagged 14,24

!

interface FastEthernet0/15

witchport mode trunk

witchport pvid 15

witchport trunk vlan-allowed 15,24

witchport trunk vlan-untagged 15,24

!

interface FastEthernet0/16

witchport mode trunk

witchport pvid 16

witchport trunk vlan-allowed 16,24

witchport trunk vlan-untagged 16,24

!

interface FastEthernet0/17

witchport mode trunk

witchport pvid 17

witchport trunk vlan-allowed 17,24

witchport trunk vlan-untagged 17,24

!

interface FastEthernet0/18

witchport mode trunk

witchport pvid 18

witchport trunk vlan-allowed 18,24

witchport trunk vlan-untagged 18,24

!

interface FastEthernet0/19

witchport mode trunk

witchport pvid 19

witchport trunk vlan-allowed 19,24

witchport trunk vlan-untagged 19,24

!

interface FastEthernet0/20

witchport mode trunk

witchport pvid 20

witchport trunk vlan-allowed 20,24

witchport trunk vlan-untagged 20,24

!

interface FastEthernet0/21

witchport mode trunk

witchport pvid 21

witchport trunk vlan-allowed 21,24

witchport trunk vlan-untagged 21,24

!

interface FastEthernet0/22

witchport mode trunk

witchport pvid 22

witchport trunk vlan-allowed 22,24

witchport trunk vlan-untagged 22,24

!

interface FastEthernet0/23

witchport mode trunk

witchport pvid 23

witchport trunk vlan-allowed 23-24

witchport trunk vlan-untagged 23-24

!

interface FastEthernet0/24                    //端口24,本例中作为上行口

witchport mode trunk                         //设为trunk模式

witchport pvid 24                               //数据入端口时加上vlan24的tag

witchport trunk vlan-untagged all          //数据出端口时去除所有tag(tag1'tag24)

!                                                         //注意trunk口时默认属于所有tag的!

vlan 1-24                                             //建立1'24个vlan,默认情况下只有vlan1,其他需要增加,且这个操作时第一步要做的!

!

!说明,本例子完成之后,interface f0/1'f/23分别属于不同的vlan,相互之间是不能互通的(不考虑使用三层路由转发的情况),但此时这23个端口都能与上行口interface f0/24口通讯!

此时的vlan分配情况为:

Switch_config#show vlan

VLAN Status  Name                             Ports

---- ------- -------------------------------- ---------------------------------

1    Static  Default                          F0/1, F0/24

2    Static  VLAN0002                         F0/2, F0/24

3    Static  VLAN0003                         F0/3, F0/24

4    Static  VLAN0004                         F0/4, F0/24

5    Static  VLAN0005                         F0/5, F0/24

6    Static  VLAN0006                         F0/6, F0/24

7    Static  VLAN0007                         F0/7, F0/24

8    Static  VLAN0008                         F0/8, F0/24

9    Static  VLAN0009                         F0/9, F0/24

10   Static  VLAN0010                         F0/10, F0/24

11   Static  VLAN0011                         F0/11, F0/24

12   Static  VLAN0012                         F0/12, F0/24

13   Static  VLAN0013                         F0/13, F0/24

14   Static  VLAN0014                         F0/14, F0/24

15   Static  VLAN0015                         F0/15, F0/24

16   Static  VLAN0016                         F0/16, F0/24

17   Static  VLAN0017                         F0/17, F0/24

18   Static  VLAN0018                         F0/18, F0/24

19   Static  VLAN0019                         F0/19, F0/24

20   Static  VLAN0020                         F0/20, F0/24

21   Static  VLAN0021                         F0/21, F0/24

22   Static  VLAN0022                         F0/22, F0/24

23   Static  VLAN0023                         F0/23, F0/24

24   Static  VLAN0024                         F0/1, F0/2, F0/3, F0/4, F0/5

F0/6, F0/7, F0/8, F0/9, F0/10

F0/11, F0/12, F0/13, F0/14, F0/15

F0/16, F0/17, F0/18, F0/19, F0/20

F0/21, F0/22, F0/23, F0/24简单分析一下工作流程:

1、f0/2和f0/3之间的通信,

Switch_config#show vlan inter f0/2

Interface            VLAN

Name                 Property PVID Vlan-Map         uTagg-VLan-Map

-------------------- -------- ---- ---------------- ----------------

FastEthernet0/2      Trunk    2    2,24             2,24

Switch_config#show vlan inter f0/3

Interface            VLAN

Name                 Property PVID Vlan-Map         uTagg-VLan-Map

-------------------- -------- ---- ---------------- ----------------

FastEthernet0/3      Trunk    3    3,24             3,24

从中我们可以看到,f0/2是属于vlan2和vlan的,且pvid为2,那就是说普通数据(非802.1q)进入这个端口时会被打上tag2,然后 zhge报通过交换机到达f0/3时,端口三是指能够untagvlan3和vlan24的的tag的,这个可以从上面的 show vlan inter f0/3看出来,所以f0/3无法识别从f0/2过来的数据包!反过来也是一样的!

换句话说就是实现了vlan2和vlan3的隔离!

2、f0/2和f0/24之间的通信,

Switch_config#show vlan inter f0/2

Interface            VLAN

Name                 Property PVID Vlan-Map         uTagg-VLan-Map

-------------------- -------- ---- ---------------- ----------------

FastEthernet0/2      Trunk    2    2,24             2,24

Switch_config#show vlan inter f0/24

Interface            VLAN

Name                 Property PVID Vlan-Map         uTagg-VLan-Map

-------------------- -------- ---- ---------------- ----------------

FastEthernet0/24     Trunk    24   1-24             1-2

同上面的分析方法,f0/2进入的数据被打上了tag2,但是由于f0/24是untag all的,所以他能够去除tag2,或者是识别vlan2的数据!反过来也是一样,数据进入f0/24时打上了tag24,这个标记在f0/2口上是能够被去除的!所以f0/2口和f0/24口可以实现互通!

上面的两个通信过程基本代表了这种vlan配置/应用的功能,即:所有的下行口都能相互隔离,但是所有的下行口都能与上行口通讯!这种vlan配置方式比较简单,也非常常用!大家可以参考应用!

当然这种方式的vlan划分是局限在一台交换机上面的!一般情况下在中小规模的应用中比较常见,特点是完全由一台交换机来实现vlan的隔离/互通,且每一个端口的输出数据都是不带有tag的,是普通的ip数据包,用户绝大多数的数据设备都能识别!(一般的网卡是无法识别802.1q的数据包的)还有一个优点是,这个交换机上面使用过的vlan号在其他交换机上面可以重复使用,没有限制或者相关性!

还有一种应用是跨交换机的vlan配置!

这种方式下要考虑多台交换机的相互协调工作,比如vlan tag的“加和“去”的问题!

还是以实现上面例子为例,

Switch_config#show run

Building configuration...

Current configuration:

!

ervice timestamps log date

ervice timestamps debug date

!

!

interface FastEthernet0/1

!

interface FastEthernet0/2

witchport pvid 2

!

interface FastEthernet0/3

witchport pvid 3

!

interface FastEthernet0/4

witchport pvid 4

!

interface FastEthernet0/5

witchport pvid 5

!

interface FastEthernet0/6

witchport pvid 6

!

interface FastEthernet0/7

witchport pvid 7

!

interface FastEthernet0/8

witchport pvid 8

!

interface FastEthernet0/9

witchport pvid 9

!

interface FastEthernet0/10

witchport pvid 10

!

interface FastEthernet0/11

witchport pvid 11

!

interface FastEthernet0/12

witchport pvid 12

!

interface FastEthernet0/13

witchport pvid 13

!

interface FastEthernet0/14

witchport pvid 14

!

interface FastEthernet0/15

witchport pvid 15

!

interface FastEthernet0/16

witchport pvid 16

!

interface FastEthernet0/17

witchport pvid 17

!

interface FastEthernet0/18

witchport pvid 18

!

interface FastEthernet0/19

witchport pvid 19

!

interface FastEthernet0/20

witchport pvid 20

!

interface FastEthernet0/21

witchport pvid 21

!

interface FastEthernet0/22

witchport pvid 22

!

interface FastEthernet0/23

witchport pvid 23

!

interface FastEthernet0/24

witchport mode trunk

witchport trunk vlan-untagged all

!

vlan 1-24

!

!

在这个配置里面,我们可以看到,除了上行口之外,所有的端口都属于access模式,就是说端口只是属于一个vlan,而f0/24上行口虽然和前面一样都是trunk,但是没有必要指定pvid号,原因是因为在这个配置里面这个参数不是很重要!

因为下行口的数据网上走时,相应的tag都能被f0/24识别(tag号不去除),但下行数据打上什么tag就不是f0/24来确定了,这个参数多是由对方交换机来确定的或者是由对方路由器(封装子接口,802.1q)来确定的!这第二种方式,关于对方的配置情况就比较复杂:

1、如果是博达自己的交换机,那么配置就相对简单,方法如前所述;最简单的配是:两台BDCOM交换机按照楼上的配置即可实现vlan的相互隔离和通信,方法是把他们的f0/24口连接起来即可,然后即可实现两台交换机的号码相同的口互通,号码不同的口不能通信!

2、如果对方是支持802.1q的路由器,比如BDCOM的2621路由器,在其子接口下面封装相应的vlan即可!如:

interface FastEthernet0/0.1

ip address *.*.*.*

o ip directed-broadcast

encapsulation dot1Q 2

andwidth 100000

delay 1

!

interface FastEthernet0/0.2

ip address *.*.*.*

o ip directed-broadcast

encapsulation dot1Q 3

andwidth 100000

delay 1

!

interface FastEthernet0/0.3

ip address *.*.*.*

o ip directed-broadcast

encapsulation dot1Q 4

andwidth 100000

delay 1

!