实验环境配置说明:

    1.将R1的Fa0/1接口的IP设为:10.0.0.2/8,Fa0/2接口的IP设为:20.0.0.1/8
    2.将SW2的Fa0/10接口的IP设为:10.0.0.1/8
    3.将vlan2的IP设为:192.168.1.1/24
    4.将vlan3的IP设为:192.168.2.1/24
    5.将pc1的IP设为:192.168.1.10/24 网关:192.168.1.1
    6.将pc2的IP设为:192.168.2.10/24 网关:192.168.2.1
    7.将pc3的IP设为:192.168.1.20/24 网关:192.168.1.1
    8.将pc4的IP设为:192.168.2.20/24 网关:192.168.2.1
    9.将pc5的IP设为:20.0.0.2/8      网关:20.0.0.1

    实验结果要求:

    pc5能ping通pc1,pc2,pc3,pc4.
    ==========================SW1配置=================================
    SW1(config)#interface range f0/1 -2
    SW1(config-if-range)#switchport mode trunk
    SW1(config)#interface range f0/13 -14
    SW1(config-if-range)#switchport mode trunk

    SW1(config)#vtp domain leaf                                     //创建VTP域名
    SW1#vlan database
    SW1(vlan)#vlan 2

    VLAN 2 added:

        Name: VLAN0002

    SW1(vlan)#vlan 3

    VLAN 3 added:

        Name: VLAN0003
    SW1(vlan)#exit

    SW1(config)#spanning-tree vlan 2 root primary             //设置SW1为vlan2的主根网桥
     VLAN 2 bridge priority set to 8192
     VLAN 2 bridge max aging time unchanged at 20
     VLAN 2 bridge hello time unchanged at 2
     VLAN 2 bridge forward delay unchanged at 15

    SW1(config)#spanning-tree vlan 3 root secondary   //设置SW1为vlan3的辅助根网桥

     VLAN 3 bridge priority set to 16384
     VLAN 3 bridge max aging time unchanged at 20
     VLAN 3 bridge hello time unchanged at 2
     VLAN 3 bridge forward delay unchanged at 15

    SW1(config)#interface range f0/1 -2                         //配置以太网通道
    SW1(config-if-range)#shutdown
    SW1(config-if-range)#channel-group 1 mode on
    SW1(config-if-range)#no shutdown
    SW1(config)#ip routing                                           //开启三层交换路由功能

    =============================SW2配置==========================
    SW2(config)#interface range f0/1 -2
    SW2(config-if-range)#switchport mode trunk
    SW2(config)#interface range f0/13 -14
 
   SW2(config-if-range)#switchport mode trunk
    SW2(config)#interface f0/10
    SW2(config-if)#switchport mode trunk
    SW2(config)#VTP mode client                      //设置SW3为VTP客户机模式

    SW2(config)#spanning-tree vlan 3 root primary  //设置SW2为vlan3的主根网桥
     VLAN 3 bridge priority set to 8192
     VLAN 3 bridge max aging time unchanged at 20
     VLAN 3 bridge hello time unchanged at 2
     VLAN 3 bridge forward delay unchanged at 15
    SW2(config)#spanning-tree vlan 2 root secondary //设置SW2为vlan2的辅助根网桥
     VLAN 2 bridge priority set to 16384
     VLAN 2 bridge max aging time unchanged at 20
     VLAN 2 bridge hello time unchanged at 2
     VLAN 2 bridge forward delay unchanged at 15
   SW2(config)#interface range f0/1 -2           //配置以太网通道
    SW2(config-if-range)#shutdown
    SW2(config-if-range)#channel-group 1 mode on
    SW2(config-if-range)#no shutdown
    SW2(config)#ip routing                        //开启三层交换路由功能
    SW2(config)#interface vlan 2
   SW2(config-if)#ip address 192.168.1.1 255.255.255.0
    SW2(config-if)#no shutdown
    SW2(config-if)#exit
    SW2(config)#interface vlan 3
    SW2(config-if)#ip address 192.168.2.1 255.255.255.0
    SW2(config-if)#no shutdown
    SW2(config-if)#exit

    SW2(config)#interface f0/10
    SW2(config-if)#no switchport                                     //配置路由接口
    SW2(config-if)#ip address 10.0.0.1 255.0.0.0
    SW2(config-if)#no shutdown
    SW2(config)#router rip
    SW2(config-router)#version 2
    SW2(config-router)#no auto-summary
    SW2(config-router)#network 10.0.0.0
    SW2(config-router)#network 192.168.1.0
    SW2(config-router)#network 192.168.2.0

    =======================SW3配置================================

    SW3(config)#interface range f0/13 -14
    SW3(config-if-range)#switchport mode trunk

    SW3(config)#VTP mode client
 
    SW3(config)#interface f0/1
    SW3(config-if)#switchport access vlan 2
    SW3config-if)#exit
    SW3(config)#interface f0/2
    SW3(config-if)#switchport access vlan 3

    SW3(config)#spanning-tree uplinkfast              //配置上行链路
 
    SW3(config)#interface range f0/1 -2                  //配置速端口
    SW3(config-if-range)#spanning-tree portfast
    =====================SW4配置=================================
    SW4(config)#interface range f0/13 -14
    SW4(config-if-range)#switchport mode trunk

    SW4(config)#VTP mode client
 
    SW4(config)#interface f0/1
    SW4(config-if)#switchport access vlan 2
    SW4(config-if)#exit
    SW4(config)#interface f0/2
    SW4(config-if)#switchport access vlan 3
 
    SW4(config)#spanning-tree uplinkfast

    SW4(config)#interface range f0/1 -2
    SW4(config-if-range)#spanning-tree portfast
 

    ==========================R1配置=============================

    R1(config)#interface f0/1
    R1(config-if)#ip address 10.0.0.2 255.0.0.0
    R1(config-if)#no shutdown
    R1(config-if)#exit
    R1(config)#interface f0/2
    R1(config-if)#ip address 20.0.0.1 255.0.0.0
    R1(config-if)#no shutdown
    R1(config-if)#exit
    R1(config)#router rip
    R1(config-router)#version 2
    R1(config-router)#no auto-summary
    R1(config-router)#network 10.0.0.0
    R1(config-router)#network 20.0.0.0
 
    实验测试:

    R1#ping 192.168.1.10
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.1.10, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 64/146/340 ms

    R1#ping 192.168.1.20
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.1.20, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 60/117/232 ms

    R1#ping 192.168.2.10
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.2.10, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 32/117/244 ms
    R1#ping 192.168.2.20
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.2.20, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 48/146/272 ms