第1章第一個里程碑:
1.1服務端軟件包下載:地址:
https://swupdate.open***.org/community/releases/open***-2.4.1.tar.gz
http://www.oberhumer.com/opensource/lzo/download/lzo-2.09.tar.gz
http://swupdate.open***.org/community/releases/easy-rsa-2.2.0_master.tar.gz
1.2客戶端軟件包下載地址:
https://swupdate.open***.org/community/releases/open***-install-2.4.1-I601.exeshell
第2章第二個里程碑:
2.1建立軟件存放目錄並下載包(限於網速問題,可在瀏覽器下載好上傳服務器)
mkdir /server/tools -p
cd /server/tools
wget https://swupdate.open***.org/community/releases/open***-2.4.1.tar.gz
wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.09.tar.gz
wget http://swupdate.open***.org/community/releases/easy-rsa-2.2.0_master.tar.gz
2.2源碼安裝lzo壓縮模塊
2.2.1解壓並切換安裝目錄
tar zxf lzo-2.09.tar.gz
cd lzo-2.09
2.2.2預編譯,編譯安裝
./configure
make && make install
2.3源碼安裝open***-2.4.1
2.3.1先用yum安裝open***依賴包(保證下載最新的openssl)
yum -y install openssl pam
2.3.2解壓並切換安裝目錄
tar xf open***-2.4.1.tar.gz
cd open***-2.4.1
2.3.3預編譯,編譯安裝---指定加載lzo壓縮模塊
./configure --with-lzo-lib=/usr/local/lib --with-lzo-headers=/usr/local/include
make && make install
2.4源碼安裝easy-rsa-2.2.0(centos6.9默認yum安裝爲3.0版本,這裏用2.0版本由於官方介紹較詳細)
2.4.1解壓並切換安裝目錄
tar xf easy-rsa-2.2.0_master.tar.gz
cd easy-rsa-2.2.0_master/
2.4.2把easy-rsa-2.2.0_master目錄下easy-rsa目錄拷貝到/server/tools/open***-2.4.1/目錄下
cp -a easy-rsa/ /server/tools/open***-2.4.1/
2.4.3進入cd open***-2.4.1/easy-rsa/2.0目錄進行建立證書文件
2.4.3.1×××預設環境信息:(根據本身需求進行修改)
vim vars
export KEY_COUNTRY="CN"
export KEY_PROVINCE="BJ"
export KEY_CITY="BeiJing"
export KEY_ORG="test"
export KEY_EMAIL="1139210923@qq.com"
export KEY_EMAIL=1139210923@qq.com
export KEY_CN=test
export KEY_NAME=test
export KEY_OU=test
export PKCS11_MODULE_PATH=changeme
export PKCS11_PIN=1234
2.4.3.2使修改後vars文件生效
source vars
NOTE: If you run ./clean-all, I will be doing a rm -rf on /server/tools/open***-2.4.1/easy-rsa/2.0/keys
第一次會提示初始化配置,按提示操做,後續正常使用時不可執行此操做,它會清空keys目錄,並初始化序列
2.4.3.3建立keys證書祕鑰存放目錄
./clean-all
2.4.3.4製做CA證書,因爲已經預先定義好了各個配置,一路回車,表示使用默認配置
./build-ca
2.4.3.5生成服務端證書調用的命令爲build-key-server(一路回車,輸入兩個y便可)
./build-key-server server ---server爲服務端證書祕鑰名稱,本身可任意定製
注意點:
A challenge password []:test
An optional company name []:test
2.4.3.6生成客戶端證書與密鑰(一路回車,輸入兩個y便可)
./build-key test ---test爲客戶端證書祕鑰名稱,本身可任意定製
注意點:
A challenge password []:test
An optional company name []:test
2.4.3.7使用命令build-dh命令生成密碼協議交換文件
./build-dh ---過程稍慢,不要中斷
2.4.3.8生成防***的key文件 ---防止DDos***和udp淹沒
open*** --genkey --secret keys/ta.key
2.4.3.9查看生產的全部祕鑰文件
ls keys/
[root@m02/server/tools/open***-2.4.1/easy-rsa/2.0]#ls keys/
01.pem ca.key index.txt.attr serial server.csr test.crt
02.pem dh1024.pem index.txt.attr.old serial.old server.key test.csr
ca.crt index.txt index.txt.old server.crt ta.key test.keyvim
第3章第三個里程碑
3.1建立配置文件目錄,拷貝祕鑰文件到該目錄
mkdir /etc/open***
cd /etc/open***/
cp -a /server/tools/open***-2.4.1/easy-rsa/2.0/keys/ /etc/open***
3.2將服務端配置文件拷貝到/etc/open***/目錄並備份
cp /server/tools/open***-2.4.1/sample/sample-config-files/{client,server}.conf /etc/open***
cp client.conf{,.ori}
cp server.conf{,.ori}
3.3編輯服務端配置文件,下面是須要修改的內容,其餘默認
[root@m02/etc/open***]#egrep '^[^#;]' server.conf
port 1433 ---默認端口1194,這裏我修改成1433
proto tcp ---udp不太穩定,這裏改成tcp協議
dev tun ---採用隧道協議傳輸
ca /etc/open***/keys/ca.crt ---根證書文件
cert /etc/open***/keys/server.crt ---服務端證書文件
key /etc/open***/keys/server.key # This file should be kept secret ---服務端祕鑰文件
dh /etc/open***/keys/dh1024.pem #密碼協議交換文件由./build-dh 生產
server 10.8.0.0 255.255.255.0 #默認虛擬局域網網段,不要和實際的局域網衝突便可
ifconfig-pool-persist ipp.txt #服務器自動給客戶端分配IP後,客戶端下次鏈接時,仍然採用上次的IP地址(第一次分配的IP保存在ipp.txt中,下一次分配其中保存的IP)。
push "route 172.16.1.0 255.255.255.0" #×××服務器所在的內網的網段,讀者應該根據自身實際狀況進行修改
client-to-client # 可讓客戶端之間相互訪問直接經過open***程序轉發,根據須要設置
duplicate-cn # 若是客戶端都使用相同的證書和密鑰鏈接×××,必定要打開這個選項,不然每一個證書只容許一我的鏈接×××
keepalive 10 120 #每10秒ping一次,鏈接超時時間設爲120秒。
tls-auth /etc/open***/keys/ta.key 0 # This file is secret #開啓TLS-auth,使用ta.key防護***。服務器端的第二個參數值爲0,客戶端的爲1。
cipher AES-256-CBC
comp-lzo #開啓×××鏈接壓縮,若是服務器端開啓,客戶端也必須開啓
persist-key
persist-tun #持久化選項能夠儘可能避免訪問在重啓時因爲用戶權限下降而沒法訪問的某些資源。
status open***-status.log #指定記錄Open×××狀態的日誌文件路徑
log-append open***.log #追加生成日誌文件
verb 5 #指定日誌文件的記錄詳細級別,可選0-9,等級越高日誌內容越詳細
3.4開啓內核轉發
sed -i 's#_forward = 0#_forward = 1#g' /etc/sysctl.conf
sysctl -p ---使之生效
net.ipv4.ip_forward = 1
3.5配置防火牆,記得保存
/etc/init.d/iptables start
iptables -F ---清空以前全部策略
iptables -X
iptable -Z
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE ##網關不在***server上,在***server上添加一條NAT地址轉換,將全部的10.8.0.0/24網段的IP都轉成eth0的IP
/etc/init.d/iptables save ---保存配置
chkconfig iptables on ---開機啓動防火牆
3.6啓動open***並設置爲開機啓動
/usr/local/sbin/open*** --config /etc/open***/server.conf &
echo "#startup open***" >>/etc/rc.local
echo "/usr/local/sbin/open*** --config /etc/open***/server.conf &" >>/etc/rc.local
ps -ef|grep open*** ---查看進程是否存在
netstat -nlput | grep 1433 查看端口是否正確
lsof -i :1433 ---查看tcp端口監聽centos
3.7查看啓動後日志
tailf /etc/open***/open***.log
Mon Mar 12 17:34:17 2018 TUN/TAP device tun0 opened
Mon Mar 12 17:34:17 2018 TUN/TAP TX queue length set to 100
Mon Mar 12 17:34:17 2018 do_ifconfig, tt->did_ifconfig_ipv6_setup=0
Mon Mar 12 17:34:17 2018 /sbin/ifconfig tun0 10.8.0.1 pointopoint 10.8.0.2 mtu 1500
Mon Mar 12 17:34:17 2018 /sbin/route add -net 10.8.0.0 netmask 255.255.255.0 gw 10.8.0.2
Mon Mar 12 17:34:17 2018 Could not determine IPv4/IPv6 protocol. Using AF_INET
Mon Mar 12 17:34:17 2018 Socket Buffers: R=[87380->87380] S=[16384->16384]
Mon Mar 12 17:34:17 2018 Listening for incoming TCP connection on [AF_INET]172.16.1.62:1433
Mon Mar 12 17:34:17 2018 TCPv4_SERVER link local (bound): [AF_INET]172.16.1.62:1433
Mon Mar 12 17:34:17 2018 TCPv4_SERVER link remote: [AF_UNSPEC]
Mon Mar 12 17:34:17 2018 MULTI: multi_init called, r=256 v=256
Mon Mar 12 17:34:17 2018 IFCONFIG POOL: base=10.8.0.4 size=62, ipv6=0
Mon Mar 12 17:34:17 2018 IFCONFIG POOL LIST
Mon Mar 12 17:34:17 2018 MULTI: TCP INIT maxclients=1024 maxevents=1028
Mon Mar 12 17:34:17 2018 Initialization Sequence Completed瀏覽器
3.8查看啓動後網卡服務器
第4章第四個里程碑
4.1安裝open***客戶端
Open××× 2.4.1 Windows 64位 安裝文件:(安裝過程所有默認)
https://swupdate.open***.org/community/releases/open***-install-2.4.1-I601.exe
修改客戶端配置文件,下面爲修改內容,其餘默認
[root@m02/etc/open***]#egrep '^[^#;]' client.conf
client
dev tun
proto tcp
remote 10.0.0.62 1433 ---遠程服務端ip
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert test.crt
key test.key
ns-cert-type server
tls-auth ta.key 1
cipher AES-256-CBC
comp-lzo
verb 3app
4.2上傳客戶端所需文件
先將client.conf修改成client.o***,而後將Open×××服務器上的client.o***、ca.crt、test.crt、test.key、ta.key上傳到Windows客戶端安裝目錄下的config文件夾(C:\Program Files\Open×××\config)tcp
第5章啓動啓動Open××× GUI
5.1啓動客戶端ide
在電腦右下角的open***圖標上右擊,選擇「Connect」。正常狀況下應該可以鏈接成功(圖標變爲綠色),分配正常的IP。測試
5.2查看狀態日誌
[root@m02/etc/open***]#cat open***-status.log
Open××× CLIENT LIST
Updated,Mon Mar 12 22:27:24 2018
Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since
test,10.0.0.253:56299,97694,57321,Mon Mar 12 19:36:52 2018
ROUTING TABLE
Virtual Address,Common Name,Real Address,Last Ref
10.8.0.10,test,10.0.0.253:56299,Mon Mar 12 19:40:57 2018
GLOBAL STATS
Max bcast/mcast queue length,0
END
5.3Xshell本地測試
ui