查看keys目錄下生成的文件:
3、創建服務器端配置文件
# 在open***的配置目錄下新建一個keys目錄
mkdir /etc/open***/keys
# 將需要用到的open***證書和密鑰複製一份到剛創建好的keys目錄中
cp /usr/share/easy-rsa/2 .0 /keys/ {ca.crt,server.{crt,key},dh2048.pem,ta.key} /etc/open***/keys/
# 複製一份服務器端配置文件模板server.conf到/etc/open***/
cp /usr/share/doc/open***-2 .3.2 /sample/sample-config-files/server .conf /etc/open***/
# 查看server.conf裏的配置參數
grep '^[^#;]' /etc/open***/server .conf
# 編輯server.conf
vim /etc/open***/server .conf
|
port 1194
# 改成tcp,默認使用udp,如果使用HTTP Proxy,必須使用tcp協議
proto tcp
dev tun
# 路徑前面加keys,全路徑爲/etc/open***/keys/ca.crt
ca keys/ca.crt
cert keys/server.crt
key keys/server.key # This file should be kept secret
dh keys/dh2048.pem
# 默認虛擬局域網網段,不要和實際的局域網衝突即可
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
# 10.0.0.0/8是我這臺***服務器所在的內網的網段,讀者應該根據自身實際情況進行修改
push "route 10.0.0.0 255.0.0.0"
# 可以讓客戶端之間相互訪問直接通過open***程序轉發,根據需要設置
client-to-client
# 如果客戶端都使用相同的證書和密鑰連接***,一定要打開這個選項,否則每個證書只允許一個人連接***
duplicate-cn
keepalive 10 120
tls-auth keys/ta.key 0 # This file is secret
comp-lzo
persist-key
persist-tun
# Open***的狀態日誌,默認爲/etc/open***/open***-status.log
status open***-status.log
# Open***的運行日誌,默認爲/etc/open***/open***.log
log-append open***.log
# 改成verb 5可以多查看一些調試信息
verb 5
|
4、配置內核和防火牆,啓動服務
# 開啓路由轉發功能
sed -i '/net.ipv4.ip_forward/s/0/1/' /etc/sysctl .conf
sysctl -p
# 配置防火牆,別忘記保存
iptables -I INPUT -p tcp --dport 1194 -m comment --comment "open***" -j ACCEPT
iptables -t nat -A POSTROUTING -s 10.8.0.0 /24 -j MASQUERADE
service iptables save
# 啓動open***並設置爲開機啓動
service open*** start
chkconfig open*** on
|
5、創建客戶端配置文件
# 複製一份client.conf模板命名爲client.o***
cp /usr/share/doc/open***-2 .3.2 /sample/sample-config-files/client .conf client.o***
# 編輯client.o***
vim client.o***
|
client
dev tun
# 改爲tcp
proto tcp
# Open***服務器的外網IP和端口
remote 203.195.xxx.xxx 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
# client1的證書
cert client1.crt
# client1的密鑰
key client1.key
ns-cert-type server
# 去掉前面的註釋
tls-auth ta.key 1
comp-lzo
verb 3
|
二、Windows客戶端安裝及配置
客戶端系統:Windows7 64位
內網IP:172.16.4.4
Open***版本:Open*** 2.3.3 Windows 64位
1、下載安裝Open***
Open*** 2.3.3 Windows 32位 安裝文件:
http://swupdate.open***.org/community/releases/open***-install-2.3.3-I002-i686.exe
Open*** 2.3.3 Windows 64位 安裝文件:
http://swupdate.open***.org/community/releases/open***-install-2.3.3-I002-x86_64.exe
2、配置client
將Open***服務器上的client.o***、ca.crt、client1.crt、client1.key、ta.key上傳到Windows客戶端安裝目錄下的config文件夾(C:\Program Files\Open***\config)
3、啓動Open*** GUI
在電腦右下角的open***圖標上右擊,選擇“Connect”。正常情況下應該能夠連接成功,分配正常的IP。
4、測試
ping通服務器的內網IP,說明已經接入到服務器的內部網絡。
到Open***服務器上查看客戶端的連接情況,查看狀態文件/etc/open***/open***-status.log: