Showing the current configuration before starting:

do show vlan brief
do show mac address-table
do show mac address-table int g0/1
do show port-security int g0/1

Setting up Port-Security on interface G0/1:

int g0/1
switchport host
switchport port-security max 1
switchport port-security violation protect

OR

switchport port-security violation restrict

OR

switchport port-security violation shutdown
  • Protect
    • Drops all packets from unauthorized sources without notifying or alerting network administrators.
  • Restrict
    • Drops all packets from sources that exceed the maximum allowed and increments the SecurityViolation counter.
  • Shutdown
    • Shuts down the port and sends an SNMP notification. The port must be brought up manually or configured with auto-recovery.

Then, enable Port-Security.

switchport port-security

Setting up auto-recovery for violated ports:

errdisable recovery cause psecure-violation
errdisable recovery interval 600
do show errdisable recovery

Manually setting the allowed MAC address for a port:

switchport port-security mac-address FF:FF:FF:FF:FF:FF