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?
iptables -m owner. This lets you setup
OUTPUT chain rules based on UID, GID, PID, SID and command name.