How To Install A Custom Iptables Firewall

How To Install A Custom Iptables Firewall

. This guide is to show you how to edit your iptables if you’re running on a server This guide info came from iptables rocks, but i edited a bunch of data to make it suitable for what i want it to do

Check to see if you already have iptables installed

if iptables is installed you should see this outputted in console screen

If iptables is not installed run use this command

Configuring System Files

This will log kernel (user) usage and activities to a log file so that the admin can look at it later

Open terminal and sign in as root (su-)

Then type mkdir /var/log/firewall. This creates the virual directory where all this information will be stored

gedit /etc/syslog.conf

Edit the log file so that it should look like this

To activate these configurations type/etc/rc.d/init.d/syslog restart

This will make the kernel log activities

Then to make sure FTP sessions run correctly run this command

Further System Preparation

Well, I dont know about you but wouldnt you like a saftey in case something goes bad… I know that i would, because it wont be fun if you’re locked out side of you’re system with all that importent data inside… A friend of mine did that do his dad’s PC once 🙂

Go into terminal and type su – and then enter password

Then enter this command (it creats the script(it resets you’re settings if you screw up)


run this command if you lock you’re self out from now on

One of the 2 scripts needed

To create script rungedit /root/primary_firewall

Then enter iptables-restore < /root/primary_firewall

into the terminal (remember to be root)

The second firewall script

This script is an advanced program that scans ports constantly for hackers/viruses and other undesireables…Together with the above script you will have a very formidable defense system indeed

Sign in as root

Make this directory

mkdir /var/lock/subsys

Edit this file(type in gedit first :)) /etc/init.d/firewall.iptables

Enter in this code

As root enter in this command

chown root:root /etc/init.d/firewall.iptables

chmod 700 /etc/init.d/firewall.iptables

Then enter cd /etc/init.d

And enter /sbin/chkconfig –level 345 firewall.iptables on

Then enter /etc/init.d/firewall.iptables start