国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > CentOS > 正文

CentOS6.5/7.0 上 OpenVPN的安裝

2024-06-28 16:00:27
字體:
來源:轉載
供稿:網友

CentOS 上 OpenVPN的安裝:

一、安裝準備

?

1、安裝openssl、gcc、libpam

#yum -y install openssl-devel openssl

#yum -y install gcc gcc-c++

#yum -y install pam-devel.x86_64

如遇Segmentation Fault,在/usr/local/lib下,刪除鏈接libz.so和libz.so.1

#rm -f libz.so

#rm -f libz.so.1

安裝完之后恢復這兩個鏈接即可

#ln -s libz.so.1.2.7 libz.so.1

#ln -s libz.so.1 libz.so

二、OpenVPN服務端安裝過程

下載lzo,下載鏈接為http://www.oberhumer.com/opensource/lzo/#download,下載完之后復制到/var/tmp目錄下

1、lzo的安裝

#cd /var/tmp    //安裝目錄

#gunzip zxvf lzo-2.04.tar.gz    //解壓

#tar zxvf lzo-2.04.tar    //解壓

#cd lzo-2.04

#./configure    

#make

#make install   #編譯與安裝

2、openvpn下載與安裝

下載openvpn,下載鏈接為https://openvpn.net/index.php/open-source/downloads.html,下載完之后復制到/var/tmp目錄下

#cd /var/tmp

#gunzip xvf openvpn-2.3.10.tar.gz

#tar xvf openvpn-2.3.10.tar

#./configure

#make

#make install

“lzo enabled but missing” -> lzo configure改為 “./configure --PRefix=/usr/local/”##CentOS 7 會遇到這個問題

“libpam required but missting” ->安裝libpam“yum -y install pam-devel.x86_64”##CentOS 7 會遇到這個問題

安裝好了檢查一下openvpn版本

#openvpn --version

3、easy-sea安裝

下載openvpn,下載鏈接為https://community.openvpn.net/openvpn/wiki/GettingEasyRsa,下載完之后復制到/var/tmp目錄下

#cd /var/tmp

#gunzip xvf easy-rsa-2.2.0_master.tar.gz

#tar xvf easy-rsa-2.2.0_master.tar

#./configure

#make

#make install

安裝路徑

/usr/local/share/easy-esa/

三、制作證書

復制源文件至目標路徑

#mkdir /etc/openvpn

#cp -rf /usr/local/share/easy-rsa /etc/openvpn/

0、配置vars

#vi /etc/openvpn/easy-rsa/vars

export KEY_SIZE=2048      //DH證書的長度設為2048,缺省為1024

export KEY_COUNTRY="CN"

export KEY_PROVINCE=“SH”

export KEY_CITY=“Shanghai”

export KEY_ORG=“jhrdc”

export KEY_EMAIL=“admin@jh.cn”

export KEY_OU=“jhrdc“

export KEY_NAME=jhrdc       //特別重要,“jhrdc”根據情況自己設定

#cd /etc/openvpn/easy-rsa

#source vars  //執行腳本生成證書時,需要設置一些環境變量

#./clean-all    //制作客戶端證書時,不需要執行該腳本

1、生成根證書-CA證書,CA證書同時需要部署在服務器和客戶端上

#./build-ca

#cp keys/ca.crt /etc/openvpn/

2、生成服務器端證書

#./build-key-server jhrdc

#./build-dh

#cp keys/jhrdc.crt keys/jhrdc.key keys/dh2048.pem /etc/openvpn/

3、Client端證書

#./build-key jhrdc    //使用服務器端的CN設定

Generating a 2048 bit RSA private key

................................................................................................+++

....+++

writing new private key to jhrdc.key'

-----

You are about to be asked to enter information that will be incorporated

into 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)[Shanghai]:

Organization Name (eg, company)[JH]:

Organizational Unit Name (eg, section)[jhrdc]:

Common Name (eg, your name or your server's hostname)[jhrdc]:testchannel1   //給不同的客戶端創建證書和私鑰時,可以使用不同名字

Name [jhrdc]:testchannel1

Email Address [admin@jh.cn]:

Please enter the following 'extra' attributes

to be sent with your certificate request

A challenge passWord []:

如遇“TXT_DB error number 2”錯誤,重新touch一個keys/index.txt

生成的客戶端證書位于/etc/openvpn/easy-rsa/keys,分別是jhrdc.crt、jhrdc.csr、jhrdc.key。這幾個證書和前面所生成的服務器端的證書有所不同,僅可為客戶端所使用,請將這幾個證書文件和ca.crt打包,拷貝到客戶端電腦備用。

注意,同一個證書,缺省配置情況下同時只能從一個客戶端登陸

四、配置openvpn服務器

修改服務器配置文件

#cp /var/tmp/openvpn-2.3.10/sample/sample-config-files/server.conf /etc/openvpn/

#vi /etc/openvpn/server.conf

port 1194 //端口設為1194

proto tcp //協議設為tcp

ca ca.crt //ca.crt的路徑,建議和server.conf在一個目錄下

cert jhrdc.crt //jhrdc.crt的路徑,建議和server.conf在一個目錄下

key jhrdc.key //jhrdc.key的路徑,建議和server.conf在一個目錄下

server 10.8.0.0 255.255.255.0 //DHCP服務器的IP段,缺省是10.8.0.0

client-to-client //VPN客戶端之間允許互相訪問,如不需要客戶端之間互相訪問,則可注釋該配置

max-clients 10 //并發的客戶端鏈接,可設為10個

user nobody //服務啟動時使用的系統用戶,建議使用nobody

group nobody //服務啟動時使用的系統用戶組,建議使用nobody

五、啟動openvpn的服務器端

#cd /etc/openvpn

#openvpn —config /etc/openvpn/server.conf —daemon

六、配置客戶端

下載Windows客戶端,下載鏈接為https://openvpn.net/index.php/download/community-downloads.html,

安裝后,將第三步所生成的證書文件和配置文件放在一個目錄里,并修改客戶端配置文件,然后啟動該配置文件即大功告成。配置文件簡要說明

client

proto tcp

remote 111.111.111.111 1194  //VPN服務器的IP地址和端口號

ca /etc/openvpn/ca.crt //ca.crt的路徑,建議和server.conf在一個目錄下

cert /etc/openvpn/testchannel1.crt //testchannel1.crt的路徑,建議和server.conf在一個目錄下

key /etc/openvpn/testchannel1.key //testchannel1.key的路徑,建議和server.conf在一個目錄下

Please enter the following 'extra' attributes

to be sent with your certificate request

A challenge password []:Jing7VPN

An optional company name []:JingHang

七、將openvpn添加到啟動腳本/etc/rc.d/rc.local里

CentOS 7里面需要給rc.local加上可執行權限,

需要ln -s /etc/rc.d/rc.local /etc/rc.local

=======

#!/bin/sh

#

# This script will be executed *after* all the other init scripts.

# You can put your own initialization stuff in here if you don't

# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

/usr/local/sbin/openvpn --config /etc/openvpn/client.conf --daemon

service iptables start

自啟動時,server.conf里,證書的路徑需要是絕對路徑


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 天长市| 卢龙县| 天津市| 庆阳市| 东兰县| 彭山县| 西华县| 惠水县| 鄂州市| 商南县| 新化县| 巴林左旗| 襄汾县| 磐石市| 阿荣旗| 拜泉县| 凤庆县| 灵石县| 富锦市| 嵊州市| 旬邑县| 墨竹工卡县| 克拉玛依市| 浦城县| 芦溪县| 济南市| 陆良县| 门头沟区| 怀来县| 桦甸市| 祁阳县| 和静县| 乌兰浩特市| 冷水江市| 关岭| 永吉县| 多伦县| 延吉市| 刚察县| 翼城县| 马鞍山市|