Simple iptables tutorial for Linux

File: /etc/sysconfig/iptables :

———————————————————————————–

*filter

#This line will block any incoming connections except for the rules we allow later in this file.
:INPUT DROP [5:574]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [136:13895]

#These two lines are the basics for allowing incoming connections.

-A INPUT -m state –state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT

# This line allows SSH

-A INPUT -p tcp -m tcp –dport 22 -j ACCEPT

COMMIT
*nat

:PREROUTING ACCEPT [468:62332]

:POSTROUTING ACCEPT [252:15827]
:OUTPUT ACCEPT [559:41614]
COMMIT

———————————————————————————–

When your done editing this file run:

# service iptables restart