D
D
Dmitry Vapelnik2015-01-27 19:32:27
linux
Dmitry Vapelnik, 2015-01-27 19:32:27

How to allow access to some IPs past OpenVPN?

I'm using an OpenVPN connection and I want to be able to access some IPs (local and non-local) past the VPN connection.
OS: Ubuntu 14.04
Package: network-manager-openvpn-gnome
Is there any way to implement this?
It is assumed that there are three VPN connections to the same server, differing only in routing:
1. General - everything goes through the VPN
2. Home - everything goes through the VPN, except the local network
3. Work - everything goes through the VPN, except the local one network and some external IP
It is highly desirable that these routes themselves be created and deleted automatically when connecting and disconnecting to OpenVPN.
Perhaps there is a way to specify scripts to be run during VPN connection and disconnection. Then it would be possible to write adding/removing routes by hand.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2015-01-27
@rostel

in client config

up "/etc/openvpn/route-bee.sh up"
down "/etc/openvpn/route-bee.sh down"

$ cat /etc/openvpn/route-bee.sh
#!/bin/bash

[ -x /sbin/ip ] || exit 0

case $1 in

up)
    /sbin/ip route add 10.10.1.0/24 via 10.10.1.2 dev tun1 table beeline
    /sbin/ip route add 10.10.1.0/24 via 10.10.1.2 dev tun1 table soyuz
    ;;
down)
    /sbin/ip route del 10.10.1.0/24 via 10.10.1.2 dev tun1 table beeline
    /sbin/ip route del 10.10.1.0/24 via 10.10.1.2 dev tun1 table soyuz
    ;;
esac

enter the required routes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question