版权声明:允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。 [url]http://gairuhe.blog.51cto.com/77728/39795[/url]

VLAN&VTP实验2:配置VLAN TrunkVTP<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 
实验等级:Assistant
 
实验拓扑:
<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />
 
 
实验说明:
 
在不同交换机上相同的VLAN内的终端是无法互相通信的,为了解决这个问题,可以将不同交换机通过Trunk链路连接起来。Trunk链路是支持多个VLAN的点到点链路,使用它可以让支持VLAN的设备创建链路时,节省端口。
 
VTP域是由一组VTP域名相同的互相连接的交换机组成。一个交换机只能在一个VTP域内。它可以减少在配置改变时可能引起的配置不一致的问题,并且可以减少对于VLAN的操作。
 
 
基本配置:
 
PC1
PC1(config)#int fa0/0
PC1(config-if)#ip add 12.1.1.1 255.255.255.0
PC1(config-if)#no sh   
 
PC2
PC2(config)#int fa0/0
PC2(config-if)#ip add 12.1.1.2 255.255.255.0
PC2(config-if)#no sh
 
PC3
PC3(config)#int fa0/0
PC3(config-if)#ip add 23.1.1.3 255.255.255.0
PC3(config-if)#no sh
 
SW1
SW1(config)#int fa1/11
SW1(config-if)#speed 100
SW1(config-if)#duplex full
SW1(config-if)#no sh
SW1(config-if)#int fa1/1
SW1(config-if)#no sh
 
SW2
SW2(config)#int fa1/11
SW2(config-if)#speed 100
SW2(config-if)#duplex full
SW2(config-if)#no sh
SW2(config-if)#int fa1/12
SW2(config-if)#speed 100
SW2(config-if)#duplex full
SW2(config-if)#no sh
SW2(config-if)#int fa1/2
SW2(config-if)#no sh
 
测试连通性,在PC1ping  PC2
    PC1#ping 12.1.1.2

 

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.1.1.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 72/432/1136 ms
可以ping
 
SW1SW2上建立VLAN,并且将相应的端口划分到VLAN
 
    SW1#vlan database
SW1(vlan)#vlan 3
VLAN 3 added:
        Name: VLAN0003
SW1(vlan)#exit
APPLY completed.
Exiting....
SW1#
SW1#conf t
SW1(config)#int fa1/11
SW1(config-if)#switchport access vlan 3
 
查看VLAN信息:
 
SW2#vlan da
SW2(vlan)#vlan 3
VLAN 3 added:
    Name: VLAN0003
SW2(vlan)#vlan 5
VLAN 5 added:
    Name: VLAN0005
SW2(vlan)#exit
APPLY completed.
Exiting....
SW2#
SW2#conf t
SW2(config)#int fa1/11
SW2(config-if)#sw ac vla 3
SW2(config-if)#int fa1/12
SW2(config-if)#sw ac vla 5
 
查看VLAN信息:
 
 
回到PC1上尝试ping PC2
    PC1#ping 12.1.1.2

 

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.1.1.2, timeout is 2 seconds:
......
Success rate is 0 percent (0/5)
此时已经无法ping
 
 
实验步骤:
 
 
1.SW1Fa1/1SW2Fa1/2端口设置为trunk端口:
 
SW1#conf t
SW1(config)#int fa1/1
SW1(config-if)#switchport mode trunk
SW2#conf t
SW2(config)#int fa1/2
SW2(config-if)#switchport mo tr
 
查看端口信息:
 
此时在回到PC1ping  PC2
PC1#ping 12.1.1.2

 

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.1.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 48/80/120 ms
通了。
 
 
2.Trunk的帧标识
在以太网的Trunk链路上,有两种帧标识的方法。分别为ISL(交换机间连接)和IEEE 802.1Qdot1q
 
ISLCisco私有的。它的标识方法是:在以太网帧上装上一个26字节的ISL头(包含VLAN ID信息)和4字节的CRC。这种封装格式不会改变以原有的以太网帧。
 
802.1Q是国际标准,任何厂商都支持。它的标识方法是:在原有的以太网帧内部插入一个4字节的标记头,然后改变原有以太网帧的CRC。这种封装格式会改变原有的以太网帧。
 
3.VTP
 
一个交换机只能位于具有相同域名的一个VTP域中。所以在使用VTP时,必须先配置VTP域名。
VTP有三种模式:Server(服务器),Client(客户),Transparent(透明)
 
 
在这个实验中,将域名设置为gairuhe,将SW2设置为ServerSW1设置为Client
首先查看VTP的状态
 
 
默认情况下,所以的交换机都为Server模式,并且域名为空(Null
 
 
改变交换机的域名:
SW1#vlan data
SW1(vlan)#vtp domain gairuhe
Changing VTP domain name from NULL to gairuhe
SW1(vlan)#exit
APPLY completed.
Exiting....
SW2(vlan)#vtp domain gairuhe
Domain name already set to gairuhe .
SW2(vlan)#exit
APPLY completed.
Exiting....
 
这里可以看到,当我们将SW1的域名设置为gairuhe时,SW2的域名就会学习,并且也设置为gairuhe
 
到这里,再次查看SW1VLAN信息:
 
 
这里只有VLAN3.
现在将SW1设置成为Client模式
SW1#vlan database
SW1(vlan)#vtp client
Setting device to VTP CLIENT mode.
 
再次查看SW1VLAN信息:
 
 
发现多了一个VLAN5,这是从服务器SW2学习过来的。
 
 
SW1上尝试创建一个VLAN 10
SW1#vlan database
SW1(vlan)#vlan 10
VLAN 10 added:
    Name: VLAN0010
SW1(vlan)#exit
In CLIENT state, no apply attempted.
Exiting....
这里可以看出,处于Client模式的交换机不能创建,修改,删除VLAN
 
 
关于VTP三种模式的区别,可以参考下表:

 

 

VTP 模式
描述
Server
默认模式。可以创建、删除、修改 VLAN 。可以指定本 VTP 域中所有交换机的配置参数。 VTP 服务器在本 VTP 域中想其它交换机通告 VLAN 信息,同时根据从 Trunk 链路上接收到的通告,对本域中其它交换机的 VLAN 进行同步。
VLAN 的配置存入 NVRAM 中。
Client
不能创建、删除、修改 VLAN
VLAN 的配置不存入 NVRAM
Transparent
处于此种模式的交换机不参与到 VTP 域中。不通告自己的 VLAN 配置,也不会根据接受到的通告同步自己的 VLAN 配置。在 VTP 版本二中,透明模式的交换机会转发接受到的通告。可以在这种模式下创建、删除、修改 VLAN 信息。
VLAN 的配置存入 NVRAM 中,但是不会通告出去。