Port security implements dynamic binding. After the maximum number of MAC addresses that can be learned by an interface is set, other non-trusted hosts cannot use the local interface to communicate with the switch, thereby improving the device and network security.
# Configure port security on the gigabitethernet0/0/1.
<HUAWEI> system-view [HUAWEI] interface gigabitethernet 0/0/1 [HUAWEI-GigabitEthernet0/0/1] port-security enable
<HUAWEI> system-view [HUAWEI] interface gigabitethernet 0/0/1 [HUAWEI-GigabitEthernet0/0/1] port-security enable [HUAWEI-GigabitEthernet0/0/1] port-security max-mac-num 5

Before setting the maximum number of MAC addresses that can be learned by an interface, ensure that the interface has been enabled with port security.
More Information: S Series Switches Common Operation Guide