centos 6.7 下搭建open***

一、open*** 簡介

1、open***  *** 概述

     ***(全稱Virtual Private Network)虛擬專業網路)是依靠ISP和其他的NSP,公共網絡中建立的專用的數據通信網絡的技術,可以爲企業之間或者個人與企業之間提供安全的數據傳輸隧道服務。

2、***的作用

     *** 功能可以幫助公司裏的遠程用戶(出差/家裏)公司的機構、商業合作伙伴供應商等公司和自己的公司內部網路之間建立可訓的安全連接或者是

局域網連接,確保數據的加密安全傳輸和業務訪問,對於運維工程師來說。還可以連接不同的機房爲局域網,處理相關的業務流。

3、***的分類

     1.遠程訪問*** 服務

      通過個人電腦遠程撥號到企業辦公網路

     2.企業內部網絡之間的***服務

      在公司的分支機構的局域網和公司總部LAN之間的***連接。通過公網Internet 建立***將公司在各

      地的分支機構的LAN連接到公司總部的LAN

     3.互聯網公司多IDC機房之間的*** 服務

      此處是運維架構人員需要考慮的問題。不同機房之間業務管理和業務訪問,數據流動

4、常見隧道協議介紹

1、PPTP
    點對點隧道協議,是由包括微軟和3Com等公司組成的PPTP論壇開發的一種點對點隧道協議,基於撥號使用的PPP塄,使用PAP或CHAP之類的加密 算法,或者使用Microsoft的點對點加密算法MPPE。其通過跨越基於PCP/IP的數據網絡創建***實現了從遠程客戶端到專用企業服務器之間數 據的安全傳輸。PPTP支持通過公共網絡建立按需的、多協議的、虛擬專用網絡。PPTP允許加密IP通訊,然後在要跨越公司IP網絡或公共IP網絡發送的 IP頭中對其進行封裝。
    PPTP屬於點對點方式應用,比較適合遠程的企業用戶撥號到企業進行辦公等的應用
2、L2TP
    L2TP第2層隧道協議是IETF基於L2F開發的PPTP的後續版本。是一種工業標準Internet隧道協議,其可以爲跨越面向數據包的媒體發送點到點協議框架提供封裝。

3、IPsec
IP安全塄實際上是一套協議包而不是一個獨立 的協議。
IPSec隧道模式隧道是封裝、跌幅與解封裝的整個過程。
    openswan
4、SSL ***
    SSL 協議提供了數據私密性、端點驗證、信息完整性等特性。SSL協議由許多子協議組成,其中兩個

    主要的子協議是握手協議和記錄協議
    open***


5、Open***開源新產品
5.1 Open***產品介紹
    Open***是一個用於創建虛擬專用網絡加密通道的軟件包,,Open***允許參與建立***的閃電戰使

    用預設的私鑰,第三方證書,或者用戶名/密碼來進行身份驗證,它大量使用了OpenSSL加密庫。
5.2 Open***的多種身份驗證方式
    Open***提供了多種身份驗證方式,用以確認參與連接雙方的身份,包括:預享私鑰,第三方證書以

    及用戶名/密碼組合等
5.3 Open***的通信原理
    Open***所遙通信都基於一個單一的IP商品(默認是1194),默認使用DP協議通訊,同時TCP也被支持。Open***連接能通過大多數的代 理服務器,並且能夠在NAT的環境中很好的工作。Open***服務端具有向客戶端“推送”某些網絡配置信息的功能,這些信息包括:IP地址、跌幅設置 等。Open***提供了兩種虛擬網絡接口:通用Tun/Tap驅動,通過它們,可以建立三層IP隧道,或者虛擬二層以太網
  Open***的技術核心是虛擬網上,其次是SSL協議實現。
驗證
Open*** 提供了多種身份驗證方式,用以確認參與連接雙方的身份,包括:預享私鑰,第三方證書以及用戶名/密碼組合。預享密鑰最爲簡單,但同時它只能用於創建點對點 的***;基於PKI的第三方證書提供了最完善的功能,但是需要額外的精力去維護一個PKI證書體系。Open***2.0後引入了用戶名/口令組合的身 份驗證方式,它可以省略客戶端證書,但是仍有一份服務器證書需要被用作加密。
網絡
Open***所有的通信都基於一個單一的IP端口,默 認且推薦使用UDP協議通訊,同時TCP也被支持。Open***連接能通過大多數的代理服務器,並且能夠在NAT的環境中很好地工作。服務端具有向客戶 端“推送”某些網絡配置信息的功能,這些信息包括:IP地址、路由設置等。Open***提供了兩種虛擬網絡接口:通用Tun/Tap驅動,通過它們,可 以創建三層IP隧道,或者虛擬二層以太網,後者可以傳送任何類型的二層以太網絡數據。傳送的數據可通過LZO算法壓縮。IANA(Internet Assigned Numbers Authority)指定給Open***的官方端口爲1194。Open*** 2.0以後版本每個進程可以同時管理數個併發的隧道。
Open***使用通用網絡協議(TCP與UDP)的特點使它成爲IPsec等協議的理想替代,尤其是在ISP(Internet service provider)過濾某些特定***協議的情況下。
安全
Open***與生俱來便具備了許多安全特性:它在用戶空間運行,無須對內核及網絡協議棧作修改;初始完畢後以chroot方式運行,放棄root權限;使用mlockall以防止敏感數據交換到磁盤。
Open***通過PKCS#11支持硬件加密標識,如智能卡。


二、安張部署

 實驗環境

open*** server


公司(Server):eth0(外網):192.168.3.154

             eth1(內網):192.168.12.0

             tun0(內網):192.168.110.0(open***提供的虛擬IP)一定不能和服務端還有客戶端的IP網段相同

客戶端是xp的   192.168.3.28

 iptables 和selinux 全部都要關閉

  1。進行時間同步

[root@***server ~]#

\cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime  -rf
       echo '*/5 * * * * /usr/sbin/ntpdate ntp.sjtu.edu.cn' >> /var/spool/cron/root
        echo 'TIMEZONE="Asia/Shanghai"' > /etc/sysconfig/clock  
        /usr/sbin/ntpdate ntp.sjtu.edu.cn


2。安張依賴包

     wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.06.tar.gz

    tar -xzf lzo-2.06.tar.gz -C /usr/local/

    cd /usr/local/lzo-2.06
   ./configure

   make && make install

3。安裝open***
 可能需要安裝openssl

[root@***server ~]#yum -y install openssl*  open*** epel-release openssl-devel lzo easy-rsa

[root@***server ~]#cp  /usr/share/easy-rsa/2.2/* /etc/open***/

[root@***server ~]#cd /etc/open***/

     修改vars 腳本文件

     vi vars

     export KEY_COUNTRY="CN" ##所在的國家
     export KEY_PROVINCE="BJ" ## 所在的省份
     export KEY_CITY="BingJing"  ##所在的城市
     export KEY_ORG="yongle"     ##所屬的組織
     export KEY_EMAIL="[email protected]"  ##所屬的郵箱

     export KEY_OU="yongle"         ## 所屬公司

    source vars   ##使之文件生效

   NOTE: If you run ./clean-all, I will be doing a rm -rf on /etc/open***/keys

下面這個命令在第一次安裝時可以運行,以後在添加客戶端時千萬別運行,這個命令會清除所有已經生成的證書密鑰。

  [root@localhost open***]# ./clean-all  ## 清除所有的證書

  [root@localhost open***]# ./build-ca   ## 生成密鑰
Generating a 2048 bit RSA private key  ##生成服務器端ca證書
............+++
...................................................................+++
writing new private key to 'ca.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) [BJ]:
Locality Name (eg, city) [BingJing]:
Organization Name (eg, company) [yongle]:
Organizational Unit Name (eg, section) [yongle]:
Common Name (eg, your name or your server's hostname) [yongle CA]:
Name [EasyRSA]:

Email Address [[email protected]]:

一路回車即可,[]內的都是vars文件定義的,除非你不想使用vars定義的參數可以手動輸入

[root@localhost open***]# ls -ltr keys/
總用量 12
-rw-r--r--. 1 root root    0 4月   6 05:46 index.txt
-rw-r--r--. 1 root root    3 4月   6 05:46 serial
-rw-------. 1 root root 1704 4月   6 05:48 ca.key ##私鑰

-rw-r--r--. 1 root root 1692 4月   6 05:48 ca.crt  ##證書

[root@localhost open***]# ./build-key-server server   ###生成服務端密鑰,名字可以自定義
Generating a 2048 bit RSA private key
.....................................................................+++
............+++
writing new private key to 'server.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) [BJ]:
Locality Name (eg, city) [BingJing]:
Organization Name (eg, company) [yongle]:
Organizational Unit Name (eg, section) [yongle]:
Common Name (eg, your name or your server's hostname) [server]:
Name [EasyRSA]:
Email Address [[email protected]]:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123qq...
An optional company name []:yongle
Using configuration from /etc/open***/openssl-1.0.0.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName           :PRINTABLE:'CN'
stateOrProvinceName   :PRINTABLE:'BJ'
localityName          :PRINTABLE:'BingJing'
organizationName      :PRINTABLE:'yongle'
organizationalUnitName:PRINTABLE:'yongle'
commonName            :PRINTABLE:'yongle'
name                  :PRINTABLE:'EasyRSA'
emailAddress          :IA5STRING:'[email protected]'
Certificate is to be certified until Apr  4 09:52:38 2026 GMT (3650 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated

[root@localhost open***]# ./build-key duxing ## 生成客戶端證書文件

Generating a 2048 bit RSA private key
................................................................................................+++
...................................................................................................................................................+++
writing new private key to 'duxing.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) [BJ]:
Locality Name (eg, city) [BingJing]:
Organization Name (eg, company) [yongle]:
Organizational Unit Name (eg, section) [yongle]:
Common Name (eg, your name or your server's hostname) [duxing]:
Name [EasyRSA]:
Email Address [[email protected]]:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123qq...                ##密碼
An optional company name []:duxing          ##名字
Using configuration from /etc/open***/openssl-1.0.0.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName           :PRINTABLE:'CN'
stateOrProvinceName   :PRINTABLE:'BJ'
localityName          :PRINTABLE:'BingJing'
organizationName      :PRINTABLE:'yongle'
organizationalUnitName:PRINTABLE:'yongle'
commonName            :PRINTABLE:'duxing'
name                  :PRINTABLE:'EasyRSA'
emailAddress          :IA5STRING:'[email protected]'
Certificate is to be certified until Apr  4 09:56:25 2026 GMT (3650 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries

Data Base Updated


[root@localhost open***]# ./build-key-pass ett  ##創建ett客戶端(帶密碼)

Generating a 2048 bit RSA private key
....................................................................+++
...................................+++
writing new private key to 'ett.key'
Enter PEM pass phrase:                             ##輸入祕密123qq...

Verifying - Enter PEM pass phrase:          ##確認再次輸入祕密123qq...

-----
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) [BJ]:
Locality Name (eg, city) [BingJing]:
Organization Name (eg, company) [yongle]:
Organizational Unit Name (eg, section) [yongle]:
Common Name (eg, your name or your server's hostname) [ett]:
Name [EasyRSA]:
Email Address [[email protected]]:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123qq...                       ## 輸入用戶名和祕密
An optional company name []:duxing
Using configuration from /etc/open***/openssl-1.0.0.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName           :PRINTABLE:'CN'
stateOrProvinceName   :PRINTABLE:'BJ'
localityName          :PRINTABLE:'BingJing'
organizationName      :PRINTABLE:'yongle'
organizationalUnitName:PRINTABLE:'yongle'
commonName            :PRINTABLE:'ett'
name                  :PRINTABLE:'EasyRSA'
emailAddress          :IA5STRING:'[email protected]'
Certificate is to be certified until Apr  4 09:59:29 2026 GMT (3650 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
生成generate diffie hellman parameters

生成傳輸時用到的密鑰交換文件
    可能時間有點長

[root@***server ~]#./build-dh ##腳本生成傳輸時用到的密鑰交換文件

Generating DH parameters, 2048 bit long safe prime, generator 2
This is going to take a long time

..........................................................................................+......................................................................................................................................................................+..................+....+.........++*++*

在[root@***server ~]#ls -ltr  keys/

有一個dh2048.pem的文件


生成防惡意***的文件
如DDOS  cc
[root@***server ~]#open*** --genkey --secret keys/ta.key

編譯open***服務端的配置文件

內容如下

[root@localhost open***]# cat server.conf
local 192.168.3.154
port 1194
proto tcp
dev tun
ca keys/ca.crt
cert keys/server.crt
key keys/server.key
dh keys/dh2048.pem
server 192.168.110.0 255.255.255.0 # open***服務提供給客戶端的IP網段
push "route 192.168.3.0 255.255.255.0" # open***服務給客戶端加路由,可以讓客戶端訪問192.168.3.0這個網段的主機,至關重要,不加此條,你將無法訪問服務端的內網主機
client-to-client # 客戶端之間可以互相訪問
duplicate-cn # 一個客戶端證書可以多人使用
keepalive 10 120
comp-lzo
user nobody
group nobody
persist-key
persist-tun
status open***-status.log
verb 3
client-to-client
duplicate-cn
log         /var/log/open***.log


同時更改客戶端配置文件

[root@localhost open***]#cp /usr/share/doc/open***-2.3.10/sample/sample-config-files/client.conf  /etc/open***/

proto tcp        #更改監聽協議

ca keys/ca.crt
cert keys/duxing.crt
key keys/duxing.key

啓動服務

[root@localhost open***]# /etc/init.d/open*** restart
正在關閉open***:                                          [確定]
正在啓動 open***:                                         [確定]

[root@localhost open***]# lsof -i :1194 ##查看端口號,下面的ip就是我們要連接的遠程連接的ip地址

COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

open*** 21695 nobody    5u  IPv4  45076      0t0  TCP 192.168.3.154:open*** (LISTEN)

開啓ipv4 轉發 sysctl -p
net.ipv4.ip_forward = 1

在客戶端下載安裝客戶端配置文件,!注意:服務端和客戶端的版本必須相同

http://swupdate.open***.org/community/releases/open***-install-2.3.10-I001-i686.exe

在服務端將

下載 client.conf duxing.crt duxing.key ca.crt並將它們移到open***安裝目錄下的conf目錄下

將client.conf重新命名爲duxing.o***

更改duxing.o*** 下面的

proto tcp  ##服務端和客戶端的配置信息都需要一樣
remote 192.168.3.154 1194

ca ca.crt
cert duxing.crt

key duxing.key

auth-user-pass   ##開啓用戶登陸

輸入用戶名祕密登陸i成功

==================

總結:

第一、生成的open*** 時間是否同步

第二、iptables 有可能自動開啓登陸時檢測是否開啓,如果開啓則關閉。

===========================


Linux主機客戶端如下:

[root@***clinet ~]# yum install open*** lzo openssl openssl-devel  -y

[root@***clinet ~]# open***-client1.tar.gz ### 該包建議自行下載

[root@***clinet ~]# cd /etc/open***/

[root@***clinet ~]# tar xf open***-client1.tar.gz ./

[root@***clinet ~]#cat open***-client1.o***

client
dev tun
proto tcp
remote 192.168.3.1541194 # 192.168.1.100是open***的服務器地址
resolv-retry infinite
nobind
persist-key
persist-tun
ca /etc/open***/ca.crt   # ca證書在位置
cert /etc/open***/duxing.crt   # 客戶端證書位置
key /etc/open***/duxing.key  # 客戶端證書位置
remote-cert-tls server
comp-lzo
verb 5


運行open***客戶端

[root@***clinet ~]# /etc/init.d/open*** start

[root@***clinet ~]#ifconfig tun0

會看見有一個192.168.110.0網段的IP地址

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章