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


# 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 -m state \