This is a tough one:
To understand security it's not just a matter of setting up firewalls.
I would first recommend reading this book:
Hacking Linux Exposed
Paperback - 608 pages (April 2001)
Osborne McGraw-Hill; ISBN: 0072127732
Then get this as a reference book:
Internet Core Protocols
Basically you'll need to understand how ports and sockets are used and the different protocols used in the OSI model and how they all work to create internet/network connectivity.
Then check out some of the FAQ's for netfilter, it doesn't go through it step by step but it will show you examples to experiment with.