Automatic static ip after successful dhcp lease

I serve internet access for my clients, they get an IP address through a dhcp server. Now I want that when a user with a device gets an IP address from the dhcp server that he always get the same IP address, based on his MAC address, when he connects on the network, it’s not possible to make them manually static because every day there are new devices. Is there a way to do this automatically?

Thanks

Here is a simple solution.

Save this as a script:

:local date [/system clock get date]
:local time [/system clock get time]
:foreach lease in=[/ip dhcp-server lease find dynamic] do={
	/ip dhcp-server lease make-static $lease
	/ip dhcp-server lease comment comment="$date $time" $lease
	}

Make a scheduler and run it once an hour.

It will then take all active DHCP leases that are not static and set it static with the current date as a comment.