How To Configure UFW Firewall On Ubuntu VPS Server Ispis

  • ubuntu firewall setup, ufw firewall ubuntu vps, secure ubuntu vps, linux server firewall, vps firewall configuration, ufw security guide, linux vps security, ufw tutorial
  • 566

How To Configure UFW Firewall On Ubuntu VPS Server

A firewall is one of the most important security layers for any Linux VPS server.

Without proper firewall protection,
your VPS may be exposed to:

  • unauthorized access
  • brute-force attacks
  • malware activity
  • open port vulnerabilities
  • server exploitation

In this guide,
you will learn how to configure UFW firewall on an Ubuntu VPS server step-by-step.


What Is UFW?

UFW stands for:

Uncomplicated Firewall

It is a user-friendly firewall management tool for Linux systems.

UFW simplifies:

  • firewall rule creation
  • port management
  • access restrictions
  • VPS security management

It is one of the easiest ways to secure Ubuntu VPS hosting environments.


Why Use A Firewall?

A firewall helps:

  • block unauthorized traffic
  • secure open ports
  • prevent attacks
  • restrict server access
  • improve VPS security

Every production VPS server should use a firewall.


Prerequisites

Before starting,
ensure you have:

  • Ubuntu VPS server
  • root or sudo access
  • SSH access enabled

Recommended operating system:

 
Ubuntu 22.04 LTS
 

Step 1 — Connect To Your VPS Server

Connect to your VPS using SSH.

Command:

 
ssh root@your-server-ip
 

Example:

 
ssh root@192.168.1.10
 

Step 2 — Install UFW Firewall

Most Ubuntu servers already include UFW.

If not installed,
install it manually.

Command:

 
apt install ufw -y
 

Step 3 — Check Firewall Status

Check current firewall status.

Command:

 
ufw status
 

If inactive,
you must configure rules before enabling it.


IMPORTANT — Allow SSH Before Enabling Firewall

Never enable firewall before allowing SSH access.

Otherwise:

you may lock yourself out of the server.

Allow SSH port:

 
ufw allow 22/tcp
 

If using custom SSH port,
replace:

 
22
 

with your custom port number.


Step 4 — Allow HTTP & HTTPS Traffic

Allow website traffic.

Allow HTTP:

 
ufw allow 80/tcp
 

Allow HTTPS:

 
ufw allow 443/tcp
 

These ports are required for websites and SSL certificates.


Step 5 — Enable UFW Firewall

Enable firewall protection.

Command:

 
ufw enable
 

Type:

 
y
 

to confirm.


Step 6 — Verify Firewall Status

Check active firewall rules.

Command:

 
ufw status numbered
 

Example output:

 
22/tcp ALLOW Anywhere
80/tcp ALLOW Anywhere
443/tcp ALLOW Anywhere
 

Important UFW Commands

Enable Firewall

 
ufw enable
 

Disable Firewall

 
ufw disable
 

Restart Firewall

 
ufw reload
 

View Firewall Status

 
ufw status verbose
 

Delete Firewall Rule

 
ufw delete allow 80/tcp
 

How To Allow Additional Ports

Example:
allow MySQL port.

Command:

 
ufw allow 3306/tcp
 

Example:
allow CyberPanel dashboard.

Command:

 
ufw allow 8090/tcp
 

How To Block Ports

Example:
deny FTP port.

Command:

 
ufw deny 21/tcp
 

How To Restrict IP Access

Allow SSH only for specific IP:

 
ufw allow from 192.168.1.100 to any port 22
 

This improves VPS security significantly.


How To Reset UFW Firewall

Reset firewall configuration.

Command:

 
ufw reset
 

Warning:
this removes all firewall rules.


Common UFW Ports

Service Port
SSH 22
HTTP 80
HTTPS 443
MySQL 3306
FTP 21
CyberPanel 8090
cPanel 2083

Common Firewall Mistakes

Avoid:

  • enabling firewall before allowing SSH
  • leaving unnecessary ports open
  • exposing database ports publicly
  • disabling firewall protection
  • allowing unrestricted root access

These can create serious security risks.


Why Firewall Protection Matters

Firewalls help businesses:

  • secure infrastructure
  • prevent attacks
  • protect customer data
  • improve server stability
  • reduce attack surfaces

Firewall protection is essential for production VPS environments.


Additional VPS Security Recommendations

For stronger VPS security:

  • use SSH keys
  • disable root login
  • install Fail2Ban
  • enable backups
  • monitor server logs
  • update packages regularly

Security should always be layered.


Why Choose DJ Technologies VPS Hosting

DJ Technologies Linux VPS hosting provides:

  • enterprise virtualization
  • advanced infrastructure security
  • premium low latency network
  • scalable VPS resources
  • NVMe SSD infrastructure
  • DDoS protection
  • optimized cloud environments
  • 24×7 technical support

Our VPS hosting environments are optimized for:

  • secure hosting
  • business applications
  • SaaS infrastructure
  • enterprise workloads

Final Thoughts

UFW is one of the easiest and most effective ways to secure an Ubuntu VPS server.

By properly configuring firewall rules,
you can:

  • secure your VPS
  • reduce vulnerabilities
  • prevent unauthorized access
  • improve server protection

Firewall security is one of the most important steps in Linux VPS hardening.


Je li Vam ovaj odgovor pomogao?

« Nazad

Powered by WHMCompleteSolution