Skip to contentSkip to conversation

Howto: filtering on a per process/program basis

DISCUSSION U.Mutlu 2 participants 2 messages Sep 16, 2011 netfilter

lore
Share & tools
lore

U.Mutlu

author
#0 lore raw

Hi,
I need filtering on a per process (ie. program name) basis.
Is this already possible in iptables/netfilter/xtables etc., or in an addon?

Practically:
Normal filtering rules based on srcaddr, dstaddr, proto, srcport, dstport etc, Allow only specified applications sending of packets,
Allow only specified applications reception of packets, Optionally log anything else,
Discard anything else.

When I write and install a netfilter module then how would I go to get the process name from within the kernel module?

#1 lore raw
Quoted 18 lines

-----Original Message-----
From: [email protected] [mailto:netfilter-devel- [email protected]] On Behalf Of U.Mutlu
Sent: Friday, September 16, 2011 3:49 AM
To: [email protected]
Subject: Howto: filtering on a per process/program basis

Hi,
I need filtering on a per process (ie. program name) basis.
Is this already possible in iptables/netfilter/xtables etc., or in an addon?

Practically:
Normal filtering rules based on srcaddr, dstaddr, proto, srcport, dstport etc, Allow only specified applications sending of packets,
Allow only specified applications reception of packets, Optionally log anything else,
Discard anything else.

Quoted 2 lines

When I write and install a netfilter module then how would I go to get the process name from within the kernel module?

I don't know how you'd get the process name, but an alternative that might work for you if you have control over the applications' implementation would be to have those applications set the SO_MARK socket option on the sockets they use. You could then use the standard iptables mark match extension to filter on the mark and save yourself the bother of writing a kernel module.

Jeff Haran