A firewall is a security system that monitors and controls incoming and outgoing network traffic based on predetermined rules.
It acts as a barrier between a trusted internal network and untrusted external networks (like the internet).
UFW is a user-friendly front-end for managing firewall rules (based on iptables).
Command | Description |
---|---|
sudo ufw status |
Check the firewall status |
sudo ufw enable |
Enable UFW |
sudo ufw disable |
Disable UFW |
sudo ufw allow 22 |
Allow SSH port 22 |
sudo ufw deny 80 |
Deny HTTP port 80 |
sudo ufw delete allow 22 |
Remove a rule |
sudo ufw reload |
Reload the firewall rules |
π Example:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
iptables
is a powerful command-line firewall utility that uses tables of rules to control network traffic.
Table | Purpose |
---|---|
filter | Default table β used for packet filtering |
nat | Used for network address translation (e.g., port forwarding) |
mangle | Used for packet modification |
raw | Used for packets before connection tracking |