# [Enterprise Switch] How to config port security This topic can help you set up port security. The switch will shut down the port. If a source MAC address is unknown or has been previously learned from another port. Support models ECS4620 series, ECS4510 series, ECS4120 series, ECS5520 series, ECS4530 series, series, ECS3510 series. ### Example 1 port security max-mac-count Topology ![](https://paper-attachments.dropbox.com/s_CD721CD679000671F03FCEACC4A6589236561AFABE32C047BD5D2F7EA7439948_1631088225270_image.png) #### Configuration ``` Console#configure Console(config)#interface ethernet 1/21 Console(config-if)#port security Console(config-if)#port security max-mac-count 1 Console(config-if)#port security action shutdown ``` Use the instruction "show port security" to check port status. ![](https://paper-attachments.dropbox.com/s_CD721CD679000671F03FCEACC4A6589236561AFABE32C047BD5D2F7EA7439948_1631088275550_image.png) #### Result: Enable port security and port security max-mac-count, If port 1 receives more than the max-mac-count. Port 1 will implement the action "shutdown". If want to no shutdown the port. It needs to use CLI to release port status. ### Example 2 network-access aging and port security mac-address sticky Topology ![](https://paper-attachments.dropbox.com/s_CD721CD679000671F03FCEACC4A6589236561AFABE32C047BD5D2F7EA7439948_1631088293476_image.png) #### Configuration ``` Console#configure Console(config)#network-access aging Console(config)#interface ethernet 1/1 Console(config-if)#port security Console(config-if)#port security max-mac-count 5 Console(config-if)#port security mac-address sticky Console(config-if)#exit Console(config)#interface ethernet 1/3 Console(config-if)#port security Console(config-if)#port security max-mac-count 5 Console(config-if)#port security action shutdown Console(config-if)# ``` Show mac table to check the mac learn statues. Port 1 will sticky PC's mac. Even if input the same mac (Fake mac) on port 3, the PC's mac will not be learned on port 3. The type on port 1 will be security. ![](https://paper-attachments.dropbox.com/s_CD721CD679000671F03FCEACC4A6589236561AFABE32C047BD5D2F7EA7439948_1631088318493_image.png) Show port security interface Port security, sticky mode, and secure MAC aging mode enable on port 1. ![](https://paper-attachments.dropbox.com/s_CD721CD679000671F03FCEACC4A6589236561AFABE32C047BD5D2F7EA7439948_1631088355351_image.png) Port 3 instruction action is shutdown, and the last instruction MAC/time will record. ![](https://paper-attachments.dropbox.com/s_CD721CD679000671F03FCEACC4A6589236561AFABE32C047BD5D2F7EA7439948_1631088383614_image.png) show interfaces brief ![](https://paper-attachments.dropbox.com/s_CD721CD679000671F03FCEACC4A6589236561AFABE32C047BD5D2F7EA7439948_1631088402362_image.png) show port security ![](https://paper-attachments.dropbox.com/s_CD721CD679000671F03FCEACC4A6589236561AFABE32C047BD5D2F7EA7439948_1631088420381_image.png) #### Result: In this example port 1 will sticky PC's mac until mac-table aging out. If input the same mac (Fake mac) on port 3, the PC's mac will not be learned on port 3. Port 3 will trig the port security action "shutdown". If port shutdown by PortSec. It needs to use the command "no shutdown" to release port status. Supplemental instruction <font color="#f00">network-access aging:</font> The security aging mode will follow the release time of the mac-table. If the switch doesn't enable the feature the mac will learn on port forever. <font color="#f00">port security max-mac-count:</font> If enable port security, and doesn't config max-mac-count. Port will not learn any mac. And if the mac quantity is more than the max-mac-count. The port will not record the mac over the max-count. If config the port security action. It will be trigged. <font color="#f00">port security mac-address sticky:</font> If enable sticky on a port that mac addresses cannot be moved to another port. If sticky MAC addresses are received on another secure port, then the port will trig action. <font color="#f00">port security action:</font> <font color="334DFF">shutdown:</font> Disables port only <font color="334DFF">trap:</font> Issues SNMP trap message only <font color="334DFF">trap-and-shutdown:</font> Issues SNMP trap message and disable port ![](https://i.imgur.com/28TCOrU.png) ###### tags:`switch function`