Install the VPN Server and the VPN Client on UbuntuVPS

Source: Internet
Author: User
Tags ubuntu vps
This article combines two articles and has personally experienced it. It is very good. We have successfully established a VPN dedicated channel! The whole process is actually very simple. First, repeat the LNMP army brother's method and establish a VPN Server. 1. The full text of Server Installation explains how to create a VPN service on VPS, and how to install and link the client on windows, I have also successfully implemented the VPN service for connecting windows to Ubuntu. Here I will only talk about it in Ubuntu

This article combines two articles and has personally experienced it. It is very good. We have successfully established a VPN dedicated channel! The whole process is actually very simple. First, repeat the LNMP army brother's method and establish a VPN Server.

1. Install the server

The full text introduces how to create a VPN service on VPS, and how to install and link the client on windows system. According to June's method, I have also successfully implemented a VPN service linked to Ubuntu on windows, here I will only talk about installing the VPN Server on Ubuntu VPS. There are some minor changes based on your own experience:

1. install apt-get install openvpn udev lzop2 and use easy-rsa to generate a server certificate.

Copy the configuration file required by OpenVPN to/etc/openvpn:

Cp-r/usr/share/doc/openvpn/examples/easy-rsa // etc/openvpn/

Production CA certificate:

Cd/etc/openvpn/easy-rsa/2.0
Source vars
./Clean-all
./Build-ca

./When building-ca, you will be prompted to enter some information. You can press enter to press the default information.

Generate the server certificate and key. The server name can be customized:

./Build-key-server

In this step, you will be prompted to enter some information. Press enter to press the default information, and the prompt "Sign the certificate?" is displayed? [Y/n]: Enter y at the time of installation. (here the prompt is different during installation. If [y/n] is displayed, enter Y, do not check whether the content above is consistent). 1 out of 1 certificate requests certified, commit? [Y/n] is also input y.

Generate client certificates and keys. The client name can be customized. Note that the previous./build-key-server and./build-key client names cannot be the same:

./Build-key client

Press enter to press the default information, and the message "Sign the certificate?" is displayed? [Y/n]: Enter y at the time of installation. (here, the prompt is different during installation. If [y/n] is displayed, enter Y, do not check whether the content above is consistent). 1 out of 1 certificate requests certified, commit? [Y/n] is also input y

To generate other clients, run:./build-key. The name of the client you want to add will have name: item settings. Enter the user name directly, as long as it is different from the server.

The generated certificates and keys are stored under/etc/openvpn/easy-rsa/2.0/keys.

Generate the Diffie Hellman parameter:

./Build-dh3, configure OpenVPN Service

Edit the/etc/openvpn/server. conf file. If no file can be created, add the following content:

IP address of the local server (which must be modified here. Other IP addresses can be left unchanged)
Port 8080 # port, which must be consistent with the client Configuration
Proto udp # the Protocol must be consistent with the client Configuration
Dev tun # You can also select the tap mode.

Ca/etc/openvpn/easy-rsa/2.0/keys/ca. crt
Cert/etc/openvpn/easy-rsa/2.0/keys/server. crt
Key/etc/openvpn/easy-rsa/2.0/keys/server. key
Dh/etc/openvpn/easy-rsa/2.0/keys/dh1024.pem
Ifconfig-pool-persist ipp.txt

Server 10.168.1.0 255.255.255.0 # IP address segment allocated to the customer. Be sure not to conflict with the client network segment!

Push "redirect-gateway"
Push "dhcp-option DNS 8.8.8.8 ″
Push "dhcp-option DNS 8.8.4.4 ″

Client-to-client
; Duplicate-cn
Keepalive 20 60

Comp-lzo
Max-clients 50

Persist-key
Persist-tun

Status openvpn-status.log
Log-append openvpn. log

Verb 3
Mute 20

Modify the Server IP address according to the preceding instructions. You can delete the comment when copying the Server IP address to VPS.

Install iptables

Apt-get install iptables # skip this step if you have already installed iptables.

Set IP Forwarding

Iptables-t nat-a postrouting-s 10.168.0.0/16-o eth0-j MASQUERADE
Iptables-save>/etc/iptables. rules

The above eth0 should be replaced with your Nic ID. You can view it through ifconfig.

Create an iptables file in the/etc/network/if-up.d/directory with the following content:

#! /Bin/sh
Iptables-restore </etc/iptables. rules

Add the execution permission to the script:

Chmod + x/etc/NET/if-up.d/iptables

Modify/etc/sysctl. the conf content is as follows: There are two items not listed above. You can simply add them directly. Other projects mainly remove comments. In fact, you can directly copy the following content to the configuration file:

Net. ipv4.ip _ forward = 1
Net. ipv4.conf. all. send_redirects = 0
Net. ipv4.conf. default. send_redirects = 0
Net. ipv4.conf. all. accept_redirects = 0
Net. ipv4.conf. default. accept_redirects = 0

Reload/etc/sysctl. conf to make it take effect. Execute the following command:

Sysctl-p

Restart OpenVPN and network:

/Etc/init. d/openvpn restart
/Etc/init. d/networking restart

Construction and configuration of PPTP and OpenVPN in Linux based on CentOS5

Use PPTP to build a VPN http://www.linuxidc.com/Linux/2012-06/61923.htm for CentOS Nic

PPTPD http://www.linuxidc.com/Linux/2012-01/51849.htm for configuration of RHEL5.4 VPN Service

Problem http://www.linuxidc.com/Linux/2011-01/31746.htm for configuring NAT forwarding in PPTPd on Ubuntu VPS

Install pptp vpn http://www.linuxidc.com/Linux/2011-06/37430.htm under CentOS

Linux VPN (PPTPD) + Windows AD unified authentication http://www.linuxidc.com/Linux/2014-03/97779.htm

Ii. Client installation and configuration:

Directly forward the message. The original image is displayed on the Gnome 2 page. Here, Unity 7 is used and the system version is Ubuntu 14.04:

Install OpenVPN for NetworkManager

NetworkManager, a network utility, enables you to enable or disable VPN connections. It is installed in Ubuntu by default. You can find it in the notification area on your screen and stay close to the system clock.

Next, find the OpenVPN extension that can work with NetworkManager from the Ubuntu Software Center.

  1. In the Application menu at the top left of the screen, open the Ubuntu Software Center)
  2. The Ubuntu Software Center allows you to search, install, and uninstall Software. Click the search box in the upper-right corner of the window.
  3. Enter "network-manager-openvpn-gnome" in the search box (the NetworkManager extension of OpenVPN can be started ). The package contains all the files you need to successfully establish a VPN connection, including the OpenVPN client. Click Install ).

For more details, refer to the highlights on the next page.: Http://www.linuxidc.com/Linux/2014-10/108182p2.htm

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.