Switch(config-if)#switchport mode access //将接口设置为access模式,在packet tracer中好像是必须的,虽然交换机的默认模式是access,但是还是必须要键入这个命令
Switch(config-if)#switchport port-security //启动端口安全功能
Switch(config-if)#switchport port-security maximum 1 //设置端口的最大MAC数量
Switch(config-if)#switchport port-security mac-address 00D0.97DC.31A7//写入MAC
Switch(config-if)#do show port-security address//验证配置,我现在配置的是fa0/2
Secure Mac Address Table
-------------------------------------------------------------------------------
Vlan Mac Address Type Ports Remaining Age
(mins)
---- ----------- ---- ----- -------------
1 0030.A36E.C1CC SecureConfigured FastEthernet0/1 -
1 00D0.97DC.31A7 SecureConfigured FastEthernet0/2 -
------------------------------------------------------------------------------
Total Addresses in System (excluding one mac per port) : 0
Max Addresses limit in System (excluding one mac per port) : 1024
%LINK-5-CHANGED: Interface FastEthernet0/2, changed state to administratively down
%LINK-5-CHANGED: Interface FastEthernet0/2, changed state to administratively down
Switch(config-if)#shutdown //必须先用shutdown关闭端口,这也是论坛里的一个兄弟提醒我的,先谢谢这位兄弟了
Switch(config-if)#no shutdown //再次执行no shutdown好的现在端口可以使用了