Creating A Firewall For Your Linux Server With IP Tables

When you are looking to be able to secure your server you must have a tool that will allow you to do this. When you are running a Linux server the number one way to do this is by using a piece of software that is known as IP tables. While Linux is one of the most secured operating systems that you can run a server on, it does have ways that the bad guys are able to get in. If you want to stop that from happening you must take the proper security measures on the operating system. In this article I will talk to you about IP tables and how you can make sure your server is secure by running it.

creating a firewall on a Linux server with IP tables

creating a firewall on a Linux server with IP tables

First a little history on IP tables

If you are new to either Linux or servers themselves you might be asking yourself why IP table is so important. The answer to that is simple. It is a type of software that is known as a firewall. Now you might be asking yourself what is firewall software. You might not know it but you run into firewall software all of the time. Your router at home might run it. Or the network that you use at work might run it as well. Firewall software allows you to be able to block open ports that are in your operating system.

When you have an operating system that allows connection to a network or the internet, it is able to do this by holes that are known as ports. Iwill use holes for lack of a better term. These allow the data stream from the network or internet to come into the operating system. Once it is there the software that is dedicated to the stream deciphers and turns into data that is human readable. So that you may have several connections going on at once, there are thousands of ports that are available for you to use. Some of the ports are dedicated to standards that all of the operating systems use. For example port 80 is the standard for the internet. When your browser gets its data from the internet it is more than likely going to go to port 80.

So with all of those ports being open you need something that is able to block them. While you are going to need some ports open there is no need to have that many. That is where firewalls and IP tables come in. With that software you are able to block any open ports except the ones that you choose to remain open.

Starting IP tables for the first time

The first thing that you want to do before you turn on IP tables is make sure that it is installed on the machine that you are using. Some Linux distributions have IP tables already installed as a default and some do not. So depending on the distribution of Linux that you are using you are going to run “apt-get install ip tables”. Some Linux distributions do not run apt-get but something similar. If you are using a distribution that does not run “apt-get” then use your systems command. You must run either sudo or su to be able to install ip tables on your machine. That means you must have root access. It is a high level function that requires root usage.

So now that is installed, it is now time to set up how IP tables is going to run. You do this by setting up the rules in a script. There are many third party software vendors out there that have a graphical set up that you can use to create this script. But more than likely though you are on a server that has no graphical setting. You are most likely going to do everything by command line. To create the script on the command line you will probably use Vim or Emacs. A great tutorial on how to do that is located at . When you first take a look at these settings it might seem overwhelming at first but the more that you use them, the easier it becomes just like anything else. The more familiar you are with Linux and the way that it works the easier getting this script down will seem to you. Once your script is running you are ready to restart your server and now have it protected.

When you are running a server you need to make sure that it is protected. You are more than likely going to have a lot of visitors over time and not all of them are going to be good guys. You need to make sure that you have the right tools installed to be able to stop them. Also IP Tables is not only for servers. If you are running the Linux operating system you can use it on your desktop as well.

About Lee Munson

Lee's non-technical background allows him to write about internet security in a clear way that is understandable to both IT professionals and people just like you who need simple answers to your security questions.


  1. […] That is the main way that hackers are able to get in so you want to avoid that if possible. A popular firewall solution on Linux is IPTables. And last but not least is that you want to make sure that all of the software, which includes the […]

  2. […] Have Been Searching For?Open Source Software Is Pretty Safe But Are There Still Some Security Risks?Creating A Firewall For Your Linux Server With IP TablesThanks for visiting and I’m looking forward to writing more for you next week on a variety of […]

Leave a Reply to Essential Security Reading Cancel reply