|
马上注册成为ROSABC会员,随时发帖回复。
您需要 登录 才可以下载或查看,没有账号?会员注册
x
一、理论支持
Native vlan是思科交换机上默认存在的一种vlan,默认情况下Vlan 1为native vlan。native并不是一种特殊的vlan,仅仅是该vlan在穿越Dot.1Q封装的Trunk时不打上Tag字段而已,也就是不包含32bit的Tag,同时交换机收到一个不打tag的帧只会把该帧转给Native vlan。我们拿一个真实的包来讲解这32bit的Ta
TPID:用来标识本数据帧是带有VLAN Tag的数据帧.该字段长度为16bit,0x0800-IP,如图中红色上层协议为IP Priority:用来表示802.1P的优先级.该字段为3bit,如图中黑色字体为尽力而为的QoS,即0CFI:用来标识MAC地址是否以标准格式进行封装.该字段长度为1bit,取值为0表示MAC地址以标准格式进行封装,为1表示以非标准格式封装,缺省取值为0.图中蓝色所示VLAN ID:用来标识报文所属VLAN的编号.该字段长度为12bit,取值范围为0-4095.由于0和4095通常不使用,所以VLAN ID的取值范围为1~4094,如图中红色的2为vlan2:
二、拓扑描述
如图所示,Sw1和Sw2的10口连接了两台PC(路由器模拟),两台交换机通过trunk链路相连
三、实验步骤
①完成路由器接口的配置以及交换机上VLAN的配置
R1(config)#interface FastEthernet0/0
R1(config-if)# ip address 10.1.1.1 255.255.255.0!
R2(config)#interface FastEthernet0/0
R2(config-if)# ip address 10.1.1.2 255.255.255.0
下面完成交换机上VLAN的配置,以及划分VLAN,注意Sw1的10口属于VLAN10,Sw2的10口属于VLAN100
SW1:
Sw1(config)#vlan 10
Sw1(config)#int f0/10
Sw1(config-if)#switchport mode access
Sw1(config-if)#switchport access vlan 10---VLAN 10!
Sw2:
Sw2(config)#vlan 100
Sw2(config-vlan)#exit
Sw2(config)#int f0/10
Sw2(config-if)#switchport mode access
Sw2(config-if)#switchport access vlan 100
②完成Trunk的配置,并修改Native Vlan
Sw1(config-if)#interface FastEthernet0/5
Sw1(config-if)# switchport trunk encapsulation dot1q
Sw1(config-if)# switchport trunk native vlan 10---修改Native Vlan为10
Sw1(config-if)# switchport mode trunk
Sw1(config-if)# switchport nonegotiate!
Sw2(config)#interface FastEthernet0/5
Sw2(config-if)# switchport trunk encapsulation dot1q
Sw2(config-if)# switchport trunk native vlan 100---修改Native Vlan为100
Sw2(config-if)# switchport mode trunk
Sw2(config-if)# switchport nonegotiate
*Mar 1 07:05:04.730: %CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/5 (100), with Sw1 FastEthernet0/5 (10).---此时会有CDP的报错,告知两端的native Vlan不匹配,不用理会
Sw2#sh int trunk
Port Mode Encapsulation Status Native vlan
Fa0/5 on 802.1q trunking 100
此时数据包并不通,因为此时由于开启了spanning,而spanning检测到两端的PVID(Port Vlan ID)不一致,会block trunk链路
*Mar 1 00:02:22.212: %SPANTREE-2-RECV_PVID_ERR: Received BPDU with inconsistent peer vlan id 100 on FastEthernet0/5 VLAN1.
*Mar 1 00:02:22.212: %SPANTREE-2-BLOCK_PVID_LOCAL: Blocking FastEthernet0/5 on VLAN0001. Inconsistent local vlan..
show spanning vlan 100也会看到PVID不一致。所以此时我们要关掉spanning tree
Sw2#sh spanning-tree vlan 100
VLAN0100
Spanning tree enabled protocol ieee
Root ID Priority 32868
Address 0016.9dd7.5180
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32868 (priority 32768 sys-id-ext 100)
Address 0016.9dd7.5180
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Fa0/5 Desg BKN*19 128.5 P2p *PVID_Inc
Fa0/10 Desg FWD 19 128.10 P2p
让我们关掉spanning tree:
Sw1(config)#no spanning-tree vlan 10!
Sw2(config)#no spanning-tree vlan 100
就像我们前面分析的一样,Sw2收到一个不打tag的帧,会转给Native Vlan,也就是Vlan 100,那么Sw2会把包转到10口,反之依然,我们来做最直观的验证:
R1#ping 10.1.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.2, timeout is 2 seconds:!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
③发散我们的思维,如果此时我们把Sw2的10口划分到Vlan 10,数据会不会通呢?注意在Sw2上Vlan 10并不是native,SW2收到不打tag的帧只会转到native vlan,所以此时数据包不通!
Sw2(config)#int f0/10
Sw2(config-if)#switchport access vlan 10
R1#ping 10.1.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.2, timeout is 2 seconds:.....
Success rate is 0 percent (0/5)
最后也可以给native vlan打上tag Sw2(config)#vlan dot1q tag native 此时,Trunk上的Native也被打上了Tag,那么,vlan10 的流量到达Sw2,Sw2只会把Vlan10的流量转给Vlan10,所以此时才会通:
R1#ping 10.1.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.2, timeout is 2 seconds:!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms |
|