How to use UFW on Linux
UFW (Uncomplicated Firewall) makes firewall management easier on Linux. This guide shows you how to install, activate, and configure core rules.
1. Install UFW
Update the package list:
sudo apt update
Install UFW:
sudo apt install ufw
Check current status:
sudo ufw status
If UFW is disabled, the output will show Status: inactive.
2. Preserve SSH access
Before activating the firewall, allow SSH connections to avoid losing remote access to the VPS:
sudo ufw allow OpenSSH
3. Activate UFW
Run:
sudo ufw enable
Confirm activation by typing y if prompted.
4. View the rules
To list the configured rules in more detail, run:
sudo ufw status verbose
5. Add new rules
Allow a port
To allow port 80:
sudo ufw allow 80
To also define the protocol:
sudo ufw allow 80/tcp
Block a port
To block port 80:
sudo ufw deny 80
Allow an IP address
To release connections from a specific IP address:
sudo ufw allow from 192.168.1.10
If you still need help, open a ticket with our support.