← Help center · VPS and servers
How to set up a firewall on Ubuntu with UFW
UFW (Uncomplicated Firewall) is an easy way to block unwanted traffic.
Steps
Allow SSH first, or you will lock yourself out:
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
Check it:
ufw status verbose
Good to know
- Only open ports for services you really run.
- If you changed the SSH port, allow that port instead of 22.
- To remove a rule:
ufw delete allow 80/tcp.
Part of the new server checklist.
More in VPS and servers
- How to connect to your Linux VPS with PuTTY (Windows)
- How to connect to a Linux VPS from Mac or Linux with SSH
- Where to find your server IP address and password
- How to change your root password on Linux
- First steps on a new Linux VPS: a security checklist
Still stuck? Open a support ticket.