Tuesday, August 24, 2010

IPTABLES (Firewall)

###################### IPTABLES ########################

*NATING = network address translation.

*PATING = port address translation.

*What is Routing
ANS :- forwarding the packet from 1 interface to another interface.

Postrouting - After routing change the source ip address.
              To hide the internel network (Dnat).

Prerouting - Before routing change the destination ip address.(Snat)

INPUT Chain - To configure in filter tables.

Targets --> ACCEPT,DROP,REJECT.
            drop - no acknoledgement
            reject - get acknoledgement.

icmp - internet control messege protocol.

#######################################################

1)To Configure the iptables command is.
#iptabls

                            Filter               NAT                            Mangle

                        INPUT           PREROUTING                 INPUT

CHAINS:-      OUTPUT        POSTROUTING              OUTPUT

                       FORWARD        OUTPUT                  PREROUTING

                                                                                    POSTROUTING
  
                                                                                    FORWARD

########################################################

1)To apply the rules.
ACCEPT,DROP,REJECT.

-L --> To listening
-A --> To append
-p --> Protocol
-j --> To jump
-F --> To flush

2)To check whether the rule is applied or not.
#iptables -L

3)To remove the previous rules.
#iptables -F

4)To remove the rule.
#iptables -D

5)To insert a rule.
#iptables -I


6)To install the rules.

1)(ping)input traficc block.
#iptables -A INPUT -p icmp -j DROP/reject

2)To block perticuler matchine.    
#iptables -A INPUT -p icmp -s 10.0.0.1 -j DROP/reject

3)To allow 1 matchine & block other all traffic.
#iptables -A INPUT -p icmp -s ! 10.0.0.1 -j DROP/reject

4)To block http service.
#iptables -A INPUT -p tcp --dport 80 -j DROP/reject

7)To set the iptables rules Permanent.
first set the rules.
#service iptables save

8)To delet the set rules.
#rm /etc/sysconfig/iptables

9)To remove a rule from the chain.
#iptables -D INPUT 1 -t filter

################### END #########################