That's a good way to deal with spam and smaller DoS attacks, although for security you should consider a manual configuration of your firewall (iptables or ufw usually). A good approach to start with would be to drop all incoming and outgoing traffic by default and then setup allow rules based on your needs. Don't forget the two ports 22 and 4200 used by SSH and web SSH, if you block them you can't access your server.