Net Eng

STP(Spaning Tree Protocol) 본문

Network/실습

STP(Spaning Tree Protocol)

欲心 2024. 6. 14. 03:31

■ STP(Spaning Tree Protocol) (IEEE 802.D)

- 가용성을 위해 링크를 이중화 하는 경우 Looping이 발생됨.

이러한 문제를 해결하기 위해 특정 포트를  Blocking Port로 만든 이후 주 경로에 장애 발생시 포트를 Forwarding 상태로 전환하여 장애 내성을 갖도록 하는 기능을 말함.

 

■ 이중화

- 장애내성 : Primary와 Secondary로 나눠서 1개만 동작.

 => STP, Floating route

- 부하분산 : 여러 경로가 동일하게 동작

 => Etherchannel, GLBP

 

STP 토폴로지

 

SW2

Switch>en
Switch#sh mac-
Switch#sh mac-address-table 
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----

   1    00e0.8fba.c901    DYNAMIC     Fa0/1
   1    00e0.8fba.c902    DYNAMIC     Fa0/2

 

SW1

sh int fa0/0
-----------------------------------------------------------
FastEthernet0/1 is up, line protocol is up (connected)
  Hardware is Lance, address is 00e0.8fba.c901 (bia 00e0.8fba.c901)
 BW 100000 Kbit, DLY 1000 usec,
 -----------------------------------------------------------

sh int fa0/2
-----------------------------------------------------------
FastEthernet0/2 is up, line protocol is up (connected)
  Hardware is Lance, address is 00e0.8fba.c902 (bia 00e0.8fba.c902)
 BW 100000 Kbit, DLY 1000 usec,
 -----------------------------------------------------------

 

■ Switching Loop 문제

스위치가 2회선 이상으로 중복 연결되어 있는 경우 스위치 구간에서 Frame이 뺑뺑이 (Looping)을 만들 수 있는데 이 경우는 모든 포트가 활성화 되어 있는 현상이다.

=> Broadcast Storm

 

PC1

C:\>ping 10.0.0.2

Pinging 10.0.0.2 with 32 bytes of data:

Reply from 10.0.0.2: bytes=32 time<1ms TTL=128
Reply from 10.0.0.2: bytes=32 time<1ms TTL=128
Reply from 10.0.0.2: bytes=32 time<1ms TTL=128
Reply from 10.0.0.2: bytes=32 time=1ms TTL=128

Ping statistics for 10.0.0.2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms

 

SW2

Switch#sh mac-address-table 
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----

   1    0030.f2de.b46d    DYNAMIC     Fa0/1
   1    0090.2ba7.b0c5    DYNAMIC     Fa0/3
   1    00e0.8fba.c901    DYNAMIC     Fa0/1
   1    00e0.8fba.c902    DYNAMIC     Fa0/2

 

■ BPDU

- 스위치는 주기적으로 매 2초 마다 BPDU(Bridge Protocol Data Unit)를 주고 받는다. 이를 통해 MAC테이블에 상대방 스위치의 MAC주소가 지속적으로 저장됨.

 

SW2

clear mac-address-table
Switch#sh mac-address-table 
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----

   1    00e0.8fba.c901    DYNAMIC     Fa0/1
   1    00e0.8fba.c902    DYNAMIC     Fa0/2

 

■ STP 기능 해제

conf t
no spanning-tree vlan 1

 

 

■ STP 기능 설정

conf t
spanning-tree vlan 1

 

■ Switchport의 상태 변이

  BPDU 송신 BPDU 수신 MAC 학습 Frame 전달
blocking (20초) O X X X
Listening (15초) O O X X
Learning (15초) O O O X
Forwarding O O O O

 

SW1

Switch(config)#do sh spanning-tree
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0060.3E20.B7AE
             This bridge is the root
             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.3E20.B7AE
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

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

 

 

■ STP에서 BLK포트 선출 순서

 

1. Root Bridge와 non-root bridge 선출

우선값 계산 : 2^16/2 = 32768 => (32768 + Vlan 주소 번호)

 => 관리자가 직접 입력 가능

- 낮은 MAC 주소를 가진 스위치 => Vlan의 MAC주소

 => Vlan별로 다르기 때문에 PVST(Per Vlan STP)로 동작

- Root Bridge의 모든 포트는 DP(Designated Port - 전달상태)로 선출

 

2. Non-Root bridge는 Root bridge로 향하는 경로 가운데 가장 낮은 경로 비용을 갖는 포트를 Root port로 선출 (전달상태)

- 비용 기준

Root Prot : non-root sw에서 root sw로 향하는 가장 좋은 경로 비용을 갖는 포트

 => 10Gbps(2), 1Gbps(4), 100Mbps(19), 10Mbps(100)

 => Root Bridge까지 가는데 사용되는 모든 출력 인터페이스 합산

 

3. 모든 Link에는 1개씩의 DP가 존재

 

4. 비용까지 동일한 겨우 낮은 인터페이스 번호를 갖는 포트를 Root port를 선출

 

5. 역할정의가 되지 않은 포트간 연결 링크의 경우 Non-root bridge간에 다시 한번 우선값, 낮은 MAC주소 비교 후 우선하는 포트를 DP로 선출

 

6. 최종적으로 남는 포트가 Blocking port가 됨.

Switch#sh spanning-tree 
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0001.C7C9.8E2D
             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.C7C9.8E2D
             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/3            Desg FWD 19        128.3    P2p
Fa0/2            Desg FWD 19        128.2    P2p
Switch#sh spanning-tree 
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0001.C7C9.8E2D
             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     00D0.BC3B.EBAB
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

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

 

변경 전

■ Priority 변경

Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#sp vlan 1 priority 1
% Bridge Priority must be in increments of 4096.
% Allowed values are:
  0     4096  8192  12288 16384 20480 24576 28672
  32768 36864 40960 45056 49152 53248 57344 61440
Switch(config)#sp vlan 1 priority 8192

 

Switch(config)#do sh spanning-tree
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    8193
             Address     00E0.B023.A659
             This bridge is the root
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    8193  (priority 8192 sys-id-ext 1)
             Address     00E0.B023.A659
             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
Gi0/1            Desg FWD 4         128.25   P2p

 

▶ 설정을 변경하면 해당 라우터가 Root Bridge가 됨.

변경 후

 

 


 

SW1 ~ SW3

en
conf t
int fa0/1
sw acc vlan 10
int fa0/2
sw acc vlan 20
do sh spanning-tree

 

■ RSTP(Rapid STP)

sp mode rapid-pvst

STP에서 포트 변이에 최대 50초의 시간이 필요한 불편을 없애기 위해 개발된 기능으로 1~3초 이내에 BLK포트를 FWD포트 상태로 변이 시킬 수 있다.

STP에서 가지고 있는 포트 상태 가운데 Blocking과 Listning을 묶어서 Discarding port상태로 보유

 

■ Portfast 선언

sp portfast default

=> 순환 구조가 아닌 종단일때

=> 일반 Access port를 대상으로 하기 때문에 순환 구조를 지닌 스위치에서 사용할 경우 Looping이 발생 가능 

 

spanning-tree vlan X priority XXXX	#우선값 변경
spanning-tree vlan 1 root primary	#root로 선언
spanning-tree mode pvst		#pvst로 선언
spanning-tree mode rapid-pvst	#rstp로 선언
spanning-tree portfast default	#portfast 선언

'Network > 실습' 카테고리의 다른 글

Routing Protocol - RIP  (0) 2024.06.14
Static Routing  (0) 2024.06.14
Inter Vlan - (3)  (0) 2024.06.14
Inter Vlan - (2)  (0) 2024.06.14
Inter Vlan -(1)  (1) 2024.06.14