Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to force the use of VPN using iptables, therefore while VPN is disabled no outgoing traffic shall be allowed (except maybe some DHCP stuff...). Now i guess I could just block everything not going to the address of the VPN server? But then I still want to do another thing: I don't want to allow all traffic for some application, e.g. some shall have no internet access, some shall have only access to specific IP addresses. Is something like "application level" possible using iptables? Does iptables recognize, from which application traffic originates? And I guess when using VPN I can't filter for the real destination that comes behind the vpn server as it is probably encrypted in the vpn packets?

share|improve this question


use iptables -m owner. This lets you setup OUTPUT chain rules based on UID, GID, PID, SID and command name.

share|improve this answer
Note that when you create a VPN connection, another interfaces is generally created and used. The traffic for the VPN can be routed to just that interface, as in the link. – Arcege Apr 7 '12 at 1:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.