Ubuntu 14.04 comes with a firewall already installed. But if you are not good on the command line, you may want to use a Graphical User Interface to configure it.
To install the Graphical User Interface for the UFW Firewall, open the Terminal and type:
sudo apt-get install gufw
It is now installed. Just search for Firewall to open it. It will ask for your password.
Most user will only need to use the following basic settings: