9

My desktop machine runs Trisquel GNU/Linux 6.0 (which is basically a libre version of Ubuntu 12.04), and I use OpenVPN to connect to a commercial VPN provider for internet access.

It currently routes all my traffic through the VPN, which is great, but I'm looking for a way to allow requests to one specific IP address to bypass the VPN. I'm sure there's a way but repeated web searching hasn't yet turned up anything (best I could find were instructions for doing this on the Cisco VPN client for Windows).

Can you help?

Thanks.

Lloyd Smart
  • 93
  • 1
  • 1
  • 4

3 Answers3

21

Simply add a route for that IP to your local gateway.

You can do this in your openvpn client config like this.

route 10.99.77.55 255.255.255.255 net_gateway

In the config net_gateway is automatically replaced with the correct address.

Zoredache
  • 128,755
  • 40
  • 271
  • 413
  • Thanks for the help, but I configured this vpn connection via NetworkManager, so there's no openvpn config file. Jeff's solution below worked for me. – Lloyd Smart Mar 13 '13 at 15:27
  • 1
    Thats fine. Do understand, that you will need to re-run that command every time the VPN has been established. Routes do not persist across a reboot. Heck they won't even persist across a disconnect of OpenVPN unless you pass the `persist-tun` option. – Zoredache Mar 13 '13 at 18:14
  • Thanks for the tip. You prompted me to look further into this, and I discovered that I could make this permanent by adding the information to the "routes" dialog on the IPv4 tab of the NetworkManager settings for my eth0 connection. – Lloyd Smart Mar 14 '13 at 01:31
  • This worked like a charm for config files from CitizenVPN – slott Nov 05 '16 at 09:57
6

ip route add to $network/$mask via $gateway

Jeff Ferland
  • 20,239
  • 2
  • 61
  • 85
0
route 10.99.77.55 255.255.255.255 net_gateway

I used this code line in ovpn config so it worked. Now I want to bypass an IP range instead of single IP, How can I do it?

something like that:

route 10.99.77.55/22 255.255.255.255 net_gateway
M Kh
  • 1
  • If you have a new question, please ask it by clicking the [Ask Question](https://serverfault.com/questions/ask) button. Include a link to this question if it helps provide context. - [From Review](/review/late-answers/509614) – bjoster Jan 24 '22 at 13:38