Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Exclude an IP range and/or an app from a VPN connection

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
h0m
Posts: 3
Joined: 2017-01-19 00:43

Exclude an IP range and/or an app from a VPN connection

#1 Post by h0m »

Hello there,

Some times ago, I added a VPN (an OpenVPN to be exact) client to reach the Internet through it by default (for all application and users) on all my computers. Everything runs fine. However, my VPS's IP range (where is my VPN server) seems to be banned by few websites (mainly one actually).That's why I would like to exclude some specific users and/or specific destinations from the VPN in order to access to Internet directly.

I think there are mainly two approaches:

The first one consists to exclude a specific user to be routed through the VPN. Like that I could run a proxy under this user and configure my browser (or whatever application as long as it's "proxyable") to use it for specific websites. Add/remove websites or applications will be easy. Moreover, I could even share the proxy with my other local computers.

The other approach is to exclude only a specific IP range (the IP range of the servers that host the website) to be routed through the VPN. It's probably the lighter and quicker solution but adding or removing new websites won't be as easy as in the first approach. Moreover, if the website IP range change, it'll be broke and I'll have to update it. Also, I'll have to configure (and regularly update) all my computers.

Maybe someone here would like to share his/her experience or knows a better solution or simply has some interesting arguments.

But the main point and why I'm asking your help is that I know anything about routing, iptables, etc. I tried to find proper commands to reach my goal but I didn't success... I can deal with users, installing a proxy daemon (I was thinking about Tinyproxy btw), but iptables, route, ip etc. commands are unfathomable for me even with the man pages. So don't hesitate to consider I'm eight years old newbie.

Thank you!

h0m
Posts: 3
Joined: 2017-01-19 00:43

Re: Exclude an IP range and/or an app from a VPN connection

#2 Post by h0m »

Nobody knows?

User avatar
Justin417
Posts: 29
Joined: 2014-06-01 02:26
Location: Pittsburgh, PA

Re: Exclude an IP range and/or an app from a VPN connection

#3 Post by Justin417 »

Do you have access to the .conf or .ovpn file that your clients use?

This is a method that I use for excluding sites from being routed through the VPN. Open your OpenVPN configuration file. Add this section in the file:

Code: Select all

route www.example.com 255.255.255.255 net_gateway
To customize this, change http://www.example.com to the website you want to exclude from being routed through the VPN.

This would have to be done from the client side, this configuration option does not work on the server side.

Hope I could be of some assistance :D

h0m
Posts: 3
Joined: 2017-01-19 00:43

Re: Exclude an IP range and/or an app from a VPN connection

#4 Post by h0m »

Thank you very much, it's not exactly what I was thinking but that helps me a lot! It's a convenient and easy way. For some reasons, NetworkManager doesn't accept a domain name in its routing table but I should to look for a similar rule to send from the openvpn server. In the meantime, I add the rule through an ip command.

Thanks again. Have a great day!

User avatar
Justin417
Posts: 29
Joined: 2014-06-01 02:26
Location: Pittsburgh, PA

Re: Exclude an IP range and/or an app from a VPN connection

#5 Post by Justin417 »

No problem! I do wish I could have helped more specifically, but OpenVPN isn't always the easiest software out there to configure.

Just remember when adding it by IP instead of by domain, if the site uses a content delievery network it could have many different changing IPs, so take that into consideration if you are having issues.

Post Reply