You can configure port security and set the maximum number of secure MAC addresses learned by an interface to improve access security on your network. Port security enables the switch to convert MAC addresses learned by an interface into secure MAC addresses and to stop learning new MAC addresses after the maximum number of learned MAC addresses is reached. After port security is enabled, the switch can only communicate with devices with learned MAC addresses. If an interface receives packets with a nonexistent source MAC address after the number of secure MAC addresses reaches the limit, the switch considers that the packets are sent from an unauthorized user and takes the configured action on the interface. This prevents unauthorized users from accessing these interfaces, improving security of the switch and the network. The following table describes port security actions.
Action |
Description |
---|---|
restrict |
Discards packets with a nonexistent source MAC address and generates a trap. This action is recommended. |
protect |
Discards packets with a nonexistent source MAC address but does not generate a trap. |
shutdown |
Sets the interface state to error-down and generates a trap. By default, an interface in error-down state can only be restored using the restart command in the interface view. To enable an interface in error-down state to automatically go Up after a period of time, run the error-down auto-recovery cause port-security interval interval-value command in the system view. In this command, interval-value specifies the period of time after which an interface can automatically go Up. |
The system view is displayed.
The interface view is displayed.
Port security is enabled.
By default, port security is disabled on an interface.
The maximum number of secure MAC addresses learned by an interface is set.
By default, the maximum number of secure MAC addresses learned by an interface is 1.
A static secure MAC address entry is configured.
A port security action is configured.
By default, the restrict action is used.
The aging time of dynamic secure MAC address entries learned by the interface is set.
Note that a short aging time (for example, 1 minute) will cause MAC address entries to be aged out fast, and therefore result in traffic forwarding failures.
By default, dynamic secure MAC address entries learned by an interface are not aged out.
To view trap information, run the display trapbuffer command or log in to the NMS.