diff --git "a/21 \346\217\255\351\230\263\344\270\275/20240508 \344\272\244\346\215\242\346\234\272\347\253\257\345\217\243\345\256\211\345\205\250.md" "b/21 \346\217\255\351\230\263\344\270\275/20240508 \344\272\244\346\215\242\346\234\272\347\253\257\345\217\243\345\256\211\345\205\250.md" new file mode 100644 index 0000000000000000000000000000000000000000..c83578bf3de719bf20120181589a1083b9028593 --- /dev/null +++ "b/21 \346\217\255\351\230\263\344\270\275/20240508 \344\272\244\346\215\242\346\234\272\347\253\257\345\217\243\345\256\211\345\205\250.md" @@ -0,0 +1,38 @@ +### 交换机的端口安全配置 + +```js +PC设置 +192.168.1.2 //PC0 +192.168.1.3 //PC1 +192.168.1.4 //PC2 +192.168.1.5 //PC3 +//子网掩码和网关 +255.255.255.0 +192.168.1.1 +``` + +Switch0和Switch1上的配置 + +```js +Switch>en +Switch#conf t +Switch(config)#inter rang f0/1-22 +Switch(config-if-range)#switchport mode access //配置端口为接入类型,否则默认为动态端口,不能启用安全模式,少了这句会报Command rejected: FastEthernet0/1 is a dynamic port. 错误 +Switch(config-if-range)#switchport port-security //开启端口安全功能 +//设置端口最大连接数为1,即启用动态MAC安全地址 +Switch(config-if-range)#switchport port-security maximum 1 +//若发现违规动作,处理方式为关闭端口 +Switch(config-if-range)#switchport port-security violation shutdown +Switch(config-if-range)#end +Switch#show port-security //查看端口安全配置 +Switch#show port-security int f 0/1 //查看f0/1端口的安全配置 +Switch(config-if-range)#switchport port-security mac-address sticky //启用粘性MAC地址,自动绑定接入的MAC地址 +//ping测试,结果链路均通 +//然后互换PC2和PC3在交换机上的端口,ping测试,结果链路均不通 +Switch(config-if-range)#end +Switch#show mac-address-table //查看端口MAC地址绑定配置 +Switch#clear port-security sticky //清除所有已绑定的粘性MAC地址 +``` + + +