diff --git "a/23\345\276\220\350\225\276/20240507-RSTP\345\222\214\347\253\257\345\217\243\350\201\232\345\220\210\351\205\215\347\275\256.md" "b/23\345\276\220\350\225\276/20240507-RSTP\345\222\214\347\253\257\345\217\243\350\201\232\345\220\210\351\205\215\347\275\256.md" new file mode 100644 index 0000000000000000000000000000000000000000..15baea17fe39fca1fd3286ab54630bdc8338bbe6 --- /dev/null +++ "b/23\345\276\220\350\225\276/20240507-RSTP\345\222\214\347\253\257\345\217\243\350\201\232\345\220\210\351\205\215\347\275\256.md" @@ -0,0 +1,142 @@ +# 交换机的生成树协议配置 + +### STP + +生成树协议(spanning Tree Protocol)防止网桥网络中的冗余电路形成环路 + +交换机默认有STP协议在工作 + +**STP缺点**:收敛(发现并更正错误)的时间需要大概50s左右,很慢 + +//show spanning-Tree 查看STP + +### RSTP(快速生成树协议) + +比STP快,收敛时间大概在1s + +//spanning-tree mode rapid-prst 在全局模式中将默认的STP修改为RSTP + +//show spanning-tree summary 查看生成树配置信息 + + + +## 实验步骤 + +1. 按照拓扑图搭建网络,并为交换机提供冗余链路 +2. 默认情况下STP是启用的。通过两台交换机之间传送网桥协议数据单元(BPDU)。先出根交换机,根端口等,以便确认端口的转发状态 +3. 配置快速生成树协议(RSTP) +4. 查看交换机生成树协议配置 + 1. Switch#show spanning-tree summary //以汇总形式查看 + 2. Switch#show spanning-tree +5. 进行测试。当主链路处于down状态时,能够自动的切换到备份链路,保证数据的正常转发 + +**注意:只有当两台交换机都配置RSTP后,再将交换机连接起来。如果先连接线再配置会造成广播风暴,影响交换机的正常工作** + +### 相关设置 + +##### pc设置 + +将每个pc都设置IP,子网掩码和网关 + +##### Switch0和Switch1配置 + +Switch>en + +Switch#show spanning-tree //查看交换机生成树运行状态 + +Switch#show spanning-tree summary //查看生成树的配置信息 + +Switch#conf t + +Switch(config)#inter f 0/1 + +Switch(config-if)#switchport access vlan 2 //将该端口划分到VLAN2 + +Switch(config-if)#exit + +Switch(config)#inter f 0/2 + +Switch(config-if)#switchport access vlan 3 //将该端口划分到VLAN3 + +Switch(config-if)#exit + +Switch(config)#inter range f 0/23-24 + +Switch(config-if-range)#switch mode trunk + +Switch(config-if-range)exit + +Switch(config)#spanning-tree mode rapid-pvst //指定生成树协议的类型为RSTP + +Switch(config)#end + +Switch#show spanning-tree //判断根交换机、端口角色、端口状态等 + +### 链路测试 + +##### 在pc0的cmd下 + +ping 192.168.1.2 //链路通 + +Switch0 + +Switch>en + +Switch#conf t + +Switch(config)#inter f 0/23 //关闭主链路上的端口 + +Switch(config-if)#shutdown + + + +ping 192.168.1.2 //链路通 + +//备份链路标记由×变为绿色,表明备份链路已启用 + +# 交换机的端口聚合配置 + +端口/链路聚合,是指把交换机上多个物理端口捆绑合成一个逻辑端口,这样在交换机之间形成一条拥有较大宽带的链路,还可以实现负载均衡,并提供冗余链路 + +**聚合端口聚合的前提是这几个要聚合的端口的编号是连续的** + +### 实验步骤 + +1. 按拓扑图搭建网络,并为交换机提供冗余链路 +2. 选择编号连续的端口进行配置 +3. 将连续的多端口加入链路组并开启 +4. 为聚合链路开启均衡负载功能 + +### 相关设置 + +##### pc设置 + +给各个pc设置IP、子网掩码和网关 + +##### Switch0和Switch1配置 + +Switch>en + +Switch#conf t + +Switch(config)#inter range f 0/23-24 + +Switch(config-if-range)#switch mode trunk //将端口配置为Trunk模式 + +Switch(config-if-range)#channel-group 1 mode on //加入链路组1并开启 + +Switch(config-if-range)#ex + +Switch(config)#port-channel load-balance dst-ip //按目的IP地址来实现负载均衡 + +Switch(config)#ex + +Switch#show etherchannel summary //显示以太通道信息 + +Switch#show interfaces etherchannel //显示聚合端口信息 + +##### pc0(cmd中) + +ping 192.168.1.3 //链路通 + +ping 192.168.1.4 //链路通 \ No newline at end of file diff --git "a/23\345\276\220\350\225\276/20240508-\344\272\244\346\215\242\346\234\272\345\256\211\345\205\250.md" "b/23\345\276\220\350\225\276/20240508-\344\272\244\346\215\242\346\234\272\345\256\211\345\205\250.md" new file mode 100644 index 0000000000000000000000000000000000000000..4047aa715b2f434096f3bafead9f4e1b5c94e06c --- /dev/null +++ "b/23\345\276\220\350\225\276/20240508-\344\272\244\346\215\242\346\234\272\345\256\211\345\205\250.md" @@ -0,0 +1,71 @@ +# 交换机安全 + +1. #### 选择要进行安全设置的端口 + + Switch(config)#int f 0/1 + +2. #### 启用交换机接口的安全设置 + + Switch(config-if)#Switchprot prot-security //直接写会报提示:Command rejected:FastEthernet 0/1 is a dynamic port 因为端口默认是动态的,要改成访问模式access + +3. #### 改成访问模式 + + Switch(config-if)#Switchport mode access + + Switch(config-if)#switchport port-security + + 再次启用交换机接口的接口安全设置 + + + + ##### 启用安全设置后还要做三件事才能生效 + + Switch(config-if)#switchport port-security maximum 1 //maximum Max secure addresses是指最大允许连接的终端数量是1,范围是1-132 + + + + Switch(config-if)#switchport port-security violation shutdown //violation Security violation mode设置超过最大连接数的设备处理方式 + + ​ 处理方式有三种: + + ​ protect Security violation protect mode //保护模式:超过限制客户机的帧将被抛弃 + ​ restrict Security violation restrict mode //限制模式:超过限制就通过SNMP通告管理员 + ​ shutdown Security violation shutdown mode //关闭模式:超过限制就关闭端口 + + + + Switch(config-if)#switchport port-security mac-address sticky //mac-address Secure mac address绑定正确的MAC地址 + + ​ 绑定的方式有两种: + + ​ H.H.H 48 bit mac address //手动输入要绑定的地址 + sticky Configure dynamic secure addresses as sticky //自动粘贴前N台客户机的地址,N是maximum命令设置的最大客户机数量 + + + + ##### 如何测试是否生效,前提是交换机要记录到正确的MAC地址 + + 为了让交换机记录到第一次正确的MAC地址,需要ping一次 + + 要重新启用被安全规则关闭的端口,先手动关闭一次,再手动开启 + + + + Switch#clear port-security sticky //清除交换机已经记录的安全MAC地址,重新开始记录 + +##### Switch#show port-security interface fa0/1 // 查看f0/1端口的安全配置 + +# 作业 + +![alt text](./img/20240508.png) + + + + + + + + + + + diff --git "a/23\345\276\220\350\225\276/img/20240508.png" "b/23\345\276\220\350\225\276/img/20240508.png" new file mode 100644 index 0000000000000000000000000000000000000000..06ec1e919d2fff22fac90913538318fa112046ac Binary files /dev/null and "b/23\345\276\220\350\225\276/img/20240508.png" differ