# [SOLVED] connecting to two VPN's

## Joseph_sys

I've setup two different "openvpn". Nice instructions at:

https://forums.gentoo.org/viewtopic-p-3895787.html#3895787

How to setup two setup a PC client to connect to two different VPN's both at once or one at a time?

on my client PC I have:

```
drwxr-xr-x 2 root root 4096 Jan 17 02:04 client

-rw-r--r-- 1 root root  378 Feb  5 23:35 client.conf
```

Do I create second set of config files: client2 directory and client2.conf?

But if I do that, starting openvpn.client will try to start both at once, isn't it?Last edited by Joseph_sys on Tue Feb 23, 2010 10:59 pm; edited 1 time in total

----------

## Rexilion

Yes, it will start both at once. I think that is only a problem if the ifconfig parameters overlap. Otherwise it should cause no harm...

----------

## Joseph_sys

 *Rexilion wrote:*   

> Yes, it will start both at once. I think that is only a problem if the ifconfig parameters overlap. Otherwise it should cause no harm...

 

Not it doesn't work I've generated second set of config files but second "tun" device is not starting.

cat client.conf

```
client

dev tun

proto udp

remote 10.0.0.150 9000

resolv-retry infinite

nobind

tun-mtu 1500

tun-mtu-extra 32

mssfix 1200

persist-key

persist-tun

ca "/etc/openvpn/client/ca.crt"

cert "/etc/openvpn/client/syscon9.crt"

key "/etc/openvpn/client/syscon9.key"

tls-auth "/etc/openvpn/client/vpn_my.key" 1

comp-lzo

log        /var/log/openvpn.log

log-append /var/log/openvpn.log

verb 3
```

cat client_clinic.conf

```
client

dev tun

proto udp

remote 10.0.0.150 9050

resolv-retry infinite

nobind

tun-mtu 1500

tun-mtu-extra 32

mssfix 1200

persist-key

persist-tun

ca "/etc/openvpn/client_clinic/ca.crt"

cert "/etc/openvpn/client_clinic/syscon9_clinic.crt"

key "/etc/openvpn/client_clinic/syscon9_clinic.key"

tls-auth "/etc/openvpn/client_clinic/vpn_clinic.key" 1

comp-lzo

log        /var/log/openvpn.log

log-append /var/log/openvpn.log

verb 3
```

I can only start one "tun" interface at the time not both.

----------

## Rexilion

Start the first openvpn and wait for it to complete.

Then start the second openvpn in a terminal (not through the init system) like so:

openvpn --config /etc/openvpn/configfileofsecondvpnconnection.conf

And post the output please.

----------

## Joseph_sys

 *Rexilion wrote:*   

> Start the first openvpn and wait for it to complete.
> 
> Then start the second openvpn in a terminal (not through the init system) like so:
> 
> openvpn --config /etc/openvpn/configfileofsecondvpnconnection.conf
> ...

 

Yes, it worked when I try to start from the command line manually as you indicated above, thank you.

It seems to me the starting script was looking for client.conf file.

I guess it is my lack of understanding init scripts :-/

The first connection is started from the symbolic link 

/etc/init.d/openvpn.client  (it works OK)

When I deleted from /etc/openvpn directory "client.conf" and left only "client_clinic.conf" the init.d script will not start the connection from symbolic link; it is looking for "client.conf" file.

Creating the second symbolic link starting script:

```
ln -sf /etc/init.d/openvpn /etc/init.d/openvpn.client_clinic
```

 solved the problem.

Both connections start from init symbolic link; though I don't understand how. 

Symbolic link is just a pointer to the original script.  It seems to me the name of the symbolic link init script points to the second config.file (in my case "client_clinic.conf")

----------

## Mad Merlin

You should create two symlinks to the openvpn init script, one named openvpn.client and the other named openvpn.client2. Then, in your /etc/openvpn directory, create a client.conf and a client2.conf. Now, /etc/init.d/openvpn.client controls the client.conf VPN, and /etc/init.d/openvpn.client2 controls the client2.conf VPN. The reason this works is that the init script knows how it was called, and can react accordingly, even though they're all symlinks back to the same script.

FWIW, the same thing happens with multiple network adapters, (net.eth0 and net.eth1 are both symlinks to net.lo).

----------

