Saturday, November 12, 2011

Host Firewall - Level 1

I know there are a ton of websites out there talking about firewalls, especially iptables, however I wanted to just take a minute to create a basic, but very functional firewall. So, here it is.

1) backup your current config file

sudo cp /etc/sysconfig/iptables /etc/sysconfig/iptables.orig


2) Edit the file /etc/sysconfig/iptables with your favorite editor (vi) and add the following lines

*filter
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -j DROP
COMMIT


3) Restart the iptables firewall

sudo service iptables restart


4) Enjoy

Note: This testing was done on CentOS 6.0

No comments:

Post a Comment