How to Set Up a Firewall with UFW on ubuntu 14.04

Uncomplicated firewall (UFW) provides easy-to-use interface for people unfamiliar with firewall concepts. It provides a framework for managing netfilter as well as the command-line interface to manipulate the firewall. With its small command set and plain English parameters, UFW makes it quick and easy to understand and set up firewall rules. At the same time, you can use UFW to configure most of the rules possible with iptables. UFW comes preinstalled with all Ubuntu installations after version 8.04 LTS.

Follow these steps to secure network with uncomplicated firewall:

Step 1 : UFW comes preinstalled on Ubuntu systems. If it's not, you can install it with the following commands:

Step 2 : Check the status of UFW

Step 3 : Add a new rule to allow SSH

Step 4 : Alternatively, you can use a port number to open a particular port

Step 5 : Allow only TCP traffic over HTTP (port 80)

Step 6 : Deny incoming FTP traffic

Step 7 : Check all added rules before starting the firewall

Step 8 : Now enable the firewall

Step 9 : Check the ufw status, the verbose parameter is optional:

Step 10 : Get a numbered list of added rules

Step 11 : You can also allow all ports in a range by specifying a port range

Step 12 : If you want to open all ports for a particular IP address, use the following command

Step 12 : Alternatively, you can allow an entire subnet, as follows:

Step 13 : You can also allow or deny a specific port for a given IP address

Step 14 : To specify a protocol in the preceding rule, use the following command

Step 15 : Deleting rules

Step 16 : Delete rules by specifying their numbers

Step 17 : Add a new rule at a specific number

Step 18 : If you want to reject outgoing FTP connections, you can use the following command

Step 19 : UFW also supports application profiles. To view all application profiles, use the following command:

Step 20 : Get more information about the app profile using the following command

Step 21 : Allow the application profile as follows

Step 22 : Set ufw logging levels [off|low|medium|high|full] with the help of the following command

Step 23 : View firewall reports with the show parameter

Step 24 : Reset ufw to its default state (all rules will be backed up by UFW)