Uncomplicated Firewall (UFW) is a frontend for managing firewall rules in Linux. It is designed to be easy to use and provides a simpler alternative to the more complex iptables.
To install UFW on a Debian-based system, use the following command:
sudo apt-get install ufw
For Red Hat-based systems, use:
sudo yum install ufw
To enable UFW, use:
sudo ufw enable
To disable UFW, use:
sudo ufw disable
To check the status of UFW, use:
sudo ufw status
To allow a specific port, use:
sudo ufw allow 22
To deny a specific port, use:
sudo ufw deny 22
To allow a range of ports, use:
sudo ufw allow 1000:2000/tcp
To delete a rule, use:
sudo ufw delete allow 22
To allow connections from a specific IP address, use:
sudo ufw allow from 192.168.1.100
To allow a subnet, use:
sudo ufw allow from 192.168.1.0/24
To enable logging, use:
sudo ufw logging on
To disable logging, use:
sudo ufw logging off