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地址

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