Ufw is for managing a Linux firewall and aims to provide an easy interface to iptables for the user. Install and configure ufw do this as root user or use sudo:

apt install ufw

Set default rules

ufw default deny incoming
ufw default allow outgoing

Allow connections

These commands both allow a connection on port 22 using the TCP protocol. Use one they end up in the same IPtables:

ufw allow ssh
ufw allow 22/tcp

Continue reading