UFW, or uncomplicated firewall, is a frontend for managing firewall rules in Arch Linux, Debian, or Ubuntu. UFW is used through the command line (although it has GUIs available), and aims to make firewall configuration easy (or, uncomplicated).
Show help:
ufw help
Show status:
ufw status
Enable it:
ufw enable
Show a list of applications:
ufw app list
Allow/deny rules:
ufw allow OpenSSH
ufw allow ssh
ufw allow 22
ufw allow Apache
ufw allow "Nginx HTTPS"
ufw allow 80/tcp
ufw allow proto tcp from any to any port 80,443
ufw allow http/tcp
ufw allow 1725/udp
ufw delete allow "Nginx Full"
ufw deny 111
ufw deny out 25
To allow/deny connections from an IP address/subnet:
ufw allow from 198.51.100.0
ufw allow from 198.51.100.0/24
ufw allow from 198.51.100.0 to any port 22 proto tcp
ufw allow from 203.0.113.0/24 to any port 873
ufw allow in on eth0 from 203.0.113.102
ufw allow from 203.0.113.103 to any port 3306
ufw deny from 203.0.113.100
ufw deny from 203.0.113.0/24
ufw deny in on eth0 from 203.0.113.100
Delete rules:
ufw delete allow 80
ufw delete allow from 203.0.113.101
Delete numbered rules:
ufw status numbered
ufw delete 1
Enable logging:
ufw logging on
ufw logging {{ low | medium | high }}