to limit the number of mac address that can connect to L2 port use the following command
switchport mode access
switchport port-security maximum 2
switchport port-security mac-address sticky
this config will allow only two mac connect to the port if more it will do what action u put in the vaulation action
sticky mean the port will take the mac address from the connected device dirctly to put it in the table
first two will be rigistered u dont need to put it manuly
u can also use dot1x for L2 authentication with username and pass
aslo if u wanna make dhcp security u can use DHCP snooping
also Secure the Layer 2 spanning tree topology with BPDU guard
good luck
if helpful Rate