macOS Server uses the adaptive firewall to protect against unauthorized users. If a user or IP address tries to access your network 10 times, the adaptive firewall creates a firewall rule.
If you have macOS Server installed, you can turn on the adaptive firewall. Log in as an admin, then use these terminal commands.
sudo /Applications/Server.app/Contents/ServerRoot/usr/libexec/afctl -c
sudo /Applications/Server.app/Contents/ServerRoot/usr/libexec/afctl -f