iptables

Here is a helpful illustration of the basic flow of a network packet.

flow