Switchport port-security maximum 2

Meaning of switchport port-security maximum 2 with example lab

Lots of important information is available in the output.

We can see that port security is enabled and that the status of the port is secure and up.

Violation mode is set to shutdown.

The maximum number of Mac addresses allowed is 2.

The security violation count is 0 which means that no violation has happened till now, if a violation happens then we will see the count increase.

Example lab

In the practice lab, we can configure a switch with port security and use the command switchport port-security maximum 2.

Now, we can connect two devices with the same switchport and we should be able to successfully use those devices on the configured switchport however, now we have to disconnect these devices and connect any other device. This time switch should reject the connection.

This lab scenario does not work in the packet tracer, either we have to emulate a switch on GNS3 or use a real Cisco switch to practice this.