Firewalls & Security

πŸ”Ή What is a Firewall?

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 (Uncomplicated Firewall)

UFW is a user-friendly front-end for managing firewall rules (based on iptables).

🧭 Common UFW Commands:

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

iptables is a powerful command-line firewall utility that uses tables of rules to control network traffic.

🧱 Main Tables:

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

πŸ”Ή Common Chains: