Using UFW to Block Inbound Connections on Ubuntu

UFW, or Uncomplicated Firewall, is an interface to iptables that is geared towards simplifying the process of configuring a firewall.

UFW is installed by default on Ubuntu. If it has been uninstalled for some reason, you can install it with

sudo apt install ufw.

To set the defaults used by UFW, use these commands:

sudo ufw default deny incoming

To configure your server to allow incoming SSH connections, you can use this command:

sudo ufw allow ssh

or

sudo ufw allow 22/tcp

Enabling UFW

To enable UFW, use the command:

sudo ufw enable

Read more about UFW on the Ubuntu http://manpages.ubuntu.com/manpages/bionic/man8/ufw.8.html\man pages