Port security refers to locking down the interfaces on switches and routers to prevent unauthorized users and devices from plugging in. Switches can be capable of sending an alert or disabling a port if unauthorized access is detected.
Port security looks at the source MAC address that’s sending information to the port. If the switch expects one particular MAC address and gets a different MAC address, then it will send an alert or disable the interface.
Each port can have its own configuration. For example, one port can be allowed to be open to multiple MAC addresses, while another interface is locked down to just allow one MAC address.
An administrator can configure port security by specifying a max number of source MAC addresses than an interface can have. For example, lets say an admin set a max number of 5 MAC address on port 1. The switch will listen to each source MAC address on port 1 and keep a list of unique MAC addresses. Once the list of addresses reaches 6, port security will activate and send an alert or disable the interface.