網絡實驗 05-快速生成樹配置


快速生成樹配置

一、實驗目標

  1. 理解生成樹協議工作原理
  2. 掌握快速生成樹協議RSTP基本配置方法

二、實驗背景

學校為了開展計算機教學和網絡辦公,建立了一個計算機教室和一個校辦公區,這兩處的計算機網絡通過兩台交換機互相連接組成內部校園網,為了提高網絡的可靠性,作為網絡管理員,你要用2條鏈路將交換機互連,現要求在交換機上做適當的配置,使網絡避免環路

三、技術原理

生成樹協議(spanning-tree),作用是在交換網絡中提供冗余備份鏈路,並且解決交換網絡中的環路問題

生成樹協議是利用SPA算法,在存在交換環路的網絡中生成一個沒有環路的樹形網絡。運用該算法將交換網絡的冗余備份鏈路從邏輯上斷開,當主鏈路出現故障時,能夠自動的切換到備份鏈路,保證數據的正常轉發

生成樹協議版本:STP、RSTP(快速生成樹)、MSTP(多生成樹協議)

生成樹協議的特點是收斂時間長,從主要鏈路出現故障到切換至備份鏈路需要50秒的時間

快速生成樹協議在生成樹協議的基礎上增加了兩種端口角色:替換端口和備份端口,分別做為根端口和指定端口的冗余端口。當根端口或指定端口出現故障時,冗余端口不需要經過50秒的收斂時間,可以直接切換到替換端口或備份端口,從而實現RSTP協議小於1秒的快速收斂

四、實驗步驟

實驗拓撲

默認情況下STP協議啟用的,通過兩台交換機之間傳送BPDU協議數據單元,選出根交換機、根端口等,以便確定端口的轉發狀態。上圖中標記為橙色的端口處於block堵塞狀態

實驗步驟

設置RSTP
查看交換機 show spanning-tree 狀態,了解根交換機和根端口情況;
通過更改交換機生成樹的優先級spanning-tree vlan * priority 4096 可以變化根交換機的角色;

    S1:
    Switch>en
    Switch#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Switch(config)#hostname S1
    S1(config)#end
    S1#
    %SYS-5-CONFIG_I: Configured from console by console

    S1#show spanning-tree                                    //查看交換機spanning-tree 狀態
    VLAN0001
    Spanning tree enabled protocol ieee
    Root ID    Priority    32769
            Address     0060.5C36.5620
            Cost        19
            Port        1(FastEthernet0/1)
            Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

    Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
            Address     0060.7078.8BDE
            Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
            Aging Time  20

    Interface        Role Sts Cost      Prio.Nbr Type
    ---------------- ---- --- --------- -------- --------------------------------
    Fa0/10           Desg FWD 19        128.10   P2p
    Fa0/1            Root FWD 19        128.1    P2p
    Fa0/2            Altn BLK 19        128.2    P2p

    S1#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    S1(config)#interface fa0/10
    S1(config-if)#switchport access vlan 10                            //將fa0/10划分到vlan 10
    % Access VLAN does not exist. Creating vlan 10
    S1(config-if)#exit
    S1(config)#interface range fa0/1 - 2                               //設置fa0/1,fa0/2端口狀態為trunk模式
    S1(config-if-range)#switchport mode trunk 

    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down

    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up


    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down

    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up

    S1(config-if-range)#exit
    S1(config)#spanning-tree mode ?                                    //設置spanning-tree 為RSTP模式
    pvst        Per-Vlan spanning tree mode
    rapid-pvst  Per-Vlan rapid spanning tree mode
    S1(config)#spanning-tree mode rapid-pvst 
    S1(config)#


    S2:
    Switch>en
    Switch#show spanning-tree 
    VLAN0001
    Spanning tree enabled protocol ieee
    Root ID    Priority    32769
            Address     0060.5C36.5620
            This bridge is the root                                //根交換機
            Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

    Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
            Address     0060.5C36.5620
            Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
            Aging Time  20

    Interface        Role Sts Cost      Prio.Nbr Type
    ---------------- ---- --- --------- -------- --------------------------------
    Fa0/1            Desg FWD 19        128.1    P2p
    Fa0/2            Desg FWD 19        128.2    P2p
    Fa0/10           Desg FWD 19        128.10   P2p

    Switch#
    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down

    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down

    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up

    Switch#
    Switch#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Switch(config)#hostname S2
    S2(config)#interface fa0/10
    S2(config-if)#switchport access vlan 10
    % Access VLAN does not exist. Creating vlan 10
    S2(config-if)#exit
    S2(config)#interface range fa0/1 - 2
    S2(config-if-range)#switchport mode trunk 
    S2(config-if-range)#exit
    S2(config)#spanning-tree mode rapid-pvst 
    S2(config)#

五、測試

當主鏈路處於down狀態時,能夠自動的切換到備份鏈路,保證數據的正常轉發。

在S2上shutdown 掉 fa0/1

    Switch#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Switch(config)#int
    Switch(config)#interface fa0/1
    Switch(config-if)#shu
    Switch(config-if)#shutdown                                         //shutdown fa0/1端口

    Switch(config-if)#
    %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to administratively down

    %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
    Switch#show spanning-tree
    VLAN0001
    Spanning tree enabled protocol rstp
    Root ID    Priority    32769
            Address     0001.63E2.4A7A
            This bridge is the root
            Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

    Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
            Address     0001.63E2.4A7A
            Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
            Aging Time  20

    Interface        Role Sts Cost      Prio.Nbr Type
    ---------------- ---- --- --------- -------- --------------------------------
    Fa0/1            Desg FWD 19        128.1    P2p
    Fa0/2            Desg FWD 19        128.2    P2p

    VLAN0010

    Spanning tree enabled protocol rstp
    Root ID    Priority    32778
            Address     0001.63E2.4A7A
            This bridge is the root
            Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

    Bridge ID  Priority    32778  (priority 32768 sys-id-ext 10)
            Address     0001.63E2.4A7A
            Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
            Aging Time  20

    Interface        Role Sts Cost      Prio.Nbr Type
    ---------------- ---- --- --------- -------- --------------------------------
    Fa0/1            Desg FWD 19        128.1    P2p
    Fa0/2            Desg FWD 19        128.2    P2p
    Fa0/10           Desg FWD 19        128.10   P2p

    Switch#

    PC1:
    PC>ipconfig
    IP Address......................: 192.168.1.2
    Subnet Mask.....................: 255.255.255.0
    Default Gateway.................: 192.168.1.1

    PC>ping -t 192.168.1.3

    Pinging 192.168.1.3 with 32 bytes of data:

    Reply from 192.168.1.3: bytes=32 time=78ms TTL=128
    Reply from 192.168.1.3: bytes=32 time=94ms TTL=128
    Reply from 192.168.1.3: bytes=32 time=78ms TTL=128
    Reply from 192.168.1.3: bytes=32 time=78ms TTL=128
    Reply from 192.168.1.3: bytes=32 time=78ms TTL=128
    Reply from 192.168.1.3: bytes=32 time=94ms TTL=128
    Reply from 192.168.1.3: bytes=32 time=93ms TTL=128
    Reply from 192.168.1.3: bytes=32 time=93ms TTL=128
    Reply from 192.168.1.3: bytes=32 time=62ms TTL=128
    Reply from 192.168.1.3: bytes=32 time=94ms TTL=128
    Reply from 192.168.1.3: bytes=32 time=79ms TTL=128
    Reply from 192.168.1.3: bytes=32 time=94ms TTL=128
    ......


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM