Windows客戶端安裝
1) 下載安裝Open***客戶端工具
創建客戶端配置文件 ../Open***/config/client.o*** 內容如下
# cat client.o*** client dev tun proto tcp remote 203.195.xxx.xxx 1194 # Open***服務器的外網IP和端口 resolv-retry infinite nobind persist-key persist-tun ca ca.crt ;cert client1.crt # client1的證書 ;key client1.key # client1的密鑰 ns-cert-type server tls-auth ta.key 1 # 客戶端是1,服務器是0 comp-lzo verb 3 auth-user-pass # 啓動User/Pass登錄的方式
2) 拷貝client.o***文件到win本地open***客戶端 ../Open***/config/目錄下
從服務器上拷貝證書/祕鑰 “ca.crt、ta.key” 到本地open***客戶端的config/目錄下
然後用管理員身份打開Open***客戶端,點擊連接。切記,一定要用管理員身份打開,否則客戶端將無法執行服務端push推送過來的route路由添加指令
ok,如果一切順利,就會看到 "Mon Apr 11 16:26:12 2016 MANAGEMENT: >STATE:1460363172,CONNECTED,SUCCESS,10.8.0.6,10.2.8.45",客戶端分配到的ip,10.8.0.6
打開CMD,ipconfig /all 可以看到分配的虛擬ip
Linux 客戶端安裝
1) 下載客戶端工具 # rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm # yum install -y open*** 2) 創建客戶端配置文件 client.conf # cat /etc/open***/conf/client.conf 添加如下內容 client dev tun proto tcp remote 203.195.xxx.xxx 1194 # Open***服務器的外網IP和端口 resolv-retry infinite nobind persist-key persist-tun ca ca.crt ns-cert-type server tls-auth ta.key 1 # 客戶端是1,服務器是0 comp-lzo verb 3 auth-user-pass # 啓動User/Pass登錄的方式 3) 啓動客戶端 # open*** --daemon --config /etc/open***/conf/client.conf > /var/log/open***_client.log # 後臺守護進程模式啓動 Username: test # 輸入用戶名 Password: 123456 # 輸入密碼 # ps -ef | grep -v grep | grep open*** # 查看啓動進程
Linux客戶端啓動腳本 expect.sh
#!/usr/bin/expect # FileName: expect.sh # Auth: Loren # Date: 2016-04-26 10:00 # 定義賬號密碼 set user test set pass 123456 # 啓動命令 spawn /usr/local/sbin/open*** --daemon --config /etc/open***/config/client.conf > /var/log/open***_client.log set timeout 30 # 檢測到指定內容 expect "Username:" # 輸入賬號 send "$user\n" set timeout 30 # 檢測輸入密碼 expect "Password:" # 輸入密碼 send "$pass\n" set timeout 30 # 退出 expect eof
# expect expect.sh # 執行腳本
Linux客戶端啓動、停止、重啓及狀態腳本 open***_client.sh
#!/bin/bash # FileName ***_client_status.sh # Auth: Loren # Date: 2016-04-26 10:00 # 客戶端配置文件 CONF_FILE='/etc/open***/conf/client.conf' # log文件 LOG_FILE='/var/log/open***_client.log' # pid文件 PID_FILE='/tmp/open***_client.pid' # 啓動腳本 EXPECT='/etc/open***/expect.sh' function start() { #/usr/local/sbin/open*** --daemon --config $CONF_FILE > $LOG_FILE expect $EXPECT > /dev/null ps -ef | grep -v grep | grep open*** > /dev/null [ $? -eq 0 ] && echo -e 'Start Open*** \033[32msuccessfully\033[0m!' || echo -e 'Start Open*** \033[31mFailing\033[0m!' echo `ps -ef | grep -v grep | grep open*** | awk '{print $2}'` > $PID_FILE } function stop() { ps -ef | grep -v grep | grep open*** | awk '{print $2}' | xargs -I {} kill -9 {} > /dev/null ps -ef | grep -v grep | grep open*** > /dev/null [ $? -eq 0 ] && echo -e 'Stop Open*** is \033[31mFailing\033[0m!' || echo -e 'Stop Open*** is \033[32mOK\033[0m!' rm -f $PID_FILE } function status() { ps -ef | grep -v grep | grep open*** > /dev/null [ $? -eq 0 ] && echo -e 'Open*** is \033[32mRunning ...\033[0m' || echo -e 'Open*** is \033[31mStopped\033[0m!' } #### main case $1 in start) start ;; stop) stop ;; restart) stop start ;; status) status ;; *) echo "Error! Usage sh $0 (start|stop|restart|status)" ;; esac
sh open***_client start #啓動*** sh open***_client stop # 停止*** sh open***_client restart # 重啓***