the usual
inconsistent at best
iptables notes

Here are some notes I keep for myself when I play with iptables (I don’t use it often enough to remember how it works):

List all rules

# iptables -L

See the rules and their numbers

# service iptables status

Delete a rule

# iptables -D CHAIN NUM

E.g.:

# iptables -D INPUT 12

Add a new rule at the bottom of the chain

# iptables -A INPUT -i eth0 -p tcp --dport 8888 -j ACCEPT

Insert a new rule in a particular place

This inserts a rule in position 6; the rule that was formerly in 6th position will be bumped down (and all rules below it):

# iptables -I INPUT 6 -i eth0 -p tcp --dport 8888 \
-s 192.168.0.0/12 -m state \
--state NEW,ESTABLISHED -j ACCEPT

Last modified on 2012-03-09