Securing your dedicated server with a firewall is essential. UFW (Uncomplicated Firewall) provides an easy interface for managing iptables rules on Ubuntu/Debian.
Installation
apt update && apt install ufw -y
Basic Configuration
# Set default policies
ufw default deny incoming
ufw default allow outgoing
# Allow SSH (IMPORTANT: do this before enabling!)
ufw allow 22/tcp
# Allow common services
ufw allow 80/tcp # HTTP
ufw allow 443/tcp # HTTPS
# Enable the firewall
ufw enable
# Check status
ufw status verbose
Advanced Rules
# Allow specific IP
ufw allow from 203.0.113.50
# Allow port range
ufw allow 8000:8100/tcp
# Delete a rule
ufw delete allow 80/tcp
Important Warning
Always ensure SSH access (port 22) is allowed before enabling UFW. If you lock yourself out, contact Premium IT support and we can access the server via IPMI/KVM to restore access.