(NW)RSTP(Rapid PVST+)やってみる

投稿者: | 2020年7月26日
皆さんこんにちは。
最近NW周りの勉強をして知ったことをメモしておきます。
仕事でNWの設定をすることはありませんが既存のNW構成の把握などに役立つかなとおもいちょくちょく手を動かしながら勉強してる感じです。

試してみることは3台のSwitchをつかって、

1, VLANごとにプライマリルートブリッジとセカンダリルートブリッジを分けて負荷分散してみる
    – Rapid PVST+だとできるぽいので設定してみる
2, ルートポートをダウンさせて代替ポートに切り替わるのを確認する
    – Rapid PVST+だと通常のSTPと異なり代替ポートがあるので通信断の時間が短く瞬時に切り替わることを確認する
    – Pingをずっと打って途切れないのを確認する

設定する

### 
### SW1
###

### 基本設定
Switch>ena
Switch#conf t
Switch(config)#hostname SW1
SW1(config)#vlan 30,40
SW1(config-vlan)#exit

### STPのモードをrapid-pvstに変更(デフォはPVSTだった)
SW1(config)#spanning-tree mode rapid-pvst 

### trunkの設定
SW1(config)#interface range fastEthernet 0/7 - 8
SW1(config-if-range)#switchport trunk encapsulation dot1q 
SW1(config-if-range)#switchport mode trunk 
SW1(config-if-range)#exit

### portfast / bpduguardの設定
SW1(config)#interface range fastEthernet 0/1 - 2
SW1(config-if-range)#spanning-tree portfast
SW1(config-if-range)#spanning-tree bpduguard enable 
SW1(config-if-range)#exit

### アクセスポートの設定
SW1(config)#interface fastEthernet 0/1
SW1(config-if)#switchport mode access 
SW1(config-if)#switchport access vlan 30
SW1(config-if)#exit

SW1(config)#interface fastEthernet 0/2
SW1(config-if)#switchport mode access 
SW1(config-if)#switchport access vlan 40
SW1(config-if)#end

SW1#write memory 
###
### SW2
###

### 基本設定
Switch>ena
Switch#conf t
Switch(config)#hostname SW2
SW2(config)#vlan 30,40
SW2(config-vlan)#exit

### STPの設定
SW2(config)#spanning-tree mode rapid-pvst 
SW2(config)#spanning-tree vlan 1,30 priority 4096
SW2(config)#spanning-tree vlan 40 priority 8192

### trunkの設定
SW2(config)#interface fastEthernet 0/1
SW2(config-if)#switchport trunk encapsulation dot1q 
SW2(config-if)#switchport mode trunk 

SW2(config)#interface fastEthernet 0/8
SW2(config-if)#switchport trunk encapsulation dot1q 
SW2(config-if)#switchport mode trunk 

### portfast / bpduguardの設定
SW2(config)#interface fastEthernet 0/2
SW2(config-if)#spanning-tree portfast 
SW2(config-if)#spanning-tree bpduguard enable 

### アクセスポートの設定
SW2(config-if)#switchport mode access 
SW2(config-if)#switchport access vlan 30
SW2(config-if)#end

SW2#write memory 
###
### SW3
###

### 基本設定
Switch>ena
Switch#conf t
Switch(config)#hostname SW3
SW3(config)#vlan 30,40
SW3(config-vlan)#exit

### STPの設定
SW3(config)#spanning-tree mode rapid-pvst 
SW3(config)#spanning-tree vlan 1,30 priority 8192
SW3(config)#spanning-tree vlan 40 priority 4096

### trunkの設定
SW3(config)#interface fastEthernet 0/1
SW3(config-if)#switchport trunk encapsulation dot1q 
SW3(config-if)#switchport mode trunk 
SW3(config-if)#exit

SW3(config)#interface fastEthernet 0/8
SW3(config-if)#switchport trunk encapsulation dot1q 
SW3(config-if)#switchport mode trunk 

### portfast / bpduguardの設定
SW3(config)#interface fastEthernet 0/2
SW3(config-if)#spanning-tree portfast 
SW3(config-if)#spanning-tree bpduguard enable 
 
### アクセスポートの設定
SW3(config-if)#switchport mode access 
SW3(config-if)#switchport access vlan 40
SW3(config-if)#end

ルートポートと代替ポートを確認

SW1でVLAN30とVLAN40のルートポートと代替ポートをそれぞれ確認します。
設定どおりにSTPが収束していれば、VLAN30では0/7がルートポート0/8が代替ポート、VLAN40では07が代替ポート0/8がルートポートになってるはずです。(STP収束までの細かい流れは飛ばします。自分も細かくは把握してない。。)
SW1#show spanning-tree vlan 30

VLAN0030
  Spanning tree enabled protocol rstp
  Root ID    Priority    4126
             Address     68bd.abcc.d280
             Cost        19
             Port        8 (FastEthernet0/7)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32798  (priority 32768 sys-id-ext 30)
             Address     6c50.4d98.f300
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Fa0/7               Root FWD 19        128.8    P2p 
Fa0/8               Altn BLK 19        128.9    P2p 
SW1#show spanning-tree vlan 40

VLAN0040
  Spanning tree enabled protocol rstp
  Root ID    Priority    4136
             Address     ece1.a99c.5000
             Cost        19
             Port        9 (FastEthernet0/8)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32808  (priority 32768 sys-id-ext 40)
             Address     6c50.4d98.f300
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Fa0/7               Altn BLK 19        128.8    P2p 
Fa0/8               Root FWD 19        128.9    P2p 
それぞれちゃんとなってますね。これでVLANごとの負荷分散は一応できてそう。
次は、ルートポートを落として代替ポートに切り替わることを確認します。
STPの時は収束までにデフォルトだと50秒近くかかっていて接続断が長くPingの接続断が発生してしまいましたが今回はどうでしょう。
VLAN30のプライマリポートをダウンさせてPing疎通がどうなるかを検証してみます。(SW1:0/7 –> 0/1:SW2のLANケーブルを抜線します)

(VLAN30)
PC1 –> 0/1:SW1:0/7 –> 0/1:SW2:0/2 –>PC2
抜線
*Mar  1 01:27:00.759: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/7, changed state to down
*Mar  1 01:27:01.774: %LINK-3-UPDOWN: Interface FastEthernet0/7, changed state to down
### PC1 --> PC2 へPingを打ち続けましたがパケロスなし
ping 192.168.30.2
PING 192.168.30.2 (192.168.30.2): 56 data bytes
64 bytes from 192.168.30.2: icmp_seq=0 ttl=64 time=0.682 ms
64 bytes from 192.168.30.2: icmp_seq=1 ttl=64 time=0.828 ms
64 bytes from 192.168.30.2: icmp_seq=2 ttl=64 time=0.669 ms
64 bytes from 192.168.30.2: icmp_seq=3 ttl=64 time=0.591 ms
64 bytes from 192.168.30.2: icmp_seq=4 ttl=64 time=0.804 ms
64 bytes from 192.168.30.2: icmp_seq=5 ttl=64 time=0.865 ms
64 bytes from 192.168.30.2: icmp_seq=6 ttl=64 time=0.865 ms
64 bytes from 192.168.30.2: icmp_seq=7 ttl=64 time=0.847 ms
64 bytes from 192.168.30.2: icmp_seq=8 ttl=64 time=0.957 ms
64 bytes from 192.168.30.2: icmp_seq=9 ttl=64 time=0.894 ms
64 bytes from 192.168.30.2: icmp_seq=10 ttl=64 time=0.921 ms
64 bytes from 192.168.30.2: icmp_seq=11 ttl=64 time=0.854 ms
64 bytes from 192.168.30.2: icmp_seq=12 ttl=64 time=0.976 ms
64 bytes from 192.168.30.2: icmp_seq=13 ttl=64 time=0.787 ms
64 bytes from 192.168.30.2: icmp_seq=14 ttl=64 time=0.944 ms
64 bytes from 192.168.30.2: icmp_seq=15 ttl=64 time=0.790 ms
^C
--- 192.168.30.2 ping statistics ---
16 packets transmitted, 16 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.591/0.830/0.976/0.105 ms
### ルートポートが0/8にちゃんと切り替わってる
SW1#show spanning-tree vlan 30

VLAN0030
  Spanning tree enabled protocol rstp
  Root ID    Priority    4126
             Address     68bd.abcc.d280
             Cost        38
             Port        9 (FastEthernet0/8)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32798  (priority 32768 sys-id-ext 30)
             Address     6c50.4d98.f300
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Fa0/1               Desg FWD 19        128.2    P2p Edge 
Fa0/8               Root FWD 19        128.9    P2p 

SW1#
今回はL2の経路冗長のRSTP(Rapid PVST+)を試してみました。
最近?のNWだと「スタック接続 + リンクアグリケーション」が一般的なようですが、そもそもスタック接続できるスイッチ持ってないので試せませんでした。(シュミレータとかで試せるのかな)
なので初心に立ち返ってレガシー?な設定を試してみました。

今回の設定でPingが途切れず経路が切り替わったのには感動しました。普段やることといえば事前に用意されてる床から伸びてるLANケーブルを自分のPCに差すか、無線LANでネットワークに接続するぐらいなのでこの辺の設定はほぼ馴染みのない世界です。もっと俯瞰してNWを理解できるようになりないですね。。

それではまた!!