Skip to content

Knowledge base

Search every guide

A simple firewall with UFW

Allow SSH and web traffic and block the rest on Ubuntu.

UFW is Ubuntu's easy firewall. Allow SSH before enabling it, or you'll lock yourself out.

ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
ufw status verbose

To allow a port only from your own IP address:

ufw allow from 198.51.100.7 to any port 22 proto tcp

IDX Panel also has a firewall that filters traffic before it reaches the server. You can use either or both.

Locked out? Open the console in IDX Panel and run ufw disable.