需求: 1.要求交换机实现mac地址绑定,一个端口对应一个MAC地址,非法pc机连接不上,但是此端口并不断开,只能此MAC——pc机能连上 2.一个端口绑定多MAC地址 需求1

>en
#config terminal
(config)#errdisable recovery cause psecure-violation
(config)#errdisable recovery interval 60
(config)#interface GigabitEthernet0/6
(config-if)#switchport mode access             
(config-if)#switchport port-secruity              
(config-if)#switchport port-secruity maximum 1
(config-if)#switchport port-security mac-address xxxx.xxxx.xxxx
(config-if)#switchport port-security violation shutdown	

cisco交换机默认都是动态安全端口secureDynamic,所以开启粘滞安全端口实现mac绑定,省去了静态端口配置

switchport port-security mac-address sticky

出现违例时间时的惩罚措施 switchport port-security violation 模式 模式分为三种 : protect:仅丢弃非法的数据帧 restrict:丢弃非法的数据帧,同时产生一个syslog消息 shutdown:将端口设置成err-disable,接口不可用,同时产生一个syslog消息

switchport port-security violation shutdown 这种情况下,由于被惩罚进入了err-disable,需要手动开启端口,有两种方法开启: 1.使用全局配置命令:err-disable recovery psecure-violation 2.手工将特定的端口shutdown再noshutdown

需求2

#config terminal
(config)#interface GigabitEthernet0/6
(config-if)#switchport mode access             
(config-if)#switchport port-secruity              
(config-if)#switchport port-secruity maximum 1
(config-if)#switchport port-security mac-address xxxx.xxxx.xxxx
(config-if)#switchport port-security mac-address xxxx.xxxx.xxxx
(config-if)#switchport port-security violation restrict