Setting Up a Firewall with UFW

Setting Up a Firewall with UFW

UFW (Uncomplicated Firewall) makes managing firewall rules straightforward, even for beginners.

Install UFW

apt install ufw -y

Set Default Policies

ufw default deny incoming
ufw default allow outgoing

Allow Essential Services

ufw allow ssh          # SSH (port 22)
ufw allow 80           # HTTP
ufw allow 443          # HTTPS

Enable the Firewall

ufw enable

View Current Rules

ufw status verbose

Common Operations

ufw allow 25565               # Allow a specific port
ufw delete allow 80           # Remove a rule
ufw allow from 203.0.113.100  # Allow a specific IP
ufw deny from 198.51.100.0    # Block a specific IP
ufw disable                   # Disable the firewall
ufw reset                     # Reset all rules

Note: Always allow SSH before enabling the firewall to avoid locking yourself out.

  • 0 istifadəçi bunu faydalı hesab edir
Bu cavab sizə kömək etdi?

Uyğun məqalələr

Securing SSH Access

Securing SSH Access SSH is the main entry point to your server. Hardening it is one of the most...

Installing Fail2Ban to Prevent Brute Force Attacks

Installing Fail2Ban Fail2Ban monitors your log files and automatically bans IP addresses that...

Setting Up Let's Encrypt SSL Certificates

Setting Up Let's Encrypt SSL Certificates Let's Encrypt provides free, trusted SSL certificates....

Scanning for Rootkits with rkhunter and chkrootkit

Scanning for Rootkits Rootkits are malware that hide from standard detection tools. Two widely...

Setting Up Two-Factor Authentication for SSH

Setting Up Two-Factor Authentication for SSH Adding 2FA to SSH requires both your SSH...