Iptables is a  firewall on linux  os.You can manage your ınput and output traffic with a lots of properties.You can use iptables like a router, nat or proxy too.

There are three default chain comes with  iptables.These are

Input:You can arrenge packets that comes to your computer.

Forward:You can arrrange packets that forwarded on your computer.

Output:You can arrange your output packets from your computer.

Processes to packets: Drop, reject, accept or forwarding another  chaine . We will check having  rpm packets or not.


Iptables rules define on at this file.






Listing the rules






We can define with -P (policy) iptables chain situation.Such as drop input packets.





As you see policy is dropped.

We can delete all rule in a chain.

# -f flush





Adding rule to the end of the chain





We can add rule on a chain which line we want.




As you see we  add 2. INPUT  rule is DROP

We can create new chain with this command





Deleting a rule on the chain

We add a rule to NewChain and then deleted it







Deleting the chain






When we define rules, we can add more option too, such as protocol source ip source port likely destination ip and port.

–sport  – = source port and if you use “!” this mean expect this port.

–dport  – = destination port

İf you use icmp protocol, you filter according to icmp packet type


-ı  and -o parametres are using to define which interface us it.-ı  UNPUT, -o OUTPUT

We can define rules to iptables, we are able to write rules according to its situation.

NEW:first packet that side start to connection

RELATED:Sended packet  depend on an old  established connection.

ESTABLİSHED:Packet that depend on established connection

INVALID: Packets that doesn’t depend on any connection.

-j define the actions such as;






We can saved he rules that defined with “iptables-save” command and we can write this rules to a  file for making our rule permanent.





We can save with “service iptables save” too.

I will take a copy of my rules for restoring.I can use these command another host or I can restore my iptables with this command.





These are basic configuration of iptables you can more info on man page of iptables. Type to your console:

or read this page;


Good luck!