实验目的:

1、掌握三层交换实现VLAN间通信的基本配置。

2、理解三层交换的实现原理。

实验拓扑:

实验步骤:

1、依据图中拓扑,在SW1和SW2之间部署Trunk链路,配置如下:

SW1(config)#int f0/0

SW1(config-if)#switchport trunk encapsulation dot1q

SW1(config-if)#switchport mode trunk

SW1(config-if)#exit

SW2(config)#int f0/0

SW2(config-if)#switchport trunk encapsulation dot1q

SW2(config-if)#switchport mode trunk

SW2(config-if)#exit

2、部署VTP技术,SW1为Server,SW2为Client,实现VLAN同步,如下:

SW1#vlan database

SW1(vlan)#vtp server

SW1(vlan)#vtp domain PingingLab

SW1(vlan)#vtp password cisco

SW1(vlan)#vlan 10

SW1(vlan)#vlan 20

SW1(vlan)#exit


SW2#vlan database

SW2(vlan)#vtp client

SW2(vlan)#vtp domain PingingLab

SW2(vlan)#vtp password cisco

SW2(vlan)#exit

3、确认VTP信息同步并将接口放入相应VLAN,如下:

SW2#show vlan-switch brief


VLAN Name            Status    Ports

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

1    default             active   Fa0/1,Fa0/2,Fa0/3,Fa0/4,Fa0/5, Fa0/6

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

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

                                Fa0/15

10   VLAN0010          active   

20   VLAN0020                     active   

1002 fddi-default                     active   

1003 token-ring-default               active   

1004 fddinet-default                  active   

1005 trnet-default                    active

可以看到,SW2已经学习到VLAN10和VLAN20,将接口划入,配置如下:

SW2(config)#int f0/1

SW2(config-if)#switchport mode access

SW2(config-if)#switchport access vlan 10

SW2(config-if)#int f0/2

SW2(config-if)#switchport mode access   

SW2(config-if)#switchport access vlan 20

SW2(config-if)#exit

4、根据拓扑为不同PC配置IP地址信息,如下:

PC1(config)#no ip routing 

PC1(config)#int f0/0

PC2(config-if)#no sh

PC1(config-if)#ip address 192.168.10.1 255.255.255.0

PC1(config-if)#exit

PC1(config)#ip default-gateway 192.168.10.254 

PC2(config)#no ip routing

PC2(config)#int f0/0

PC2(config-if)#no sh

PC2(config-if)#ip address 192.168.20.1 255.255.255.0

PC2(config-if)#exit

PC2(config)#ip default-gateway 192.168.20.254

5、在三层交换机上开启三层路由功能,并为不同VLAN定义不同IP,如下:

SW1(config)#ip routing 

SW1(config)#int vlan 10

SW1(config-if)#ip address 192.168.10.254 255.255.255.0

SW1(config-if)#exit

SW1(config)#int vlan 20

SW1(config-if)#ip address 192.168.20.254 255.255.255.0

SW1(config-if)#exit

6、测试三层交换,如下:

①测试主机到网关的连通性

PC1#ping 192.168.10.254


Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.10.254, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 20/227/1036 ms

②测试主机与主机的连通性

PC1#ping 192.168.20.1


Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:

.!!!!

Success rate is 80 percent (4/5), round-trip min/avg/max = 24/48/84 ms

从上面可以看到,通过部署三层交换技术,使得VLAN间的主机能够相互通信。此实验完成。