OpenVPN client configuration tutorial in Ubuntu

Source: Internet
Author: User
Generally, Linux servers that provide Web Services seldom need to connect to OpenVPN, but personal Linux computers often need to connect to OpenVPN. For example, if you use Linux as the development environment, you need to connect to the company's OpenVPN. This document uses Ubuntu as an example to describe how to connect to the remote OpenVPN service on a terminal. To install OpenVPN, you must first install the OpenVPN client. Generally, you can use apt-get directly.

Generally, Linux servers that provide Web Services seldom need to connect to OpenVPN, but personal Linux computers often need to connect to OpenVPN. For example, if you use Linux as the development environment, you need to connect to the company's OpenVPN.

This document uses Ubuntu as an example to describe how to connect to the remote OpenVPN service on a terminal.

Install OpenVPN

First, install the OpenVPN client. Generally, you can use apt-get directly. Run the following command to install the SDK:

1 [root@www ~]# apt-get install openvpn

Wait a moment to automatically install the software package required by openvpn. After the installation is complete, it should appear

/Etc/openvpn/

Folder.

Configure OpenVPN

As a client, OpenVPN does not have a specific configuration file, but a configuration file is provided by the server provider. OpenVPN provides two authentication methods: User Name/password-based authentication and SSL certificate authentication. The user name/password authentication method cannot (or is difficult) restrict an account to connect to multiple clients at the same time. Using a certificate, you can ensure that only one client can be connected to the same certificate at the same time. Of course, these are determined by the server and do not need to be selected by the client.

Decompress the configuration file sent to you by the OpenVPN server provider and copy all the files to/etc/openvpn.

These files contain at least one. ovpn file and need to be manually created, for example, client. ovpn. If the server requires certificate authentication, there should be three other certificate files.

Understand the OpenVPN configuration format. The following is an. ovpn configuration example:

Client
Dev tap
Proto tcp-client
Remote Host 192.168.135.75 1194
Resolv-retry infinite
Nobind
Mute-replay-warnings
Redirect-gateway
Ca/etc/openvpn/ca. crt
Cert/etc/openvpn/client. crt
Key/etc/openvpn/client. key
Comp-lzo
Verb 4

Generally, you may need to modify the red content. Change the red content to the actual location of the three files. Save the settings.

Connect to OpenVPN

After the. ovpn file is configured, run

Openvpn/etc/openvpn/client. ovpn

You can connect to the server (note the permissions of the corresponding files in this directory ). Note that the above parameters should be replaced by the actual location of your configuration file.

At this time, the consumer will display a lot of connection logs. If the connection fails, you can use these logs to locate the error. To disconnect, you only need to force the termination through Ctrl + C.

The preceding command is not convenient in practice because it occupies an independent terminal. After the test is successful, run the following command to connect to OpenVPN in the background:

Openvpn/etc/openvpn/client. ovpn>/dev/null &

It is commendable that openvpn is very intelligent. It will automatically reconnect when the connection is interrupted, the server cannot be connected, or the network is disconnected. Therefore, if you want to automatically connect to OpenVPN upon startup, or the VPN is always online, you can add the above command line

/Etc/rc. local

. Note: The & symbol at the end of the command cannot be omitted; otherwise, the normal startup of the system may be blocked.

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.