Post

UFW cheatsheet

It’s so satisfying and much cheaper to host your own websites on a self managed barebones vps. But if you’re going to host your own websites then you will need to have a firewall running to protect your website from hackers.

Luckily UFW, the default firewall on Linux distributions makes the process of enabling a firewall simple.

What is a website firewall?

A website firewall is a security solution designed to monitor, filter, and block malicious traffic to a website. It helps protect against various online threats, such as hacking attempts, DDoS attacks, and other types of cyber threats by analyzing and filtering incoming web traffic.

What is UFW?

Uncomplicated Firewall (UFW) is a user-friendly command-line interface for managing iptables, which is the default firewall management tool in many Linux distributions. UFW is designed to simplify the process of configuring a firewall by providing a straightforward syntax.

Enable Firewall

1
sudo ufw enable

Disable Firewall

1
sudo ufw disable

Status

See what rules are in place

1
sudo ufw status

Get a bit more information

1
sudo ufw status verbose

Allow range of ip’s

1
sudo ufw allow proto tcp from 104.245.210.224/28 to any port 22

Allow range of ip’s with a dry run

1
sudo ufw --dry-run allow proto tcp from 104.245.210.224/28 to any port 22

Reset all UFW rules

Start from the default ufw configuring your rules

1
sudo ufw reset

allow access to special port

1
ufw allow from 1.2.3.4 to any port 7080

To view all blocked threats using Uncomplicated Firewall (ufw), you can check the firewall logs. Use the following command in the terminal:

1
2
sudo ufw status | grep BLOCK

This command filters the status output to show only the blocked entries, providing information about blocked threats or unauthorized access attempts.

This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.