Iptables – How does iptables execute rules

csffirewalliptables

I've been having some trouble with a firewall blocking traffic between two servers recently and want to check how iptables handles multiple rules applying to the same IP. If I run iptables -L -n | grep 1.2.3.4 I see this output:

ACCEPT    all  --  1.2.3.4      0.0.0.0/0
DROP      all  --  1.2.3.4      0.0.0.0/0
ACCEPT    all  --  0.0.0.0/0            1.2.3.4
DROP      all  --  0.0.0.0/0            1.2.3.4

How will iptables process these rules? Will all traffic from 1.2.3.4 be dropped?

Best Answer

Hard to say since you're not displaying for which chains these rules apply.

Easily said: For a firewall you've got to start with the FORWARD chain and follow all rules that match in sequence until you hit an ACCEPT, DROP or REJECT

If you reach the end of all rules this way, the FORWARD's default policy applies.

Related Topic