Install
apt install ufw
Config
Doc: https://help.ubuntu.com/community/UFW
The best things to do is disable all the port and enable only what you need.sudo ufw default deny
Be carefull, if you are connected via ssh you should enable the port first.sudo ufw allow 22
It’s 22 for the exemple, but you have to change the port to avoid attacks from Chinese bots.
To see your open port you can use netstat.sudo netstat -tulpn
And then allow what you need.
If the config is done you can enable the service.sudo ufw enable