Linux生成系统树,快速生成树配置

导读

学校为了开展计算机教学和网络办公,建立的一个计算机教室和一个校办公区,这两处的计算机网络通过两台交换机互联组成内部校园网,为了提高网络的可靠性,作为网络管理员,你要用 2 条链路将交换机互连,现要求在交换机上做适当配置,是网络避免环路。

技术原理

生成树协议(spanning-tree),作用是在交换网络中提供冗余备份链路,并且解决交换网络中的环路问题;生成树协议是利用 SPA 算法,在存在交换机环路的网络中生成一个没有环路的属性网络,运用该算法将交换网络的冗余备份链路从逻辑上断开,当主链路出现故障时,能够自动的切换到备份链路,保证数据的正常转发。生成树协议版本:STP、RSTP(快速生成树协议)、MSTP(多生成树协议)。生成树协议的特点收敛时间长。从主要链路出现故障到切换至备份链路需要 50 秒时间。快速生成树在生成树协议的基础上增加了两种端口角色,替换端口或备份端口,分别作为根端口和指定端口。当根端口或指定端口出现故障时,冗余端口不需要经过50 秒的收敛时间,可以直接切换到替换端口或备份端口,从而实现 RSTP 协议小于 1 秒的快速收敛。

实验步骤

新建 packet tracer 拓扑图

32e9a08eb1d6f0989c92c6bca4f886fb.png

默认情况下 STP 协议是启用的。通过两台交换机之间传送 BPDU 协议数据单元。

选出跟交换机、根端口等,以便确定端口的转发状态。图中标记为黄色的端口处于block 堵塞状态。

设置 RSTP。

查看交换机 show spanning-tree 状态,了解跟交换机和根端口情况。

通过更改交换机生成树的优先级spanning-tree vlan 10 priority 4096 可以变化跟交换机的角色。

测试。当主链路处于 down 状态时候,能够自动的切换到备份链路,保证数据的正常转发。

实验设备

Switch_2960 2 台;PC 2 台;直连线(各设备互联)

PC1

IP: 192.168.1.2

Submask: 255.255.255.0

Gateway: 192.168.1.1

PC2

IP: 192.168.1.3

Submask: 255.255.255.0

Gateway: 192.168.1.1

S1

en

show spanning-tree

conf t

hostname S1

vlan 10

exit

int fa 0/10

switchport access vlan 10

exit

int range fa 0/1 - 2 #同时打开1号和2号端口,记得加range参数

switchport mode trunk #变成trunk模式,让多个vlan可以通讯

exit

spanning-tree mode rapid-pvst #定义为生成树协议

end

S2

en

conf t

hostname S2

vlan 10

exit

int fa 0/10

switchport access vlan 10

exit

int range fa 0/1 - 2 #同时打开1号和2号端口,记得加range参数

switchport mode trunk #变成trunk模式,让多个vlan可以通讯

exit

spanning-tree mode rapid-pvst #定义为生成树协议

end

show spanning-tree

PC1

ipconfig

ping -t 192.168.1.3

S2

en

conf t

int fa 0/1

shut

(查看 PC1 的 ping 情况是否正常)

实战演练

S1

Switch>en

Switch#show spanning-tree

VLAN0001

Spanning tree enabled protocol ieee

Root ID Priority 32769

Address 0006.2A89.4544

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.BCCB.3D34

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/10 Desg FWD 19 128.10 P2p

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#hostname S1

S1(config)#vlan 10

S1(config-vlan)#exit

S1(config)#int fa 0/10

S1(config-if)#switchport access vlan 10

S1(config-if)#exit

S1(config)#int rang fa 0/1 - 2

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 rapid-pvst

S1(config)#end

S1#

%SYS-5-CONFIG_I: Configured from console by console

S1#

S1#show spanning-tree

VLAN0001

Spanning tree enabled protocol rstp

Root ID Priority 32769

Address 0006.2A89.4544

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.BCCB.3D34

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

VLAN0010

Spanning tree enabled protocol rstp

Root ID Priority 32778

Address 0006.2A89.4544

Cost 19

Port 1(FastEthernet0/1)

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32778 (priority 32768 sys-id-ext 10)

--More--

S2

Switch>en

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#hostname S2

S2(config)#vlan 10

S2(config-vlan)#exit

S2(config)#int fa 0/10

S2(config-if)#switchport access vlan 10

S2(config-if)#exit

S2(config)#int range fa 0/1-2

S2(config-if-range)#switchport mode trunk

S2(config-if-range)#exit

S2(config)#spanning-tree mode rapid-pvst

S2(config)#end

S2#

%SYS-5-CONFIG_I: Configured from console by console

S2#show spanning-tree

VLAN0001

Spanning tree enabled protocol rstp

Root ID Priority 32769

Address 0006.2A89.4544

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 0006.2A89.4544

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Aging Time 20

Interface Role Sts Cost Prio.Nbr Type

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

Fa0/2 Desg FWD 19 128.2 P2p

Fa0/1 Desg FWD 19 128.1 P2p

VLAN0010

Spanning tree enabled protocol rstp

Root ID Priority 32778

Address 0006.2A89.4544

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 0006.2A89.4544

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

--More--

测试

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=65ms TTL=128

Reply from 192.168.1.3: bytes=32 time=16ms TTL=128

Reply from 192.168.1.3: bytes=32 time=19ms TTL=128

Reply from 192.168.1.3: bytes=32 time=13ms TTL=128

Reply from 192.168.1.3: bytes=32 time=17ms TTL=128

Reply from 192.168.1.3: bytes=32 time=16ms TTL=128

Reply from 192.168.1.3: bytes=32 time=17ms TTL=128

Reply from 192.168.1.3: bytes=32 time=18ms TTL=128

Reply from 192.168.1.3: bytes=32 time=19ms TTL=128

Reply from 192.168.1.3: bytes=32 time=18ms TTL=128

Reply from 192.168.1.3: bytes=32 time=16ms TTL=128

Reply from 192.168.1.3: bytes=32 time=16ms TTL=128

Reply from 192.168.1.3: bytes=32 time=18ms TTL=128

S2

S2#en

S2#conf t

Enter configuration commands, one per line. End with CNTL/Z.

S2(config)#int fa 0/1

S2(config-if)#shutdown

%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to administratively down

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

S2(config-if)#

S2(config-if)#no shutdown

%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up

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

S2(config-if)#

837d65254f1835f91469211e73502b82.png

1fea4e684b095ecab8bd7621fdc507d3.png

44d425545bf333aebe4ccdcda0fe1749.png

d41bbb1c2125af26ca5ff03c923f2d03.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值