web123456

Install OpenVPN Client

Install OpenVPN Client

yum -y install epel-release
yum -y install openvpn

Configure the client

Note: When opening openvpn is enabled, the SSH that was originally connected will be disconnected, and the server will allocate you a LAN IP (specific IP segment and server configuration related). You can use this IP to connect.

How to view the ip of the LAN: There will be a status item in the server configuration, followed by a file name used to record the connection status. You can find it by viewing this file.

Method 1: Command line method (not recommended)

​ First, you need to upload the .ovpn file provided by the server to the server, and the location is free.

openvpn \
--daemon \
--config  \
--log-append  \
--auth-nocache

Command parameter description:

--daemon         # Backend run
--cd           # Configuration file directory path
--config          # Configuration file name
--auth-user-pass       # Specify account password file
--log-append       # Log file.
--auth-nocache      # Do not cache the -askpass or -auth-user-pass password.

​ Just stop killing this method

Method 2: Management through Systemctl

​ This method requires uploading .ovpn to /etc/openvpn/client, and changing the suffix .ovpn to .conf

​ If the configuration file requires us to enter the password manually, we need to fix the password in the form of a configuration file, otherwise the automatic startup will fail. Create a new file in /etc/openvpn/client/, and enter:

username
password

Some OpenVPN server tools only generate passwords (such as Pritunl), where username can enter one at will and then add the password on the following line.

Then go to the configuration file and findauth-user-pass. By default, this configuration entry is empty after it, so we modify it to:

auth-user-pass /etc/openvpn/client/

Suppose we change the configuration file to

Next we use systemctl to manage

#Start up
systemctl enable openvpn-client@test
#start up
systemctl start openvpn-client@test
#stop
systemctl stop openvpn-client@test

verify:

Method 1: View the log:

systemctl status openvpn-client@test

The following sentence appears, it is basically successful

10moon11 15:06:26  openvpn[4680]: Initialization Sequence Completed

Method 2: Verify the public IP

curl 

Check whether your public IP has become the IP of the openvpn server

Replenish:

Available on the serveropenvpn-install, This script is built quickly. It supports Ubuntu, Debian, CentOS and Fedora.