Understanding connection tracking in iptables
        Posted  
        
            by 
                Matt
            
        on Server Fault
        
        See other posts from Server Fault
        
            or by Matt
        
        
        
        Published on 2012-11-26T22:59:31Z
        Indexed on 
            2012/11/26
            23:05 UTC
        
        
        Read the original article
        Hit count: 310
        
I'm after some clarification of the state/connection tracking in iptables.
- What is the difference between these rules? - iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT 
- Is connection tracking turned on when a packet is first matched containing -m state --state BLA , or is connection tracking always on? 
- Can/Should connection state be used for fast matching like below? 
e.g. suppose this is some sort of router/firewall (no nat).
# Default DROP policy
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
# Drop invalid
iptables -A FORWARD -m state --state INVALID -j DROP
# Accept established,related connections
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow ssh through, track connection 
iptables -A FORWARD -p tcp --syn --dport 22 -m state --state NEW -j ACCEPT
© Server Fault or respective owner