Allowing Established Sessions using iptables

Allowing Established Sessions

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

-A, --append chain rule-specification

Append one or more rules to the end of the selected chain.

--state state

Where  state  is  a  comma separated list of the connection states to match.  Possible states are INVALID              meaning that the packet could not be identified for some reason which includes running out of memory  and          ICMP  errors which don't correspond to any known connection, ESTABLISHED meaning that the packet is associated with a connection which has seen packets in both directions,  NEW  meaning  that  the  packet  has started  a  new  connection, or otherwise associated with a connection which has not seen packets in both directions, and RELATED meaning that the packet is starting a new connection, but is associated  with  an existing connection, such as an FTP data transfer, or an ICMP error.

-j, --jump target

This specifies the target of the rule; i.e., what to do if the packet matches it.