LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-14-2013, 10:56 AM   #1
tkalfaoglu
Member
 
Registered: Oct 2003
Location: Izmir, Turkey
Distribution: Fedora Core 10
Posts: 68

Rep: Reputation: 15
Application specific routing (not routing p2p over vpn)


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?

Thanks!

Last edited by tkalfaoglu; 06-14-2013 at 10:59 AM.
 
Old 06-15-2013, 06:33 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
Quote:
Originally Posted by tkalfaoglu View Post
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
VPN and routing dormant Linux - Networking 8 08-28-2010 06:31 PM
Vpn Routing Franxez Linux - Server 4 10-08-2009 02:22 PM
VPN Routing kevosurge Linux - Networking 2 08-17-2009 07:29 AM
VPN routing Ipolit Linux - Networking 4 02-08-2007 01:58 AM
routing on a specific port stapper Linux - Networking 0 10-10-2002 01:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration