A firewall is a network security system that monitors and controls incoming/outgoing traffic based on predefined rules.
Deny All (more secure) ORAllow All (less secure, not recommended)| Rule # | Action | Source IP | Destination IP | Protocol | Port | Purpose |
|---|---|---|---|---|---|---|
| 1 | ALLOW | 192.168.1.10 |
ANY |
TCP | 22 | SSH Access |
| 2 | ALLOW | ANY |
192.168.1.20 |
TCP | 80,443 | Web Server |
| 3 | DENY | ANY |
ANY |
ANY | ANY | Block Unwanted |
# Install UFW
sudo apt install ufw
# Enable UFW
sudo ufw enable
# Allow SSH
sudo ufw allow 22
# Allow HTTP & HTTPS
sudo ufw allow 80
sudo ufw allow 443
# Deny a specific IP
sudo ufw deny from 203.0.113.5
# Check status
sudo ufw status verbose