Explore the options for setting port security on interface Fast Ethernet 0/1:
S1#configure terminal
S1(config)#interface fastethernet 0/1
S1(config-if)#switchport port-security ?
aging Port-security aging commands
mac-address Secure mac address
maximum Max secure addresses
violation Security violation mode
<cr>
Notice the last option is a carriage return, <cr>, which means the command switchport
port-security can be entered without specifying any additional options. In fact, you must
enter the switchport port-security command before port security is active and any
remaining port security commands are evaluated by the IOS.
In addition, a port must be in access mode before you can enable port security. Otherwise,
you will get the following error message:
S1(config)#interface fastethernet 0/1
S1(config-if)#switchport port-security
Command rejected: FastEthernet0/1 is a dynamic port.
S1(config-if)#switchport mode access
S1(config-if)#switchport port-security
S1(config-if)#switchport port-security maximum 2
S1(config-if)#switchport port-security mac-address sticky
S1(config-if)#switchport port-security violation protect
S1(config-if)#exit