Here are some frequent iptables usage notes. 
 iptables -nvL --line-numbers 

  • -L : List rules. --line-numbers : Show rule number  -v : Verbose.
  • -n : Display IP address and port in numeric format. Do not use DNS to resolve names.
  • -t : Show rules from table. e.g. -t nat, By default iptables assumes the 'filter' table.
  • -F : Flush rules.  -P : Default rule.  -X : Delete custom chain with no references.
  • -A : APPEND   -I : INSERT   -D : Delete  -R : Replace

  • --dport : destination-port. It's a flag for one of it's extended packet matching modules i.e. used with -p protocol or -m.

Define custom chain.  

Add a chain LOGGINGEverything not being -d  127.0.0.0/8 or 239.192.0.0/16 would be logged, then control would go back to the OUTPUT.
All packets coming through the OUTPUT chain would go through the LOGGING chain.
$ iptables -N LOGGING
$ iptables -A LOGGING -d 127.0.0.0/8 -j RETURN
$ iptables -A LOGGING -d 239.192.0.0/16 -j RETURN
$ iptables -A LOGGING -j LOG 
$ iptables -A OUTPUT -j LOGGING 

Use iprange module
 iptables -t mangle -A LOGGING -p tcp -m iprange --dst-range 192.168.1.1-192.168.1.20 -j RETURN

Use iprange module
 iptables -t mangle -A LOGGING -p tcp -m iprange --dst-range 192.168.1.1-192.168.1.20 -j RETURN 

Use multi port with tcp / udp
 -p tcp  --match multiport --sports 80,443 -j LOGGING

Logging with limit module
 -m limit --limit 3/min -j LOG --log-prefix "iptables denied: " --log-level 4

State & MAC ADDRESS
 -m state --state NEW -m mac --mac-source YOUR-MAC-ADDRESS-HERE

Use iprange module
 iptables -t mangle -A LOGGING -p tcp -m iprange --dst-range 192.168.1.1-192.168.1.20 -j RETURN


# References iptables
https://wiki.archlinux.org/index.php/iptables

http://artoflinux.blogspot.com/2008/07/iptables-tutorial-for-beginners.html

http://www.cyberciti.biz/faq/rhel-fedorta-linux-iptables-firewall-configuration-tutorial/

http://www.netfilter.org/documentation/HOWTO/packet-filtering-HOWTO-7.html

Rate Limiting

http://serverfault.com/questions/384132/iptables-limit-rate-of-a-specific-incoming-ip
http://courses.oreillyschool.com/sysadmin5/IPTablesSpeedLimits.html