版本:v0.01
日期:2005-09-12
* 版本歷程:
1) 2005-09-12 v0.01
- 初版
—————————————
一, 功能介紹
* SSL vpn 方案
* 可完整支援 L2 及 L3 連線
* 使用 CA 簽章確認及加密, 也可使用單一鍵值對稱加密
* 同時支援 Linux, FreeBSD, OS X 與 Windows
* 支援 tunnel 及 TAP 連線方式
* GPL 授權方式
二, 實作環境
2.1 server
OS: CentOS 4.1 Linux
real IP: 192.168.100.151
vpn IP: 10.8.0.1
2.2 client
OS: Windows XP(home)
real IP: 192.168.100.x(dhcp)
vpn IP: 10.8.0.x(server assigned)
三, 安裝
3.1 server
# 安裝 lzo (source rpm)
rpmbuild –rebuild http://openvpn.net/release/lzo-1.08-4.rf.src.rpm
rpm -ivh /usr/src/redhat/RPMS/i386/lzo-*.rpm
# 安裝 openvpn
mkdir /usr/src/pkgs
cd /usr/src/pkgs
wget http://openvpn.net/release/openvpn-2.0.2.tar.gz
rpmbuild -tb openvpn-1.6.0.tar.gz
rpm -ivh /usr/src/redhat/RPMS/i386/openvpn-2.0.2-1.i386.rpm
# 複制設定範例
cp -r /usr/share/doc/openvpn-2.0.2/easy-rsa/ /etc/openvpn/
cp /usr/share/doc/openvpn-2.0.2/sample-config-files/server.conf /etc/openvpn/
# 設定 CA 環境
cd /etc/openvpn/easy-rsa/
vi vars
export KEY_COUNTRY=TW
export KEY_PROVINCE=Taiwan
export KEY_CITY=Tainan
export KEY_ORG="Study-Area"
export KEY_EMAIL="netman@study-area.org"
. ./vars
./clean-all
# 建置 root CA
./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) [TW]:
State or Province Name (full name) [Taiwan]:
Locality Name (eg, city) [Tainan]:
organization Name (eg, company) [Study-Area]:
organizational Unit Name (eg, section) []:test
Common Name (eg, your name or your server’s hostname) []:CA
Email Address [netman@study-area.org]:
# 建置 server key 及 crt
./build-key-server ovpnsrv1
Generating a 1024 bit RSA private key
……………………….++++++
….++++++
writing new private key to ‘ovpnsrv1.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) [TW]:
State or Province Name (full name) [Taiwan]:
Locality Name (eg, city) [Tainan]:
organization Name (eg, company) [Study-Area]:
organizational Unit Name (eg, section) []:test
Common Name (eg, your name or your server’s hostname) []:ovpnsrv1
Email Address [netman@study-area.org]:
Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Using configuration from /etc/openvpn/easy-rsa/openssl.cnf
Check that the request matches the signature
Signature ok
The Subject’s Distinguished Name is as follows
countryName
RINTABLE:’TW’
stateOrProvinceName
RINTABLE:’Taiwan’
localityName
RINTABLE:’Tainan’
organizationName
RINTABLE:’Study-Area’
organizationalUnitName:PRINTABLE:’test’
commonName
RINTABLE:’ovpnsrv1′
emailAddress :IA5STRING:’netman@study-area.org’
Certificate is to be certified until Sep 7 20:36:58 2015 GMT (3650 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
# 建置 Diffie Hellman 參數
./build-dh
Generating DH parameters, 1024 bit long safe prime, generator 2
This is going to take a long time
…………………………….+……………………………………..
..+………………………………………………………………….
……………….+………………………………+………………….
…………………..+…
# 安裝 server 所需的 CA 文件
cp keys/ca.crt ../
cp keys/dh1024.pem ../
cp keys/ovpnsrv1.key ../
cp keys/ovpnsrv1.crt ../
# 配置 server 設定檔(沒提及的請保持原樣)
cd ../
vi server.conf
dev tap
;dev tun
ca ca.crt
cert ovpnsrv1.crt
key ovpnsrv1.key # This file should be kept secret
# 啟動 server
service openvpn restart
chkconfig openvpn on
————————–
3.2 Client
# 下載並安裝 openvpn (GUI 版本)
http://openvpn.se/files/install_packages/openvpn-2.0.2-gui-1.0.3-install.exe
# 設定環境
cmd.exe
cd "c:\Program Files\OpenVPN\easy-rsa"
edit vars.bat
(內容必需與 server 一至, 尤其 KEY_ORG 項目.)
# 建置 CA環境
vars
# 建置 client key 與 crs
build-key ovpnclt1
….
Common Name (eg, your name or your server’s hostname) []:ovpnclt1
….
# 提交 crs (請使用安全方式, 本例用 pscp.exe .)
pscp keys/ovpnclt1.csr root@192.168.100.151:/etc/openvpn/easy-rsa/keys
# 轉至 server, 簽署 client crt
————————
cd /etc/openvpn/easy-rsa/
./sign-req ovpnclt1
Using configuration from /etc/openvpn/easy-rsa/openssl.cnf
Check that the request matches the signature
Signature ok
The Subject’s Distinguished Name is as follows
countryName
RINTABLE:’TW’
stateOrProvinceName
RINTABLE:’Taiwan’
localityName
RINTABLE:’Tainan’
organizationName
RINTABLE:’Study-Area’
organizationalUnitName:PRINTABLE:’test’
commonName
RINTABLE:’ovpnclt1′
emailAddress :IA5STRING:’netman@study-area.org’
Certificate is to be certified until Sep 7 21:07:33 2015 GMT (3650 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
————————
# 安裝 CA 文件
cd ..\config
pscp root@192.168.100.151:/etc/openvpn/easy-rsa/keys/ovpnclt1.crt .\
pscp root@192.168.100.151:/etc/openvpn/easy-rsa/keys/ca.crt .\
copy ..\easy-rsa\keys\ovpnclt1.key .\
# 複制 sample 設定檔:
copy ..\sample-config\client.ovpn .\
# 配置 client 端設定檔
右下角(OpenVPN GUI)
右鍵–> Edit Config (沒提及的, 請保持原貌)
dev tap
;dev tun
dev-node OpenVPN_Tap
remote 192.168.100.151 1194
ca ca.crt
cert ovpnclt1.crt
key ovpnclt1.key
ns-cert-type server
# 設定 openvpn TAP 界面
控制台–>網路連線–>TAP-Win32#(#)
右鍵–>重新命名–>OpenVPN_Tap
# 啟動 openvpn client
右下角(OpenVPN GUI)
右鍵–> Connect
# 測試
ping 10.8.0.1
四, 注意:
4.1 要允許多個 client 相互連線, 須在 server 端打開:
client-to-client
4.2 若想隱藏 server IP, 但純作 bridge 來用:
;server 10.3.0.0 255.255.255.0
server-bridge 10.8.0.1 255.255.255.0 10.8.0.129 10.8.0.246
4.3 若由其它 CA 建的 csr , organization(KEY_ORG=)必需要一至.
否則, 不能簽署.
4.4 CA 文件分佈:
server:
ca.crt
dh1024.pem
server.crt
server.key # 必須保密
client:
ca.crt
client.crt
client.key # 必須保密
CA server:
ca.crt
ca.key # 必須保密
4.5 Windows XP + SP2 與某些安全套件一併運行可能會導至 windows client 端不能成功.
目前除了移除 SP2 或衝突套件外, 暫無更好方法.
參考: http://openvpn.se/xpsp2_problem.html
五, 官方網站及文件:
http://openvpn.net/
http://openvpn.net/howto.html