VPN network built on VPS in Linux system

Source: Internet
Author: User
Tags vars vps iptables

1, the VPS (server) on the operation as follows

The code is as follows Copy Code

Mkdir-p/root/software/vpn
Cd/root/software/vpn

# Download Packages
wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.05.tar.gz
wget http://swupdate.openvpn.net/community/releases/openvpn-2.2.1.tar.gz

# Decompression and Installation
Tar zxvf lzo-2.05.tar.gz
cd/root/software/vpn/lzo-2.05
./configure
Make
Make install

Tar zxvf openvpn-2.2.1.tar.gz
cd/root/software/vpn/openvpn-2.2.1
./configure
Make
Make install

# Server-side settings
Cp/root/software/vpn/openvpn-2.2.1/easy-rsa/2.0-r/etc/openvpn
Cd/etc/openvpn

Vim VARs
# Change the contents of VARs to
Export key_country= "CN"
Export key_province= "SH"
Export key_city= "Shanghai"
Export key_org= "Studyday.net"
Export key_email= "Kuco@studyday.net"
Export Key_email=kuco@studyday.net
Export Key_cn=kuco
Export Key_name=kuco
Export Key_ou=kuco
Export Pkcs11_module_path=kuco
Export pkcs11_pin=20110804
source./vars

./clean-all

./BUILD-CA # All the way to the carriage

./build-key-server server # All the way to the return, the last to press two times Y

./build-key client # All the way to the return, the last to press two times Y

./BUILD-DH

cp/root/software/vpn/openvpn-2.2.1/sample-config-files/server.conf/etc/openvpn/

Vim/etc/openvpn/server.conf
#将 server.conf Content revision to
Local 184.82.33.161
Port 1194
Proto UDP

Dev Tun

Ca/etc/openvpn/keys/ca.crt
Cert/etc/openvpn/keys/server.crt
Key/etc/openvpn/keys/server.key
Dh/etc/openvpn/keys/dh1024.pem

Server 10.8.0.0 255.255.255.0

Client-to-client
KeepAlive 10 120

Comp-lzo

Persist-key
Persist-tun
Status/etc/openvpn/keys/openvpn-status.log
Verb 4

Push "Dhcp-option DNS 10.8.0.1"
Push "Dhcp-option DNS 8.8.8.8"
Push "Dhcp-option DNS 8.8.4.4"

Ifconfig-pool-persist/etc/openvpn/keys/ipp.txt
# Modify Iptables
Iptables-t nat-a postrouting-s 10.8.0.0/24-o venet0-j Masquerade
/etc/init.d/iptables Save
/etc/init.d/iptables restart

# Start VPN
/usr/local/sbin/openvpn--config/etc/openvpn/server.conf--daemon
2, the Windows (client) operation is as follows

# download OpenVPN and install

Http://swupdate.openvpn.org/community/releases/openvpn-2.2.1-install.exe

# Suppose the installation path is
D:\Program Files\openvpn

# Download the certified files generated on the server to the D:\Program files\openvpn\config\ directory
/etc/openvpn/keys/ca.crt
/etc/openvpn/keys/client.crt
/etc/openvpn/keys/client.key

# copy D:\Program Files\openvpn\sample-config\client.ovpn to D:\Program files\openvpn\config\

# Modify D:\Program Files\openvpn\config\client.ovpn
# Change the contents of Client.ovpn to
Client

Dev Tun
Proto UDP

Remote 184.82.33.161 1194

Persist-key
Persist-tun
CA ca.crt
Cert CLIENT.CRT
Key Client.key
Ns-cert-type Server
Comp-lzo
Verb 3

Redirect-gateway DEF1
Route-method exe
Route-delay 2

Finally attention to a little thing: our article above the conversion in the English state of the \ Oh, otherwise will not be executed, this is because the server configuration cause I can not release lowercase \ OH

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.