The uncomplicated firewall (UFW) is easy to to manager a firewall on your Debian or Ubuntu based server.
Step 1: Update your system.
$ sudo apt-get update
$ sudo apt-get upgrade
Step 2: Installing UFW
$ sudo apt-get install ufw
Sample outputs:
Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: ufw 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 138 kB of archives. After this operation, 733 kB of additional disk space will be used. Get:1 http://ftp.us.debian.org/debian/ stable/main ufw all 0.33-2 [138 kB] Fetched 138 kB in 2s (66.5 kB/s) Preconfiguring packages ... Selecting previously unselected package ufw. (Reading database ... 85541 files and directories currently installed.) Preparing to unpack .../archives/ufw_0.33-2_all.deb ... Unpacking ufw (0.33-2) ... Processing triggers for systemd (215-17+deb8u4) ... Processing triggers for man-db (2.7.0.2-5) ... Setting up ufw (0.33-2) ... Creating config file /etc/ufw/before.rules with new version Creating config file /etc/ufw/before6.rules with new version Creating config file /etc/ufw/after.rules with new version Creating config file /etc/ufw/after6.rules with new version update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults Processing triggers for systemd (215-17+deb8u4) ...
Examples and usage: How to setup a UFW firewall on Ubuntu 16.04 LTS server