Network communications go through "channels" called ports. You can restrict which ports are available ("open") for network communications, creating a barricade to unwanted network intrusion. Firewalls do this job for you. But I guarantee that if you install one before you know how to use it that one or more networking programs on your system will stop working. Read every bit of documentation about a firewall before installing it -- you won't regret the time invested. All of these packages modify iptables, which is the set of rules that controls network access in and out of your computer. (You can modify iptables manually from the command line, as well, but if you are that much of an expert, you probably don't need this guide.)
Firestarter
Firestarter is an intuitive firewall manager used to set the iptables values which provide firewall capabilities in Linux (including Ubuntu). It has a very easy-to-use GUI.
sudo apt-get install firestarter
Guarddog
Guarddog is a GUI firewall configuration utility that has been used for KDE. It has a complex array of configuration, and is difficult to use for some beginners.
sudo apt-get install guarddog
Uncomplicated Firewall
Uncomplicated Firewall is installed in Ubuntu Intrepid Ibex by default, but is disabled by default. It is configurable through the command-line interface (i.e. Konsole). See this forum thread , or this usage tutorial for tips on how to set up and use it. If not installed, it can be installed:
apt-get install ufw
Gufw
Gufw is a graphical user interface for Uncomplicated Firewall. Install:
sudo apt-get install gufw