VLAN (虚拟局域网) 叙述 <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

一个VLAN=一个广播域=逻辑网段(子网)

VLAN 运作:

每个逻辑的VLAN就像一个独立的物理桥

交换机上的每个端口都可以划分给不同的VLAN

默认下,所有的端口都属于VLAN1

同一个VLAN 可以跨越多个交换机

TRUNK 功能支持多个VLAN的数据

Trunk上使用了特殊的封装格式支持不同的VLAN

只有快速以太网口可以配置为主干端口

VLAN 可以增加网络的安全性、灵活性和可扩展性

VLAN 分为动态VLAN和静态VLAN

 

VLAN 的网络管理方式:

1 通过将某个端口配置到合适VLAN中,就可以实现网络的添加、转移和改变

2 VLAN 可以增强网络的安全性

3 VLAN 增加了广播域的数量同时也减小了广播域的范围

VLAN Trunk

交换机对帧进行VLAN标记有两种:ISLIEEE802.1Q这两种协议

 

VLAN 干道:对于多个VLAN交换机来说,VLAN干线是两个交换机之间的连接,它在两个或两个以上的VLAN间传输通信。每个交换机一定要确定它收到的帧属于那个VLAN

   一个交换机的任何一个端口都必须属于而且只能属于一个VLAN,但当端口配置成Trunk干线后,该端口就失去了他的VLAN标识,可以给该交换机内所有VLAN传输数据。

 

VLAN 配置的基本步骤

1 全局配置模式下,输VLAN ID,进入VLAN配置模式:

Switch(config)#VLAN<vlan-id>

2 VLAN设置名字:

Switch(config-vlan)#name<vlan-name>

3 创建了以太网VLAN之后,接下来把交换机端分配到特定的VLAN里,假如你把端口分配了但不存在VLAN里,那么新的VLAN将自动创建,进入接口配置模式:

  Switch(cinfig)#interface<interface>

 

4 定义 VLAN 端口的成员关系 , 把它定义为接入端口 :

Switch(config-if)#switchport mode access

5 把端口分配进特定的VLAN :

Switch(config-if)#switchport access vlan <vlan-id>

6 配置中继端口 , 定义中继模式 :

Switch(config-if)#switchport trunk encapsulation<isl|dot1q|negotiate>

7 定义端口为层2的中继端口:

Switch(config-if)#switchport mode <dynamic auto|dynamic desirable|trunk>

试验VLAN拓扑图:

试验说明:

在交换机SW1上划分VLAN 2 VLAN 3 。把交换机的F0/2端口放入VLAN 2。把F0/3端口放入VLAN 3

在交换机SW2上划分VLAN 2VLAN 3。把F0/3端口放入VLAN 2,把F0/5端口放入VLAN 3

实验要求:

在交换机SW1 SW2上划分vlan并把指定端口放入vlan内。使用show vlan brief(由于模拟器与真实机器之间的差别,查看VLAN的命令为:show vlan-switch brief

以下是配置内容

SW1:

Router>en

Router#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#host sw1                                            

sw1(config)#exit

sw1#vlan database

sw1(vlan)#vlan 2 name v2                                           

VLAN 2 added:

    Name: v2

sw1(vlan)#vlan 3 name v3

VLAN 3 added:

    Name: v3

sw1(vlan)#exit

sw1#conf tleted.Exiting....

Enter configuration commands, one per line.  End with CNTL/Z.

sw1(config)#int f0/2                                                  

sw1(config-if)#switchport mode access                        

sw1(config-if)#switchport access vlan 2

sw1(config-if)#exit

sw1(config)#int f0/3

sw1(config-if)#switchport mode access                         

sw1(config-if)#switchport access vlan 3

sw1(config-if)#exit

sw1(config)#int f0/1

sw1(config-if)#switchport trunk encapsulation dot1q        

sw1(config-if)#switchport mode trunk                           

sw1(config-if)#switchport trunk allowed vlan all

SW2

Router>en

Router#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#host sw2

sw2(config)#exit

sw2#vlan database

sw2(vlan)#vlan 2 name v2

VLAN 2 added:

    Name: v2

sw2(vlan)#vlan 3 name v3

VLAN 3 added:

    Name: v3

sw2(vlan)#exit

APPLY completed.

Exiting....

sw2#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

sw2(config)#int f0/3

sw2(config-if)#switchport mode access

sw2(config-if)#switchport access vlan 2

sw2(config-if)#exit

sw2(config)#int f0/5

sw2(config-if)#switchport mode access

sw2(config-if)#switchport access vlan 3

sw2(config-if)#exit

sw2(config)#int f0/1

sw2(config-if)#switchport trunk encapsulation dot1q

sw2(config-if)#switchport mode trunk

sw2(config-if)#switchport trunk allowed vlan all

sw2(config-if)#exit

 

下面我们用这条命令来看下VLAN的信息: show vlan-switch brief

 

Sw1

sw1#show vlan-switch brief

 

VLAN Name                             Status    Ports

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

1    default                          active    Fa0/0, Fa0/4, Fa0/5, Fa0/6

                                                Fa0/7, Fa0/8, Fa0/9, Fa0/10

                                                Fa0/11, Fa0/12, Fa0/13, Fa0/14

                                                Fa0/15

2    v2                               active    Fa0/2

3    v3                               active    Fa0/3

1002 fddi-default                     active

1003 token-ring-default               active

1004 fddinet-default                  active

 

Sw2

sw2#show vlan-switch brief

 

VLAN Name                             Status    Ports

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

1    default                          active    Fa0/0, Fa0/2, Fa0/4, Fa0/6

                                                Fa0/7, Fa0/8, Fa0/9, Fa0/10

                                                Fa0/11, Fa0/12, Fa0/13, Fa0/14

                                                Fa0/15

2    v2                               active    Fa0/3

3    v3                               active    Fa0/5

1002 fddi-default                     active

1003 token-ring-default               active

1004 fddinet-default                  active

1005 trnet-default                    active

 

如上面所示:VLAN2   VLAN3  active这样的状态,就证明试验成功!