Open*** 服务器的搭建
?服務介紹
×××直譯就是虛擬專用通道,是提供給企業之間或者個人與公司之間安全數據傳輸的隧道,Open×××無疑是Linux下開源×××的先鋒,提供了良好的性能和友好的用戶GUI。它大量使用了OpenSSL加密庫中的SSLv3/TLSv1協議函數庫。
實驗拓撲圖
實驗環境
xuegod 63 br0 IP :172.18.80.163 ?eth1:192.168.10.63 ?(vmnet1) ? ? ? DG:192.168.10.64?
備注使用vmnet1 模擬公網
xuegod 64 eth1:192.168.10.64 ?? DG:192.168.10.63 ?(vmnet1)
?xuegod63 網絡信息查看
[root@xuegod63 桌面]# route -n?
Kernel IP routing table
Destination ? ? Gateway ? ? ? ? Genmask ? ? ? ? Flags Metric Ref ? ?Use Iface
172.18.80.0 ? ? 0.0.0.0 ? ? ? ? 255.255.255.0 ? U ? ? 1 ? ? ?0 ? ? ? ?0 eth0
192.168.10.0 ? ?0.0.0.0 ? ? ? ? 255.255.255.0 ? U ? ? 1 ? ? ?0 ? ? ? ?0 eth1
0.0.0.0 ? ? ? ? 192.168.10.64 ? 0.0.0.0 ? ? ? ? UG ? ?0 ? ? ?0 ? ? ? ?0 eth1
xueggod 64網絡信息查看
Xuegod63上面開啟路由轉發功能
[root@xuegod63 ~]# vim /etc/sysctl.conf
安裝*** 前的準備工作
[root@xuegod63 ~]# yum install openssl openssl-devel gcc -y
[root@xuegod64 ~]# yum install openssl openssl-devel gcc -y
配置xuegod 63為open***服務器
上傳需要的軟件包 ? ?lzo-2.03.tar.gz ?open***-2.2.2.tar.gz
安裝軟件?lzo-2.03.tar.gz
[root@xuegod63 lzo-2.03]# tar zxvf lzo-2.03.tar.gz ; cd /root/open***/lzo-2.03
[root@xuegod63 lzo-2.03]# ./configure --prefix=/usr/ && make -j 4 && make install?
?建立CA中心
[root@xuegod63 2.0]# pwd
/root/open***/open***-2.2.2/easy-rsa/2.0
配置CA中心的相關變量 ? ? ? ? ? ? ?
改
?64 export KEY_COUNTRY="US"
?65 export KEY_PROVINCE="CA"
?66 export KEY_CITY="SanFrancisco"
?67 export KEY_ORG="Fort-Funston"
?68 export KEY_EMAIL="me@myhost.mydomain"
?69 export KEY_EMAIL=mail@host.domain
?70 export KEY_CN=changeme
?71 export KEY_NAME=changeme
?72 export KEY_OU=changeme
?73 export PKCS11_MODULE_PATH=changeme
?74 export PKCS11_PIN=1234
為
?export KEY_COUNTRY="CN"
?65 export KEY_PROVINCE="CA"
?66 export KEY_CITY="beijing"
?67 export KEY_ORG="xuegod"
?68 export KEY_EMAIL="me@myhost.mydomain"
?69 export KEY_EMAIL=mail@host.domain
?70 export KEY_CN=changeme
?71 export KEY_NAME=changeme
?72 export KEY_OU=IT
?73 export PKCS11_MODULE_PATH=changeme
?74 export PKCS11_PIN=1234
[root@xuegod63 2.0]# ls keys/
index.txt ?serial
[root@xuegod63 keys]# cat serial ?CA認證簽名的次數
01
[root@xuegod63 keys]# cat index.txt ?簽名過的用戶
配置CA中心
[root@xuegod63 2.0]# ./build-ca ? 一路回車
[root@xuegod63 2.0]# ./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]:
State or Province Name (full name) [CA]:
Locality Name (eg, city) [beijing]:
Organization Name (eg, company) [xuegod]:
Organizational Unit Name (eg, section) [IT]:
Common Name (eg, your name or your server's hostname) [changeme]:xuegod63.cn
Name [changeme]:bob
Email Address [mail@host.domain]:bob@xuegod.com
[root@xuegod63 2.0]# ls keys/
ca.crt ? # 根證書 ca.key #私鑰 ?index.txt ?serial
頒發證書
頒發證書給*** server
[root@xuegod63 2.0]# ./build-key-server ?server ?頒發證書給server 一路回車
查看***生成的相關配置文件
[root@xuegod63 2.0]# ll keys/server.*
-rw-r--r-- 1 root root 3993 11月 12 02:20 keys/server.crt ? ? ? 服務器的證書
-rw-r--r-- 1 root root ?712 11月 12 02:19 keys/server.csr ? ? ? ? ?服務器的證書請求文件
-rw------- 1 root root ?912 11月 12 02:19 keys/server.key ? ? ? ? ? 服務器的私鑰
查看序列號和已經頒發的證書文件
[root@xuegod63 2.0]# cat keys/serial
02
[root@xuegod63 2.0]# cat keys/index.txt
V251108181933Z01unknown/C=CN/ST=beijing/L=beijing/O=xuegod/OU=IT/CN=server/name=changeme/emailAddress=mail@host.domain
頒發證書給客戶端
[root@xuegod63 2.0]# ./build-key yonghu
?查看證書
[root@xuegod63 2.0]# ll keys/yonghu.*
-rw-r--r-- 1 root root 3871 11月 12 02:31 keys/yonghu.crt ? #客戶端證書
-rw-r--r-- 1 root root ?712 11月 12 02:31 keys/yonghu.csr ? ?#客戶端證請求文件
-rw------- 1 root root ?916 11月 12 02:31 keys/yonghu.key ? #客戶端證?私鑰
查看序列號和CA頒發的證書文件
[root@xuegod63 2.0]# cat keys/serial
03
[root@xuegod63 2.0]# cat keys/index.txt
V251108181933Z01unknown/C=CN/ST=beijing/L=beijing/O=xuegod/OU=IT/CN=server/name=changeme/emailAddress=mail@host.domain
V251108183134Z02unknown/C=CN/ST=beijing/L=beijing/O=xuegod/OU=IT/CN=yonghu/name=changeme/emailAddress=mail@host.domain
CA認證確認身份后,客戶端和服務端需要協商一份對稱秘鑰,來加密數據
建立秘鑰(迪菲爾曼)
[root@xuegod63 2.0]# ./build-dh?
Generating DH parameters, 1024 bit long safe prime, generator 2
This is going to take a long time
........................................................................................+.....+..........................................+.............+............................................................................++*++*++*
[root@xuegod63 2.0]# ls keys/dh1024.pem?
keys/dh1024.pem
[root@xuegod63 2.0]# cat keys/dh1024.pem?
-----BEGIN DH PARAMETERS-----
MIGHAoGBAO+CR/g6dn05dNCsHTNMtaDoBXZJbs926pl2jKHpu2aMypLxsCRpKxDW
/imTYkftEGGzeqhOMigWgddgJhp3Cq1F+BWtgsm7bqFiPKa6x0M/ju0qZbePz8Jg
pC5aYNBh1ebuvj5co+gs2BjDmN1D050A652uNDHRVmso/XZe8MULAgEC
-----END DH PARAMETERS-----
備注以后若要添加客戶端,使用CA重復給客戶端頒發證書,以及生成對應的私鑰使用下面的步驟
?./build-key XXXX
?./build-dh
配置×××服務器
cp sample-config-files/server.conf ? /etc/server.conf
ca的路徑
[root@xuegod63 keys]# pwd
/root/open***/open***-2.2.2/easy-rsa/2.0/keys
需要修改的內容
;proto tcp
?36 proto udp
改為
;proto tcp
proto tcp
78 ca ca.crt
ca ?/root/open***/open***-2.2.2/easy-rsa/2.0/keys/ca.crt ?##ca中心的根證書
?79 cert server.crt
cert?/root/open***/open***-2.2.2/easy-rsa/2.0/keys/server.crt ?##open***服務器的證書
?80 key server.key ?# This file should be kept secret
key?/root/open***/open***-2.2.2/easy-rsa/2.0/keys/server.key ?##open***服務器的秘鑰
87 dh1024.pem
dh ??/root/open***/open***-2.2.2/easy-rsa/2.0/keys/dh1024.pem
295 verb 3
? ??verb 4
138行后追加1條路由
;push "route 192.168.10.0 255.255.255.0"
;push "route 192.168.20.0 255.255.255.0"
push "route 172.18.80.0 255.255.255.0"
啟動open***
[root@xuegod63 ~]# /usr/local/sbin/open*** --config /etc/server.conf?--daemon(表示在后臺啟動)
? ? ? ? ?Thu Nov 12 05:33:58 2015 Initialization Sequence Completed
查看是否啟動成功
[root@xuegod63 keys]# netstat -anutp | grep 1194
tcp ? ? ? ?0 ? ? ?0 0.0.0.0:1194 ? ? ? ? ? ? ? ?0.0.0.0:* ? ? ? ? ? ? ? ? ? LISTEN ? ? ?24646/open***?
[root@xuegod63 keys]# ifconfig 多出一個網卡
tun0 ? ? ?Link encap:UNSPEC ?HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 ?
? ? ? ? ? inet addr:10.8.0.1 ?P-t-P:10.8.0.2 ?Mask:255.255.255.255
? ? ? ? ? UP POINTOPOINT RUNNING NOARP MULTICAST ?MTU:1500 ?Metric:1
? ? ? ? ? RX packets:0 errors:0 dropped:0 overruns:0 frame:0
? ? ? ? ? TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
? ? ? ? ? collisions:0 txqueuelen:100?
? ? ? ? ? RX bytes:0 (0.0 b) ?TX bytes:0 (0.0 b)
配置***客戶端
安裝lzo-2.03.tar.gz
[root@xuegod63 open***]# scp lzo-2.03.tar.gz open***-2.2.2.tar.gz ?192.168.10.64:/root/
[root@xuegod64 lzo-2.03]# tar zxvf lzo-2.03.tar.gz?
[root@xuegod64 lzo-2.03]# cd lzo-2.03
[root@xuegod64 lzo-2.03]# ./configure --prefix=/usr/ && make -j 4 && make install?
[root@xuegod64 lzo-2.03]# echo $?
0
安裝?open***
[root@xuegod64 open***-2.2.2]# tar zxvf open***-2.2.2.tar.gz?
[root@xuegod64 open***-2.2.2]# cd open***-2.2.2
[root@xuegod64 open***-2.2.2]# ./configure --with-lzo-lib=/usr/ ?&& make -j 4 && make install?
[root@xuegod64 open***-2.2.2]# echo $?
0
把之前生成的證書頒發給客戶端
[root@xuegod64 ~]# mkdir /etc/open*** ? 新建目錄用于存放證書
拷貝證書
拷貝文件
[root@xuegod64 ~]# cp /root/open***-2.2.2/sample-config-files/client.conf ? /etc/open***/
編輯文件
[root@xuegod64 ~]# vim /etc/open***/client.conf?
37行
;proto tcp
proto udp
proto tcp
remote my-server-1 1194
;remote my-server-2 1194
remote?192.168.10.63 1194
ca ca.crt
ca /etc/open***/ca.crt
cert client.crt
cert /etc/open***/yonghu.crt
key client.key
key /etc/open***/yonghu.key
啟動客戶端
[root@xuegod64 ~]# /usr/local/sbin/open*** --config /etc/open***/client.conf --daemon
查看啟動情況
[root@xuegod64 open***]# ifconfig tun0
tun0 ? ? ?Link encap:UNSPEC ?HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 ?
? ? ? ? ? inet addr:10.8.0.6 ?P-t-P:10.8.0.5 ?Mask:255.255.255.255
? ? ? ? ? UP POINTOPOINT RUNNING NOARP MULTICAST ?MTU:1500 ?Metric:1
? ? ? ? ? RX packets:0 errors:0 dropped:0 overruns:0 frame:0
? ? ? ? ? TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
? ? ? ? ? collisions:0 txqueuelen:100?
? ? ? ? ? RX bytes:0 (0.0 b) ?TX bytes:0 (0.0 b)
測試通信
open×××搭建完成
場景模擬:在xuegod63上開啟一臺ftp服務器只允許內網用戶和分公司的用戶訪問,可以先登錄***,在訪問192.168.10.63 或10.8.0.1
配置xuegod63為ftp 服務器
[root@xuegod63 keys]# rpm -ivh /mnt/Packages/vsftpd-2.2.2-11.el6_4.1.x86_64.rpm?
[root@xuegod63 keys]# /etc/init.d/vsftpd restart?
關閉 vsftpd: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?[失敗]
為 vsftpd 啟動 vsftpd: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?[確定]
xuegod 64 上進行測試
[root@xuegod64 open***]# rpm -ivh /mnt/Packages/lftp-4.0.9-1.el6.x86_64.rpm?
測試2
[root@xuegod63 ~]# echo "zhe shi wod *** " > /var/www/html/index.html
[root@xuegod63 ~]# cd /var/www/html/
[root@xuegod63 html]# ls
index.html
[root@xuegod63 html]# cat index.html?
zhe shi wod ***?
[root@xuegod63 html]# /etc/init.d/httpd restart?
停止 httpd: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [失敗]
正在啟動 httpd: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [確定]
[root@xuegod64 ~]# curl 10.8.0.1
zhe shi wod ***?
在xuegod63上開啟防火墻只允許 10.8.0.0/24 的20和21端口訪問
[root@xuegod63 keys]# /etc/init.d/iptables restart?
[root@xuegod63 keys]# iptables -t filter -A INPUT -s 10.8.8.0/24 -p tcp --dport 20 -j ACCEPT
[root@xuegod63 keys]# iptables -t filter -A INPUT -s 10.8.8.0/24 -p tcp --dport 21 -j ACCEPT
[root@xuegod63 keys]# /etc/init.d/iptables save
[root@xuegod63 keys]# iptables -nL --line-number
Chain INPUT (policy ACCEPT)
num ?target ? ? prot opt source ? ? ? ? ? ? ? destination ? ? ? ??
1 ? ?ACCEPT ? ? tcp ?-- ?10.8.8.0/24 ? ? ? ? ?0.0.0.0/0 ? ? ? ? ? tcp dpt:20?
2 ? ?ACCEPT ? ? tcp ?-- ?10.8.8.0/24 ? ? ? ? ?0.0.0.0/0 ? ? ? ? ? tcp dpt:21?
轉載于:https://blog.51cto.com/sdsca/1713922
總結
以上是生活随笔為你收集整理的Open*** 服务器的搭建的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【小技巧】【map】【set】【Java
- 下一篇: 译文(Artistic Style Tr