Quote:
Originally Posted by tkalfaoglu
I'm using OpenVPN normally for all my applications, but for some, such as p2p, I'd like to disable it so it uses regular wlan0 for its traffic.
Is there a way of configuring iptables/ip route so that some apps route traffic directly instead of via vpn?
I know that I can route traffic based on the destination port, but does that work for a p2p application as well?
|
You can do policy routing based on a lot of things, including packets marked internally by iptables. And while you can mark packets based on process ID, the PID will change whenever you restart the application, so marking based on owner (UID or GID) is probably a better idea: Create a group, change the GID of the executable to that group, set the SGID bit and you're in business.
The iptables MARK rule would look something like this:
Code:
iptables -t mangle -A OUTPUT -m owner --gid-owner yourgroup -j MARK --set-mark 0x4 # Just a randomly chosen non-zero number
Then create a custom routing table pointing to the gateway of wlan0, and a rule forcing the marked packets to use that table:
Code:
ip route add table 4 0.0.0.0/0 via gateway.ip.of.wlan0
ip rule add fwmark 4 table 4