開機啓動OpenVPN(服務方式啓動OpenVPN)

https://openvpn.net      // 已被牆微笑


Configuring OpenVPN to run automatically on system startup


The lack of standards in this area means that most OSes have a different way of configuring daemons/services for autostart on boot. 
The best way to have this functionality configured by default is to install OpenVPN as a package, 
such as via RPM on Linux or using the Windows installer.


Linux


If you install OpenVPN via an RPM or DEB package on Linux, 
the installer will set up an initscript. 
When executed, the initscript will scan for .conf configuration files in /etc/openvpn, 
and if found, will start up a separate OpenVPN daemon for each file.


Windows


The Windows installer will set up a Service Wrapper, 
but leave it turned off by default. 
To activate it, go to Control Panel / Administrative Tools / Services, 
select the OpenVPN service, right-click on properties, 
and set the Startup Type to Automatic. 
This will configure the service for automatic start on the next reboot.


When started, the OpenVPN Service Wrapper will scan the \Program Files\OpenVPN\config folder for .ovpn configuration files, 
starting a separate OpenVPN process on each file.


-----------------------------------------------------


Running OpenVPN from a console window


First, create a config file. A sample is provided in \Program Files\OpenVPN\config\sample.ovpn.txt
Edit this file and save to a .ovpn extension.
Now, run OpenVPN by right clicking on the .ovpn filename and selecting "Start OpenVPN on this config file".


You can also run from a command prompt window:


    openvpn --config sample.ovpn
    
Running OpenVPN as a Windows Service
When OpenVPN runs as a service it will start a separate OpenVPN process for each configuration file 
it finds in the \Program Files\OpenVPN\config directory and will output a logfile of the same name to the \Program Files\OpenVPN\log directory.


When installed as a service, OpenVPN will default to manual start mode. 
You can go to the "Services" control panel in Control Panel -> Administrative Tools to start the service or to set it to Automatic Start mode.


A sample config file has been provided in \Program Files\OpenVPN\config\sample.ovpn.txt which can be adapted to your needs.


Service Notes:


When you install OpenVPN as a service, 
you are actually installing openvpnserv.exe which is a service wrapper for OpenVPN, 
i.e. it reads the config file directory and starts up a separate OpenVPN process for each config file. 
openvpnserv.exe performs the same function under windows as the /etc/init.d/openvpn startup script does under linux.
When you stop the OpenVPN service, it will send a terminate signal to all OpenVPN processes which were started by it.
If the OpenVPN service wrapper (openvpnserv.exe) encounters fatal errors, 
it will write them to the windows event log, 
which can be viewed in Control Panel -> Administrative Tools -> Event Viewer -> Application Log.
If the OpenVPN processes themselves encounter errors, 
they will write them to their respective log files in the log file directory.
There is a one-to-one correspondence between an OpenVPN process, 
an OpenVPN config file, an OpenVPN log file, 
and a TAP-Win32 adapter which represents an endpoint of a VPN tunnel.
OpenVPN tunnels are point-to-point in their simplest form, 
but can be made point-to-multi-point through the use of bridging or routing (see below).
Multiple OpenVPN processes can run concurrently, each on a different TAP-Windows adapter.
openvpn.exe gets all configuration information from its config file, not from the registry.
The openvpnserv.exe program (the service wrapper) gets several string parameters from the registry which can be modified by the user. 
If you change any of these parameters, you should be able to upgrade OpenVPN to a new version without the installer overwriting your changes:
HKEY_LOCAL_MACHINE\SOFTWARE\OpenVPN


config_dir
configuration file directory to scan, defaults to "\Program Files\OpenVPN\config"


config_ext
file extension on configuration files, defaults to "ovpn"


exe_path
path to openvpn.exe, defaults to "\Program Files\OpenVPN\bin\openvpn.exe"


log_dir
log file directory, defaults to "\Program Files\OpenVPN\log"


log_append
if set to "1", multiple instantiations of an OpenVPN process will append onto the same log file, if set to "0" (default), each new instantiation will truncate the previous log file


priority
the windows priority class for each instantiated OpenVPN process, can be one of:
"IDLE_PRIORITY_CLASS"
"BELOW_NORMAL_PRIORITY_CLASS"
"NORMAL_PRIORITY_CLASS" (default)
"ABOVE_NORMAL_PRIORITY_CLASS"
"HIGH_PRIORITY_CLASS"



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章