open***的搭建
open***服务器端配置:
#whereis open***
#cd /usr/ports/security/open***
#make install
#cd /usr/local/share/doc/open***/easy-rsa/2.0
#chmod a+x *
把2.0下面的所有文件复制到easy-rsa目录下,要不然会出错
#tar zcvf 1.tar.gz *
#cp 1.tar.gz ../
#cd ..
#tar zxvf 1.tar.gz
默认的vars文件在FreeBSD下是用不了的,不要运行它,直接在csh下面执行以下格式的语句
#setenv D `pwd`
#setenv KEY_CONFIG /usr/local/share/doc/open***/easy-rsa/openssl.cnf
#setenv KEY_DIR /usr/local/etc/open***/keys
#setenv KEY_SIZE 1024
#setenv KEY_COUNTRY CN 定义你所在的国家,2个字符
#setenv KEY_PROVINCE ZJ 你所在的省份
#setenv KEY_CITY HangZhou 你所在的城市
#setenv KEY_ORG "My ×××" 你所在的组织
#setenv KEY_EMAIL "admin@163.com" 你的邮件地址
建立open***的配置文件目录
#mkdir /usr/local/etc/open***
现在来生成根证书
初始化keys目录生产根证书以及key 和创建证书颁发机构(CA)
#sh clean-all
#sh build-ca
这时会有一堆东西跑出来
Generating 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 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]:
跟着就提示你输入国家/省份/城市等信息,不用管它,都是默认,只有
Common Name (eg, your name or your server's hostname) []:
这个要设置,可以设置成你的主机名或者你的组织名什么的,例如My ×××
生成服务器使用的证书.
#sh build-key-server server
跟刚才的步骤一样,Common Name这个填写server,
Sign the certificate? [y/n]:
1 out of 1 certificate requests certified, commit? [y/n]
上面这两项填写y,其他的全部默认
生成客户端使用的证书
#sh build-key client1
#sh build-key client2
跟刚才的步骤一样,Common Name这个填写client1/client2
你可以为各个客户端生成各自的证书.
接着生成dh1024.pem (创建Diffie Hellman 参数,Diffie Hellman 用于增强安全性,在Open×××是必须的)
#sh build-dh
dhparam: not found 出现错误的解决办法
#ee build-dh
把$OPENSSL 改成 openssl
保存退出
#sh build-dh
...+............+...............................+.........................................................................................+.......................................................+............+.................................................+.............................+...........................................................................................................................+............................
证书生成完毕,现在开始设置配置文件.
先复制配置文件到配置文件目录里面
#cp /usr/local/share/doc/open***/sample-config-files/server.conf /usr/local/etc/open***
#cp /usr/local/share/doc/open***/sample-config-files/server.conf /usr/local/etc/open***/open***.conf
编辑配置文件open***.conf,这里只说明一下需要修改的地方,其他的不另解析.
#cd /usr/local/etc/open***
#ee open***.conf
port 1194 这是open***监听的端口,如果你认为默认端口不安全,可以改成你想要的端口,跟客户端配置文件要一致
;proto tcp
proto udp 使用什么方式的连接,默认是udp
;dev tap
dev tun 这是网络设置选项,一般来说,官方推荐使用tun接口,如果你要使用桥接,则需要改成tap接口
ca /usr/local/etc/open***/keys/ca.crt
cert /usr/local/etc/open***/keys/server.crt
key /usr/local/etc/open***/keys/server.key
这三个是设置证书具体路径,填写绝对路径
dh /usr/local/etc/open***/keys/dh1024.pem
同上
server 10.8.0.0 255.255.255.0 使用服务器模式,并指定×××虚拟网络地址
;client-to-client 这个选项是设置客户端之间可以相互通信的
duplicate-cn 这个是设置同一个客户证书可以同时多个连接
push "route 10.10.10.0 255.255.255.0" 为open***服务器添加到10.10.10.0这个LAN的路由
push "dhcp-option DNS 202.101.172.47" 为客户端设置DNS服务器地址
;max-clients 100 允许的最大并发×××连接数
log /var/log/open***.log ×××连接日志
保存退出
#touch /var/log/open***.log
#ee /etc/syslog.conf
添加:
!open***
*.* /var/log/open***.log
保存退出
#/etc/netstart
查看ip.forwarding的值
#sysctl net.inet.ip.forwarding 为0则没启用ip转发功能
启用ip.forwarding(ip转发功能)
#ee /etc/rc.conf
添加:
open***_enable="YES"
sysctl net.inet.ip.forwarding=1
保存退出
#/usr/local/etc/rc.d/open*** start 启动open***服务器
如果成功了可以用下面的命令查看
#ifconfig tun0
显示:
tun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1500
inet 10.8.0.1 --> 10.8.0.2 netmask 0xffffffff
Opened by PID 19399
成功
注:如果 Open××× 与 gateway 不共用同一台服务器,则需在 gateway 服务器上加
# /etc/rc.conf
static_routes="Open×××"
route_Open×××="-net 10.8.0.0/24 10.10.10.55"
其中,10.10.10.55 为 Open××× 服务器的 IP
Open××× 服务器则需启用 ip.forwarding (ip转发功能)
#ee /etc/rc.conf
sysctl net.inet.ip.forwarding=1
或
#/etc/rc.conf
gateway_enable="YES"
客户端:
系统:xp
安装open***-2.0.9-install.exe(尽量和服务器的版本接近)
下载地址:http://open***.net/index.php/open-source/downloads.html
把***服务端的证书和key:(从服务器上下载下来)
ca.crt
client1或client2.crt
client1或client2.key
放到windows的open***安装目录下的config文件下
在C:\Program Files\Open×××\sample-config下有客户端配置文件,把client.o***复制到C:\Program Files\Open×××\config下,并修改
remote 202.202.202.3 1194 open***服务器的外网地址 和端口(和服务器上的端口一致)
ca ca.crt
cert client1.crt
key client1.key (客户端证书和密钥的名字要和服务器上的一致)
其他的和服务器上的配置文件配置都一样,
客户端拨号:
在刚才改完到客户端配置文件右击,选择start open*** on this
config file即可.
然后打开cmd
查看是否获得到Ip和是否可以访问***内网ip
转载于:https://blog.51cto.com/gaosc900926/1159640