Route traffic only for processes that bind to tun0 (Linux)

This forum is for general conversation and user-user networking.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
User avatar
ManuHry
OpenVpn Newbie
Posts: 2
Joined: Thu Aug 18, 2022 2:09 pm

Route traffic only for processes that bind to tun0 (Linux)

Post by ManuHry » Thu Aug 18, 2022 2:21 pm

Hi all,

I would need to use OpenVPN for a few processes only, not for all my Linux system.
These processes can bind to tun0 directly, forcing them to use VPN only.

I thought I could accomplish that with 2 steps :
  • include "route-nopull" in my client config file
  • bind my processes to tun0
Could you tell me if this is the "right way" to proceed ?
Or do I have to use a more optimized solution ?

Thanks in advance and best regards :)

TinCanTech
OpenVPN Protagonist
Posts: 11137
Joined: Fri Jun 03, 2016 1:17 pm

Re: Route traffic only for processes that bind to tun0 (Linux)

Post by TinCanTech » Thu Aug 18, 2022 5:37 pm

ManuHry wrote:
Thu Aug 18, 2022 2:21 pm
Could you tell me if this is the "right way" to proceed ?
That is the wrong way to proceed.

User avatar
ManuHry
OpenVpn Newbie
Posts: 2
Joined: Thu Aug 18, 2022 2:09 pm

Re: Route traffic only for processes that bind to tun0 (Linux)

Post by ManuHry » Thu Aug 18, 2022 5:50 pm

TinCanTech wrote:
Thu Aug 18, 2022 5:37 pm
ManuHry wrote:
Thu Aug 18, 2022 2:21 pm
Could you tell me if this is the "right way" to proceed ?
That is the wrong way to proceed.
Hi @TinCanTech, thanks for your answer.

Do you know a better way, or best-practice ?
It works by my side with some provider (I made traceroute comparisons), but I cannot evaluate performance.

TinCanTech
OpenVPN Protagonist
Posts: 11137
Joined: Fri Jun 03, 2016 1:17 pm

Re: Route traffic only for processes that bind to tun0 (Linux)

Post by TinCanTech » Thu Aug 18, 2022 5:53 pm

Openvpn does not work the way you want. --route-nopull will break your VPN completely.

Edit: Your OS does not work that way either, you need another app to do packet filtering by application.
ManuHry wrote:
Thu Aug 18, 2022 5:50 pm
Do you know a better way, or best-practice ?
https://community.openvpn.net/openvpn/wiki/HOWTO

Post Reply