open0pn的一次踩坑

发布时间:2020-06-24 10:32:39 作者:缘柠
来源:网络 阅读:225

open0pn的一些介绍

open0pn的原理

Open0pn的技术核心是虚拟网卡,其次是SSL协议实现:
  虚拟网卡是使用网络底层编程技术实现的一个驱动软件,安装后在主机上多出现一个网卡,可以像其它网卡一样进行配置。服务程序可以在应用层打开虚拟网卡,如果应用软件(如IE)向虚拟网卡发送数据,则服务程序可以读取到该数据,如果服务程序写合适的数据到虚拟网卡,应用软件也可以接收得到。虚拟网卡在很多的操作系统下都有相应的实现,这也是Open0pn能够跨平台一个很重要的理由。
  在Open0pn中,如果用户访问一个远程的虚拟地址(属于虚拟网卡配用的地址系列,区别于真实地址),则操作系统会通过路由机制将数据包(TUN模式)或数据帧(TAP模式)发送到虚拟网卡上,服务程序接收该数据并进行相应的处理后,通过SOCKET从外网上发送出去,远程服务程序通过SOCKET从外网上接收数据,并进行相应的处理后,发送给虚拟网卡,则应用软件可以接收到,完成了一个单向传输的过程,反之亦然。

open0pn的优缺点

  优点:成本低,是一个廉价有效的构建私有网络的方式,用它可以替代昂贵的实体专线;灵活,比实体专线更灵活。例如,一个公司可以在0pn站点的数量调整,根据不断变化的需求。
  缺点:搭建不容易,对技术要求非常高,需要对网络和安全问题有高水平的理解以及认真地规划和配置。由于在互联网上缺乏质量服务(QoS)管理,可能会导致数据包丢失和其他性能问题。若公共网络条件发生问题,则私网的管理员不能控制。出于这个原因,许多大公司一般购买使用可信0pn使用专用网络,以保证服务质量。

0pn的作用

0pn的分类

open0pn的部署

1.关闭selinux

 setenforce 0

2.安装编译环境

yum -y install gcc gcc-c++ make
yum -y install pam-devel.x86_64

3.配置0pn时间同步服务器

4.安装lzo压缩模块

#准备包
wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.10.tar.gz
#解压安装
tar xf lzo-2.10.tar.gz
cd lzo-2.10.tar.gz
./configure
make && make install

5.安装open0pn 软件

#安装ssl
yum -y install openssl*
#源码包
wget https://swupdate.open***.org/community/releases/open***-2.4.6.tar.gz
#解压安装
tar xf open***-2.4.6.tar.gz
cd open***-2.4.6
./configure --prefix=/usr/local/open*** --with-lzo-headers=/usr/local/include --with-lzo-lib=/usr/local/lib
make && make install
  1. 检查版本
    #把包里的脚本做软链接
    ln -sv /home/open***-2.4.6/src/open***/open***/usr/bin/open***
    open*** --version

    open0pn的一次踩坑
    7.配置CA证书

    #下载easy-rsa
    wget http://build.open***.net/downloads/releases/easy-rsa-2.2.0_master.tar.gz
    tar xf easy-rsa-2.2.0_master.tar.gz
    cd easy-rsa-2.2.0_master
    ./configure
    make && make install
    #放置/etc/open0pn
    mkdir /etc/open***
    cp -rf /home/easy-rsa /etc/open***/
    #配置vars
    vi /etc/open***/easy-rsa/vars

    open0pn的一次踩坑

    cd /etc/open***/easy-rsa
    source vars  //执行脚本生成证书时,需要设置一些环境变量 
    #生成根证书-CA证书,CA证书同时需要部署在服务器和客户端上
    ./build-ca #一路回车
    #查看ca
    [root@aliyun ~]# ll /etc/open***/keys/ca*
    -rw-r--r-- 1 root root 1643 Dec 12 11:05 /etc/open***/keys/ca.crt
    -rw------- 1 root root 1704 Dec 12 11:05 /etc/open***/keys/ca.key

    介绍一下easy-rsa的的工具功能

    [root@aliyun easy-rsa]# ll
    build-ca #生成CA证书
    build-dh #生成密码协议交换文件
    build-key  #生成免密码客户端密钥对
    build-key-pass #生成带密码客户端密钥对
    build-key-server #生成服务端密钥对
    clean-all #初始化配置,清空所有keys
    pkitool #各证书生成主要调用此命令执行
    revoke-full #证书吊销
    vars #预定义的证书基本信息


8.生成server证书和密钥key

./build-key-server jhrdc

open0pn的一次踩坑

[root@aliyun ~]# ll /etc/open***/easy-rsa/keys/jhrdc.*
#查看证书
-rw-r--r-- 1 root root 5340 Dec 12 11:08 /etc/open***/easy-rsa/keys/jhrdc.crt #服务端证书
-rw-r--r-- 1 root root 1115 Dec 12 11:08 /etc/open***/easy-rsa/keys/jhrdc.csr #服务端证书请求文件
-rw------- 1 root root 1708 Dec 12 11:08 /etc/open***/easy-rsa/keys/jhrdc.key #服务端私钥

8.生成客户端证书和密钥,若要生成多个证书,重复步骤即可(一个证书仅限一人使用)

./build-key test#和之前server一样一路回车即可

9.生成需要密码验证的客户端密钥ett

./build-key-pass ett
Generating a 2024 bit RSA private key
.........................+++
...........................................................+++
writing new private key to 'ett.key'
Enter PEM pass phrase:                #此处需要输入用户密码 (***拨号的密码)
Verifying - Enter PEM pass phrase:        #确认密码
-----
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) [Beijing]:
Organization Name (eg, company) [oldboy]:
Organizational Unit Name (eg, section) [oldboy]:
Common Name (eg, your name or your server's hostname) [ett]:
Name [oldboy]:
Email Address [mail@host.domain]:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456
An optional company name []:oldboy
Using configuration from /etc/open***/easy-rsa/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:'Beijing'
organizationName      :PRINTABLE:'oldboy'
organizationalUnitName:PRINTABLE:'oldboy'
commonName            :PRINTABLE:'ett'
name                  :PRINTABLE:'oldboy'
emailAddress          :IA5STRING:'mail@host.domain'
Certificate is to be certified until Oct 23 08:45:44 2028 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@aliyun ~]# ll /etc/open***/easy-rsa/keys/ett*
-rw-r--r-- 1 root root 5217 Dec 12 11:12 /etc/open***/easy-rsa/keys/ett.crt
-rw-r--r-- 1 root root 1110 Dec 12 11:12 /etc/open***/easy-rsa/keys/ett.csr
-rw------- 1 root root 1834 Dec 12 11:12 /etc/open***/easy-rsa/keys/ett.key

10.生成密钥协议交换文件

./build-dh #视网络环境,等待即可

open0pn的一次踩坑
11.防止恶意连接(如DOS、UDP port flooding),生成一个“HMAC firewalls”

open*** --genkey --secret keys/ta.key

[root@aliyun ~]# ll /etc/open***/easy-rsa/keys/ta*
-rw------- 1 root root 636 Dec 12 11:20 /etc/open***/easy-rsa/keys/ta.key
#复制证书
cp -ap keys /etc/open***/
将服务端配置文件拷贝到/etc/open***/目录
[root@aliyun ~]# cp open***-2.4.6/sample/sample-config-files/{client,server}.conf /etc/open***/
[root@aliyun open***] ls
client.conf  easy-rsa  keys  server.conf

12.备份配置文件

cp client.conf client.conf.bak
cp server.conf server.conf.bak
#server配置
[root@aliyun ~]#  grep -vE ";|#|^$" /etc/open***/server.conf
port 52115
proto tcp #指定监听的协议,当并发访问多时,推荐tcp
dev tun #*** server的模式采用路由模式。可选tap或tun
ca /etc/open***/keys/ca.crt #写绝对路径
cert /etc/open***/keys/jhrdc.crt
dh /etc/open***/keys/dh3048.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "route 172.18.249.0 255.255.240.0" #加一条路由
client-to-client #允许拨号的多个client互相通信
duplicate-cn  #允许多个客户端使用一个账号连接
keepalive 10 120
cipher AES-256-CBC
persist-key #   当超时后,当重新启动后,保持上一次使用的私钥,而不重新读取私钥
persist-tun
status open***-status.log
log /var/log/open***.log
verb 3
#

open0pn的一次踩坑

13.调试服务启动

#开启路由转发功能
sed -i 's#net.ipv4.ip_forward = 0#net.ipv4.ip_forward = 1#' /etc/sysctl.conf
#开启服务
/usr/local/sbin/open*** --config /etc/open***/server.conf &
#检查***服务端口:
netstat -lntup | grep ***
#加入开机启动
echo "#startup open***" >>/etc/rc.local
echo "/usr/local/sbin/open*** --config /etc/open***/server.conf &" >>/etc/rc.local

14.window客户端配置
下载客户端 https://swupdate.open***.org/community/releases/open***-install-2.4.1-I601.exe
open0pn的一次踩坑
配置客户端证书
将ca.crt test.crt test.key 下载,
open0pn的一次踩坑
配置文件如下:

client
dev tun
proto tcp
remote IP 52115
resolv-retry infinite
nobind
persist-key
persist-tun
ca D:\\Open***\\config\\test\\ca.crt  #注意window的文件格式呵Linux不一样
cert D:\\Open***\\config\\test\\test.crt
key D:\\Open***\\config\\test\\test.key
ns-cert-type server
comp-lzo
verb 3
log D:\\Open***\\config\\test\\open***.log

open0pn的一次踩坑
导入配置点击登录,如下成功
open0pn的一次踩坑

参考https://idc.wanyunshuju.com/***/915.html

推荐阅读:
  1. 【jumpserver】记一次jumpserver部署的踩坑记录
  2. ingress rollingUpdate 踩坑记录

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

open0pn

上一篇:pycharm怎么安装pygame?

下一篇:如何用python爬取知乎话题?

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》