Solved Running two VPN connections at startup

I searched for startup options of OpenVPN in rc.conf. But I have two connections of OpenVPN. The first is for home users. The second is my static VPN to another office. Now I start my second VPN with /usr/local/sbin/openvpn /user/local/etc/openvpn/conf/otheroffice.conf &. But this is not the proper way and will not completely start up both OpenVPN connections.

How do I set up two VPN connections so these are working after starting up the server?
 
Hi,

/usr/local/etc/rc.d/openvpn:
Code:
[...]
# This script supports running multiple instances of openvpn.
# To run additional instances link this script to something like
# % ln -s openvpn openvpn_foo
# and define additional openvpn_foo_* variables in one of
# /etc/rc.conf, /etc/rc.conf.local or /etc/rc.conf.d/openvpn_foo
#
# Below NAME should be substituted with the name of this script. By default
# it is openvpn, so read as openvpn_enable. If you linked the script to
# openvpn_foo, then read as openvpn_foo_enable etc.
#
# The following variables are supported (defaults are shown).
# You can place them in any of
# /etc/rc.conf, /etc/rc.conf.local or /etc/rc.conf.d/NAME
#
# NAME_enable="NO"      # set to YES to enable openvpn
# NAME_if=              # driver(s) to load, set to "tun", "tap" or "tun tap"
#                       # it is OK to specify the if_ prefix.
#
# # optional:
# NAME_flags=                           # additional command line arguments
# NAME_configfile="/usr/local/etc/openvpn/NAME.conf"    # --config file
# NAME_dir="/usr/local/etc/openvpn"     # --cd directory
#
# You also need to set NAME_configfile and NAME_dir, if the configuration
# file and directory where keys and certificates reside differ from the above
# settings.
[...]

Example in rc.conf:
Code:
openvpn_enable="YES"
openvpn_client1_client_enable="YES"
openvpn_client1_client_configfile="/path/to/client1.conf"
openvpn_client2_client_enable="YES"
openvpn_client2_client_configfile="/path/to/client2.conf"

In /usr/local/etc/rc.d:
Code:
openvpn_client1@ -> /usr/local/etc/rc.d/openvpn
openvpn_client2@ -> /usr/local/etc/rc.d/openvpn
 
Can you please explain it more da1?
I did these steps and got stuck in the last step where you mention to put command in /usr/local/etc/rc.d.
My FreeBSD didn't recognize this command.

Do I did it wrong?
Or can you give me a full tutorial? I'm wondering whether I missed something.

Thank you.
 
In /usr/local/etc/rc.d:
Code:
openvpn_client1@ -> /usr/local/etc/rc.d/openvpn
openvpn_client2@ -> /usr/local/etc/rc.d/openvpn

This would be the result of running the following commands (as root):
Code:
cd /usr/local/etc/rc.d
ln -s /usr/local/etc/rc.d/openvpn /usr/local/etc/rc.d/openvpn_client1
ln -s /usr/local/etc/rc.d/openvpn /usr/local/etc/rc.d/openvpn_client2
ls -l openvpn_client*
 
Thanks for your answer
Yes, I did a little miss and its now working

Now I have a new problem here
When I start the OpenVPN as usual with /usr/local/etc/rc.d/openvpn start it shows the error :
Code:
/etc/rc.conf: openvpn_client1_client_enable=YES: not found
/etc/rc.conf: openvpn_client1_client_configfile=/usr/local/etc/openvpn/server1.conf: not found
/etc/rc.conf: openvpn_client2_client_enable=YES: not found
/etc/rc.conf: openvpn_client2_client_configfile=/usr/local/etc/openvpn/server2.conf: not found
Starting openvpn.
My /etc/rc.conf:
Code:
openvpn_enable="YES"
#openvpn_configfile="/usr/local/etc/openvpn/openvpn.conf"
openvpn_client1_client_enable="YES"
openvpn_client1_client_configfile="/usr/local/etc/openvpn/server1.conf
openvpn_client2_client_enable="YES"
openvpn_client2_client_configfile="/usr/local/etc/openvpn/server2.conf
I already have server1.conf and server2.conf in that directory.
And I also have tried to change my rc.conf to :
Code:
openvpn_enable="YES"
#openvpn_configfile="/usr/local/etc/openvpn/openvpn.conf"
openvpn_client1_enable="YES"
openvpn_client1_configfile="/usr/local/etc/openvpn/server1.conf
openvpn_client2_enable="YES"
openvpn_client2_configfile="/usr/local/etc/openvpn/server2.conf
But still have the same problem.

Then I tried with /usr/local/etc/rc.d/openvpn_client1 start and still got stuck.

Where did I do wrong again ? Do I need to change some part in /usr/local/etc/rc.d/openvpn manually ?
 
For running the two separate OpenVPN services, use the second set of rc.conf settings you tried but take out the openvpn_enable="YES" line (and the commented-out line, too).

Code:
openvpn_client1_enable="YES"
openvpn_client1_configfile="/usr/local/etc/openvpn/server1.conf
openvpn_client2_enable="YES"
openvpn_client2_configfile="/usr/local/etc/openvpn/server2.conf
Then service openvpn_client1 start and/or service openvpn_client2 start; the plain openvpn service does nothing.
 
Okay. It's working now. I just start over everything.

Actually, I did the same thing. But voila, it's working this time. And yes, I use my last rc.conf.

Thank you for your time gentlemen.
 
Back
Top