Monday, January 01, 2007

Locking Down Ubuntu - Firewalls

The best way to protect yourself from attackers on the Internet is to disconnect yourself from the Internet. The next best way is to install a firewall, which is like a lock on a door to a room inside of a building. It allows only authorized programs and protocols to open the door between your computer and the Internet. It also locks the door from the outside, keeping people and programs from opening the "door", walking in, and harming your computer. A firewall uses filters that either allow or prevent programs from sending or receiving data. If there is protocol with a security hole in your computer, you can configure the firewall to block all incoming connections to that protocol until the hole is fixed.

Although both Ubuntu and Kubuntu are fairly secure--they do not leave any ports open by default--it is always a good idea to install a firewall. Since firewalls are important to making a computer more secure, two firewalls are evaluated in this article: Firestarter and Guarddog. Each has strengths and weaknesses, both in the GUIs(Graphical User Interface) and the way they run, so it is a matter of personal preference. Both of them work on any official Ubuntu distribution or other popular Linux distributions (such as SUSE or Fedora Core). The following instructions will show you how to set up Firestarter for Ubuntu and Guard dog for Kubuntu, but they work just fine vice versa. Even though the firewalls are different, there are some firewall security principles that apply to any firewall and operating system. All firewalls either white-list or blacklist IP addresses (Internet Protocol address) and protocols. A white-list isan explicit list of protocols and IP addresses that the firewall lets pass through. A blacklist is the exact opposite of a white-list: it is an explicit list of protocols and IP addresses that the firewall will block.

There are some common protocols that you will either want to white-list not want to blacklist. They are:

Http/Https(Common web site protocol)

Ftp, (A file transfer protocol. Many web sites use this to upload and download files)

Smpt(An email sending protocol)

Pop3(An email receiving protocol)

(A list of more ports can be found at:http://www.chebucto.ns.ca/~rakerman/port-table.html)

Allow the firewall to permit only the few protocols and/or IP addresses that you will be using. If you don't recognize a protocol, block it. You can unblock any protocol later when you have a need for it.


Firestarter(For Ubuntu)

Firestarter(based on the GTK GUI toolkit) focuses on simplicity. Firestarter allows the white-listing of good connections; it blocks all connections from the start, both incoming and outgoing. After you have installed Firestarter, go to Applications -- System Tools-- Firestarter to start it. You should see a blue icon appearing your system tray. The first time you run Firestarter, a wizard is automatically launched. If you need to return to the wizard later,you can access it from the Firewall menu. All of the choices that you make in the wizard can be changed by going to Edit --Preferences.

Click on the Policy tab to get started. You will see a drop down menu next to the word Editing. Click on it and select the Outbound traffic policy. Now make sure the radio button that saysRestrictive by default, causing the firewall to block all traffic that is not white-listed. This will make your computer very secure by only allowing a few programs to open the "door".

The next step is to tell Firestarter what protocols you don't want to lock down. Right click on the Allow Service Portand For tables. Click on Add Rule, select a name from the drop down menu, or enter your own protocol name and port. You have the option to allow any computer on the Internet or network, the firewall host (your computer), or IP address (a specific computer Internet Protocol address on the Internet or your network).Select the appropriate source and click Add. Do this for any protocol you want to use (such as email, web, etc). You can use this same process to allow incoming connections (click on Incoming traffic policy next to the word Editing instead ofOutgoing traffic policy).

(Insert firestarter.jpg here)

When Firestarter blocks a connection, the icon in the system tray turns red. If you are having trouble with either connecting to another computer or browsing the web, click on the red icon and then click onthe Events tab. This will show you what protocol(s)Firestarter has blocked and you can now white-list the protocol if you need to use it.

If you notice that Firestarter blocks a particular computer's IP and you recognize it (as it may be a family member or colleague's computer),add the IP to the Allow connections from host table under the appropriate outgoing or incoming policies.


Guarddog(For Kubuntu)

Guarddog(which uses Qt for it GUI toolkit) differs from Firestarter because it lets you configure a firewall for numerous networks such as the Internet, your local computer, and your Local Area Network. The advantage of using Guarddog is that you can configure a firewall for as many different networks as you want. To configure Guarddog, go to Kmenu -- System -- Guarddog.Enter your password to continue. After you enter your password, click on the Protocol tab and select on the the "zone"(what Guarddog calls the configurations for different networks) that you would like to configure. On the right you will notice the Zone Properties tree. Click on the tree category that you would like to configure (such as Chat)and it will expand, revealing several common protocols. Guarddog automatically blocks every protocol by default so you will have to white-list the protocols you'd like the firewall to accept, and blacklist the protocols you'd like the firewall to outright reject.You should click on the Network tree and enable DNS andICMP Redirect if you can not browse the web.

To to add a protocol that is not in any of the trees, click on the Advancedtab and add a new protocol under User Defined Protocols to be able to enable or disable it in the Protocol tab. To block a certain IP address or domain, create a new zone and leave all the check boxes blank (to block all protocols).

If you use a router to connect to the Internet and/or are behind a NAT you should create a new zone for the Local Area Network that you belong to. You should d enable the Internet and Localzones so that you will be able to connect to the Internet and the Local zones. Now click on the Protocol tab and check to see if the new zone you have created is selected under Protocols Served from Zone. Configure the firewall to allow the protocols you need to pass through it for the Local and Internet column. By selecting the check boxes in both columns you allow your computer to use the checked protocols on your local area network (which goes to your router which is connected to the Internet).

Now move over to the Protocol tab and make sure that Protocols Served from Zone is set to your newly created zone. Check the protocols you need to enable. By turning these on for the LocalorInternetzones, you allow your computer to use the checked protocols in the new zone you created.

(Insert guarddog.png here)

When you are finished with configuring your changes, click Apply to change the settings. If your firewall keeps you from browsing theweb, or starting certain system services you can temporarily disable it until you find out what it's blocking; click on the Advancedtab, check Disable Firewall and click Apply.


Testing your firewall

To see if your firewall is doing what you want it to do you can test it athttp://www.grc.com at the Gibson Research Center. Go toShields Up or Leak Test to try out your firewall.


Summing it up

You now have a fairly secure system. It will be hard for a cracker to break into your computer, or for some other user on your computer to read sensitive data (you may want to encrypt that data to be even safer).Always remember that your computer will remain secure if you are careful and do not accidentally enable a protocol that you don't use,or copy sensitive data to a folder that anyone can read.

delicious digg technorati yahoo newsvine google socialize