owner module
Take a look at this URL titled: Iptables Tutorial 1.2.2. This page lists several of the matching techniques one can do using owner information about a process.
The owner match extension is used to match packets based on the identity of the process that created them. The owner can be specified as the process ID either of the user who issued the command in question, that of the group, the process, the session, or that of the command itself. This extension was originally written as an example of what iptables could be used for. The owner match only works within the OUTPUT chain, for obvious reasons: It is pretty much impossible to find out any information about the identity of the instance that sent a packet from the other end, or where there is an intermediate hop to the real destination. Even within the OUTPUT chain it is not very reliable, since certain packets may not have an owner. Notorious packets of that sort are (among other things) the different ICMP responses. ICMP responses will never match.
Match --uid-owner
$ iptables -A OUTPUT -m owner --uid-owner 500
Match --gid-owner
$ iptables -A OUTPUT -m owner --gid-owner 0
Caveat
The documentation I reference is severely out dated, but is in fact still referred to on the official netfilter.org website: http://www.netfilter.org/documentation/.
Consulting the built-in docs
So I would take this opportunity to teach you another skill that will carry you far and wide as you continue to use Linux/Unix and opensource software for that matter. Consult the usage and/or man pages, since they're likely the most up to date information you'll find when dealing with various tools.
Example
The module we're dealing with within iptables
is called owner. So we can query a extensive usage guide on it like so:
$ iptables -m owner --help
Doing so will reveal that these are the supported owner match options:
owner match options:
[!] --uid-owner userid[-userid] Match local UID
[!] --gid-owner groupid[-groupid] Match local GID
[!] --socket-exists Match if socket exists
NOTE: You can check what version you have like so:
$ iptables --version
iptables v1.4.18
I encourage you to read through this usage guide to gain further insights into how to use the tool and also to understand how to use the tool.