文章目录

  • 1、对交换机SW-1进行配置,仅允许Host-1通过Ethernet0/0/1接口与Host-3和Host-4通信,Host-2无法与其他主机通信。
  • 2、关闭生成树协议,验证环路造成的影响
  • 3、关闭生成树协议通过链路聚合实现两条链路正常通信并提高链路可靠性。



内容包括生成树协议解决网络环路,mac地址与接口绑定实现设备接入,通过链路聚合提高网络可靠性。

新建相关拓扑

交换机关于环路、接口绑定、链路聚合的相关知识_链路

1、对交换机SW-1进行配置,仅允许Host-1通过Ethernet0/0/1接口与Host-3和Host-4通信,Host-2无法与其他主机通信。

在绑定前先进行测试当前拓扑的连通性

交换机关于环路、接口绑定、链路聚合的相关知识_链路_02


查看交换机的mac表

交换机关于环路、接口绑定、链路聚合的相关知识_Ethernet_03


重启交换机SW-1,消除mac地址表动态项。

关闭交换机SW-1指定接口的mac地址学习功能

<Huawei>sys	
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]undo	
[Huawei]undo info	
[Huawei]undo info-center ena	
[Huawei]undo info-center enable 
Info: Information center is disabled.
[Huawei]sysnam	
[Huawei]sysname SW-1
[SW-1]inte	
[SW-1]interface Eth	
[SW-1]interface Ethernet 0/0/1
[SW-1-Ethernet0/0/1]mac-add	
[SW-1-Ethernet0/0/1]mac-address learn	
[SW-1-Ethernet0/0/1]mac-address learning disab	
[SW-1-Ethernet0/0/1]mac-address learning disable acti	
[SW-1-Ethernet0/0/1]mac-address learning disable action disca	
[SW-1-Ethernet0/0/1]mac-address learning disable action discard 
[SW-1-Ethernet0/0/1]quit
[SW-1]inte	
[SW-1]interface Eth	
[SW-1]interface Ethernet 0/0/2
[SW-1-Ethernet0/0/2]mac-address learning disable action discard
[SW-1-Ethernet0/0/2]quit
[SW-1]interface Ethernet 0/0/3
[SW-1-Ethernet0/0/3]mac-address learning disable action discard
[SW-1-Ethernet0/0/3]quit
[SW-1]interface Ethernet 0/0/4
[SW-1-Ethernet0/0/4]mac-address learning disable action discard
[SW-1-Ethernet0/0/4]quit
[SW-1]interface Ethernet 0/0/5
[SW-1-Ethernet0/0/5]mac-address learning disable action discard
[SW-1-Ethernet0/0/5]quit
[SW-1]interface Ethernet 0/0/6
[SW-1-Ethernet0/0/6]mac-address learning disable action discard
[SW-1-Ethernet0/0/6]quit
[SW-1]interface Ethernet 0/0/7
[SW-1-Ethernet0/0/7]mac-address learning disable action discard
[SW-1-Ethernet0/0/7]quit
[SW-1]interface Ethernet 0/0/8
[SW-1-Ethernet0/0/8]mac-address learning disable action discard
[SW-1-Ethernet0/0/8]quit
[SW-1]interface Ethernet 0/0/9
[SW-1-Ethernet0/0/9]mac-address learning disable action discard
[SW-1-Ethernet0/0/9]quit
[SW-1]interface Ethernet 0/0/10
[SW-1-Ethernet0/0/10]mac-address learning disable action discard
[SW-1-Ethernet0/0/10]quit
[SW-1]interface Ethernet 0/0/11
[SW-1-Ethernet0/0/11]mac-address learning disable action discard
[SW-1-Ethernet0/0/11]quit
[SW-1]interface Ethernet 0/0/12
[SW-1-Ethernet0/0/12]mac-address learning disable action discard
[SW-1-Ethernet0/0/12]quit
[SW-1]interface Ethernet 0/0/13
[SW-1-Ethernet0/0/13]mac-address learning disable action discard
[SW-1-Ethernet0/0/13]quit
[SW-1]interface Ethernet 0/0/14
[SW-1-Ethernet0/0/14]mac-address learning disable action discard
[SW-1-Ethernet0/0/14]quit
[SW-1]interface Ethernet 0/0/15
[SW-1-Ethernet0/0/15]mac-address learning disable action discard
[SW-1-Ethernet0/0/15]quit
[SW-1]interface Ethernet 0/0/16
[SW-1-Ethernet0/0/16]mac-address learning disable action discard
[SW-1-Ethernet0/0/16]quit
[SW-1]interface Ethernet 0/0/17
[SW-1-Ethernet0/0/17]mac-address learning disable action discard
[SW-1-Ethernet0/0/17]quit
[SW-1]interface Ethernet 0/0/18
[SW-1-Ethernet0/0/18]mac-address learning disable action discard
[SW-1-Ethernet0/0/18]quit
[SW-1]interface Ethernet 0/0/19
[SW-1-Ethernet0/0/19]mac-address learning disable action discard
[SW-1-Ethernet0/0/19]quit
[SW-1]interface Ethernet 0/0/20
[SW-1-Ethernet0/0/20]mac-address learning disable action discard
[SW-1-Ethernet0/0/20]quit
[SW-1]interface Ethernet 0/0/21
[SW-1-Ethernet0/0/21]mac-address learning disable action discard
[SW-1-Ethernet0/0/21]quit
[SW-1]interface Ethernet 0/0/22
[SW-1-Ethernet0/0/22]mac-address learning disable action discard
[SW-1-Ethernet0/0/22]quit
[SW-1]

测试当前网络连通性。

Host-1和Host-2都不能和Host-3和Host-4通信。

交换机关于环路、接口绑定、链路聚合的相关知识_链路_04


交换机关于环路、接口绑定、链路聚合的相关知识_Ethernet_05


关闭交换机接口的mac地址自动学习功能后,无法自动学习主机的mac地址,对于不在mac地址表的数据包采取了丢弃的动作。

将Host-1的mac地址与Ethernet 0/0/1接口绑定。

[SW-1]mac-address static 5489-985d-731b Ethernet 0/0/1 vlan 1

交换机关于环路、接口绑定、链路聚合的相关知识_生成树_06


之后就可以和Host-1主机通信了,Host-2没有进行绑定,测试不通。

交换机关于环路、接口绑定、链路聚合的相关知识_网络协议_07


交换机关于环路、接口绑定、链路聚合的相关知识_链路_08


当更改Host-1的接入位置时,可以发现也是测试不通的。

2、关闭生成树协议,验证环路造成的影响

相关拓扑

交换机关于环路、接口绑定、链路聚合的相关知识_网络_09

恢复SW-1初始配置,重启。要检查第一步操作的mac地址是否清除。

<SW-1>res	
<SW-1>reset sav	
<SW-1>reset saved-configuration 
Warning: The action will delete the saved configuration in the device.
The configuration will be erased to reconfigure. Continue? [Y/N]:y
Warning: Now clearing the configuration in the device.
Error: The config file does not exist.
<SW-1>reboot
Info: The system is now comparing the configuration, please wait.
Warning: All the configuration will be saved to the configuration file for the n
ext startup:, Continue?[Y/N]:y
Now saving the current configuration to the slot 0.
Save the configuration successfully.
Info: If want to reboot with saving diagnostic information, input 'N' and then e
xecute 'reboot save diagnostic-information'.
System will reboot! Continue?[Y/N]:y
<SW-1>

分别关闭SW-1和SW-2的生成树协议。

<SW-1>sys	
<SW-1>system-view 
Enter system view, return user view with Ctrl+Z.
[SW-1]st	
[SW-1]stp dis	
[SW-1]stp disable 
Warning: The global STP state will be changed. Continue? [Y/N]y
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW-1]
<Huawei>sys	
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]undo	
[Huawei]undo info	
[Huawei]undo info-center ena	
[Huawei]undo info-center enable 
Info: Information center is disabled.
[Huawei]
[Huawei]sysna	
[Huawei]sysname SW-2
[SW-2]stp disa	
[SW-2]stp disable 
Warning: The global STP state will be changed. Continue? [Y/N]y
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW-2]

测试Host-1不能和2、3、4进行通信

交换机关于环路、接口绑定、链路聚合的相关知识_Ethernet_10


此时接口出现了大量数据流,在SW-1交换机验证过程中会出现卡顿。

交换机关于环路、接口绑定、链路聚合的相关知识_网络协议_11


进行对GE 0/0/1接口抓包,出现大量ARP广播报文。

交换机关于环路、接口绑定、链路聚合的相关知识_网络_12


因此采用双链路通信时,关闭了生成树协议会造成广播包环路,导致网络瘫痪。重新开启生成树协议后等待一段时间,通信恢复正常。

3、关闭生成树协议通过链路聚合实现两条链路正常通信并提高链路可靠性。

[SW-1]interface Eth-Trunk 1
[SW-1-Eth-Trunk1]quit
[SW-1]inter	
[SW-1]interface Giga	
[SW-1]interface GigabitEthernet 0/0/1
[SW-1-GigabitEthernet0/0/1]eth-T	
[SW-1-GigabitEthernet0/0/1]eth-trunk 1
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW-1-GigabitEthernet0/0/1]quit
[SW-1]inter	
[SW-1]interface Giga	
[SW-1]interface GigabitEthernet 0/0/2
[SW-1-GigabitEthernet0/0/2]eth-t	
[SW-1-GigabitEthernet0/0/2]eth-trunk 1
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW-1-GigabitEthernet0/0/2]quit
[SW-1]quit
<SW-1>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:
flash:/vrpcfg.zip exists, overwrite?[Y/N]:y
Now saving the current configuration to the slot 0.
Save the configuration successfully.
<SW-1>
[SW-2]interface Eth-Trunk 1
[SW-2-Eth-Trunk1]quit
[SW-2]inter	
[SW-2]interface Giga	
[SW-2]interface GigabitEthernet 0/0/1
[SW-2-GigabitEthernet0/0/1]eth	
[SW-2-GigabitEthernet0/0/1]eth-trunk 1
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW-2-GigabitEthernet0/0/1]quit
[SW-2]inter	
[SW-2]interface Giga	
[SW-2]interface GigabitEthernet 0/0/2
[SW-2-GigabitEthernet0/0/2]eth-t	
[SW-2-GigabitEthernet0/0/2]eth-trunk 1
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW-2-GigabitEthernet0/0/2]quit
[SW-2]quit
<SW-2>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:
Now saving the current configuration to the slot 0.
Save the configuration successfully.
<SW-2>

分别关闭生成树协议。

<SW-1>sys	
<SW-1>system-view 
Enter system view, return user view with Ctrl+Z.
[SW-1]stp dis	
[SW-1]stp disable 
Warning: The global STP state will be changed. Continue? [Y/N]y
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW-1]

原理是将两个交换机的两台链路捆绑成Eth-Trunk进行通信,如果一条链路断了也可以完成通信。

测试可以通信。

交换机关于环路、接口绑定、链路聚合的相关知识_生成树_13


将其中一条链路删除后测试也可以通信。

交换机关于环路、接口绑定、链路聚合的相关知识_网络协议_14


交换机关于环路、接口绑定、链路聚合的相关知识_Ethernet_15