OpenVPN configuration in Linux

Source: Internet
Author: User
Tags install openssl openvpn gui
OpenVPN: OpenVPN can run on most common system platforms. it is a VPN solution based on SSL/TLS. OpenVPN can implement link between Layer 2 and Layer 3 based on the TAP/TUN virtual device driver, provide industry-level encryption function based on SSL/TLS, and implement most common VPN solutions... "/> <scripttype =" text/plain Crip OpenVPN introduction:
 
OpenVPN can run on most common system platforms and is a VPN solution based on SSL/TLS. OpenVPN can implement layer-2 and Layer-3 links based on the TAP/TUN virtual device driver, and provides industry-level encryption based on SSL/TLS, and implements all the features of most common VPN solutions. However, there are not many VPN Hardware vendors that integrate OpenVPN.


1. download the software package # wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.04.tar.gz# Wget http://openvpn.net/release/openvpn-2.1_rc22.tar.gz# Yum install openssl-devel 2. unzip and install # tar xvf lzo-2.04.tar.gz # cd lzo-2.04 #. /configure # make & make install # cd .. /# tar xvf openvpn-2.1_rc22.tar.gz # cd openvpn-2.1_rc22 #. /configure # make & make install # cd .. /3. server side settings: 1. use easy-rsa to generate server certificate client certificate # cp openvpn-2.1_rc22/easy-rsa/2.0-r/etc/openvpn/# cd/etc/openvpn/2.0/edit required parameters and then call # vim varsexport D = "'pwd'" export KEY_CONFIG = "$ D/openssl. cnf "export KEY _ DIR = "$ D/keys" export KEY_COUNTRY = "CN" export KEY_PROVINCE = "SH" export KEY_CITY = "PD" export KEY_ORG = "zyfmaster" export KEY_EMAIL = "905407204@qq.com" # source vars # can also be left empty, directly execute the following command. the following command can be run during the first installation. do not run the command after adding a client. this command will clear all generated certificate keys. #. /Clean-all generate the server-side ca certificate #. /build-caGenerating a 1024 bit RSA private key ............ ++ .................. ++ writing new private key to 'ca. key' ----- You are about to be asked to enter information that will be inreceivatedinto your certificate request. what you are about to enter is what is called a Distinguished Name or a DN. there are quite a few fields but you can leave some blankFor some fiel Ds there will be a default value, If you enter '. ', the field will be left blank. ----- Country Name (2 letter code) [CN]: State or Province Name (full name) [SH]: Locality Name (eg, city) [PD]: Organization Name (eg, company) [zyfmaster]: Organizational Unit Name (eg, section) []: zyfmasterCommon Name (eg, your name or your server's hostname) [zyfmaster CA]: serverName []: email Address [905407204@qq.com]: Generate the server key. the server-name is the server name, which can be customized. #. /Build-key-server Generating a 1024 bit RSA private key .......................... ............. ++ ....... ++ writing new private key to 'server. key' ----- You are about to be asked to enter information that will be inreceivatedinto your certificate request. what you are about to enter is what is called a Distinguished Name or a DN. there are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '. ', the field will be left blank. ----- Country Name (2 letter code) [CN]: State or Province Name (full name) [SH]: Locality Name (eg, city) [PD]: Organization Name (eg, company) [zyfmaster]: Organizational Unit Name (eg, section) []: zyfmasterCommon Name (eg, your name or your server's hostname) [server]: serverName []: email Address [905407204 @ q Q.com]: Please enter the following 'Extra 'attributesto be sent with your certificate requestA challenge password []: abcd1234An optional company name []: zyfmasterUsing configuration from/etc/openvpn/2.0/openssl. cnfCheck that the request matches the signatureSignature okThe Subject's Distinguished Name is as followscountryName: PRINTABLE: 'cn' stateOrProvinceName: PRINTABLE: 'sh' localityName: PRINTAB LE: 'PD 'organizationname: PRINTABLE: 'zyfmaster' organizationalUnitName: PRINTABLE: 'zyfmaster' commonName: PRINTABLE: 'server' emailAddress: IA5STRING: '1970 @ qq.com 'Certificate is to be certified until Dec 2 04:14:34 905407204 GMT (2022 days) Sign the certificate? [Y/n]: y 1 out of 1 certificate requests certified, commit? [Y/n] yWrite out database with 1 new entriesData Base Updated generate client key #. /build-key client1Generating a 1024 bit RSA private key ............ ++ .................................. ...................... ++ writing new private key to 'client1. key' ----- You are about to be asked to enter information that will be inreceivatedinto your certificate request. what you are about to enter is what is called A Distinguished Name or a DN. there are quite a few fields but you can leave some blankFor some fields there will be a default value, If you enter '. ', the field will be left blank. ----- Country Name (2 letter code) [CN]: State or Province Name (full name) [SH]: Locality Name (eg, city) [PD]: Organization Name (eg, company) [zyfmaster]: Organizational Unit Name (eg, section) []: zyfmasterCommon Name (eg, Your name or your server's hostname) [client1]: client1 # Important: certificates generated by different clients must have different names. name []: Email Address [905407204@qq.com]: Please enter the following 'Extra 'attributesto be sent with your certificate requestA challenge password []: abcd1234An optional company name []: zyfmasterUsing configuration from/etc/openvpn/2.0/openssl. cnfCheck that the request matches the signatureSignature okThe Subj Ect's Distinguished Name is as followscountryName: PRINTABLE: 'cn' region: PRINTABLE: 'sh' localityName: PRINTABLE: 'PD 'organizationname: PRINTABLE: 'zyfmaster' organizationalUnitName: PRINTABLE: 'zyfmaster' commonName: PRINTABLE: 'client1' emailAddress: IA5STRING: '2017 @ qq.com 'Certificate is to be certified until Dec 2 04:15:50 905407204 GMT (2022 days) Sign the certificate? [Y/n]: y 1 out of 1 certificate requests certified, commit? [Y/n] yWrite out database with 1 new entriesData Base Updated and so on to create other client keys #. /build-key client2 #. /build-key client3 note that when entering the Common Name (eg, your name or your server's hostname) []: input, each certificate must have a different Name. 5. generate the Diffie Hellman parameter #. /build-dh 6. package and download all files in keys to a local device (you can use winscp, http, ftp, etc ......) # Tar zcvf yskeys.tar.gz keys/* 7. create the server configuration file # mkdir/etc/openvpn/2.0/conf # cp/root/openvpn/openvpn-2.1_rc22/sample-config-files/server. conf/etc/openvpn/2.0/conf/# vim/etc/openvpn/2.0/conf/server. confport 1194 proto udp dev tun ca/etc/openvpn/2.0/keys/ca. crtcert/etc/openvpn/2.0/keys/server. crtkey/etc/openvpn/2.0/keys/server. key # This file shoshould be kept secret dh/etc/openvpn/2.0/keys/login server 10.8.0.0 255.255.255.0push "route 10.8.0.0 255.255.255.0" push "route 0.0.0.0 0.0.0.0" ifconfig-pool-persist ipp.txt push "redirect-gateway def1 bypass-dhcp" push "dhcp-option DNS 8.8.8.8" push "dhcp-option DNS 8.8.4.4" client-to-client keepalive 10 120 comp-lzo user nobodygroup nobody persist -keypersist-tun status openvpn-status.log log openvpn. logverb 3 4. enable server routing 1. enable the route forwarding function of CentOS 5 # vim/etc/sysctl. conf: net. ipv4.ip _ forward = 1 5. enable sysctl. the conf configuration file takes effect and adds iptables forwarding rules: # sysctl-p # iptables-t nat-a postrouting-o eth0-s 10.8.0.0/24-j MASQUERADE #/etc/init. d/iptables save 6. start openvpn and add random startup vi/etc/rc. add this line at the end:/usr/local/sbin/openvpn -- config/etc/openvpn/2.0/conf/server. conf & 7. OpenVPN GUI For Windows client installation process 1. download openvpn-2.1_rc15-install.exe (this version integrates OpenVPN GUI) official: http://openvpn.net/release/openvpn-2.1_rc15-install.exe2 . Install OpenVPN GUI3. configure openvpn Guito unzip the following certificate files from yskeys.tar.gz in step 6 to the ca under the OpenVPN GUI installation path OpenVPNconfig folder. crchloroform. keyclient1.crtclient1. csrclient1.key 4. modify client. ovpn install OpenVPN GUI in the path OpenVPNsample-config. copy the ovpn file to your OpenVPN GUI installation path OpenVPNconfig folder and open the client in Notepad. ovpn # locate remote my-server-1 1194 and change my-server-1 to your IP address remote. b. c. d (your own VPN address) 5. double-click client. ovpn can start openvpn, or start VP through OpenVPN GUI control. N. view the IP address obtained by the client: after the connection is successful, go to www.ip138.com to check what the internet ip address is. if it is the Internet ip address of the CentOS system, the test is successful ~
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.