Configuring UFW Firewall
Install UFW Firewall
sudo apt install ufw
Allow inbound connections on a specific port and protocol
sudo ufw allow <port>/<protocol>
Example to allow TCP port 80
sudo ufw allow 80/tcp
Allow inbound connections on a specific port for any protocol
sudo ufw allow <port>
Enable UFW Firewall
sudo ufw enable
Check UFW Firewall Status
sudo ufw status
Optionally block pings
sudo nano /etc/ufw/before.rules
Scroll down to ok icmp codes for INPUT
and insert the following line beforeĀ the other lines:
-A ufw-before-input -p icmp --icmp-type echo-request -j DROP