<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[静怡家园]]></title> 
<link>http://www.zhanghaijun.com/index.php</link> 
<description><![CDATA[书山有路勤为径，学海无涯苦作舟！]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[静怡家园]]></copyright>
<item>
<link>http://www.zhanghaijun.com/post//</link>
<title><![CDATA[openvpn成功安装笔记 使用rpm包安装]]></title> 
<author>碟舞飞扬 &lt;webmaster@zhanghaijun.com&gt;</author>
<category><![CDATA[Linux技术]]></category>
<pubDate>Mon, 16 May 2011 18:11:18 +0000</pubDate> 
<guid>http://www.zhanghaijun.com/post//</guid> 
<description>
<![CDATA[ 
	需要的软件包:<br/> <br/>1、安装加密软件包<br/> <br/>[root@localhost ~]#rpm -ivh lzo-2.02-3.el5.kb.i386.rpm<br/> <br/>2、安装openvpn<br/> <br/>[root@localhost ~]#rpm -ivh openvpn-2.1-0.20.rc4.el5.kb.i386.rpm<br/> <br/>3、复制生成证书密钥的文件夹<br/> <br/>[root@localhost ~]#cp -r /usr/share/openvpn/easy-rsa/2.0/ /etc/openvpn/<br/> <br/>4、复制范例的配制文件<br/> <br/>[root@localhost ~]#cp /usr/share/doc/openvpn-2.1/sample-config-files/server.conf /etc/openvpn/<br/> <br/>5、生成证书key<br/> <br/>(1)初始化PKI<br/> <br/>[root@localhost ~]# cd /etc/openvpn/2.0/<br/> <br/>[root@localhost 2.0]# vi vars<br/> <br/>修改正在面几项<br/> <br/>export KEY_COUNTRY=”CN”(注：国家)<br/> <br/>export KEY_PROVINCE=”SX”(注：省份)<br/> <br/>export KEY_CITY=”XA”(注：城市)<br/> <br/>export KEY_ORG=”VPN-TEST”(注：公司名称)<br/> <br/>export KEY_EMAIL=”ganxing888@qq.com”(注：电子邮件)<br/> <br/>[root@localhost 2.0]#env &#124;grep KEY(先查看一下，看到是没有)<br/> <br/>[root@localhost 2.0]# source ./vars<br/> <br/>NOTE: If you run ./clean-all, I will be doing a rm -rf on /etc/openvpn/2.0/keys<br/> <br/>(注：如果你已经运行了./clean-all,就运行rm -rf /etc/openvpn/2.0/keys 删除)<br/> <br/>[root@localhost 2.0]# env &#124;grep KEY<br/> <br/>KEY_EXPIRE=3650<br/> <br/>KEY_EMAIL=ganxing888@qq.com<br/> <br/>KEY_SIZE=1024<br/> <br/>KEY_DIR=/etc/openvpn/2.0/keys<br/> <br/>KEY_CITY=XA<br/> <br/>KEY_PROVINCE=SX<br/> <br/>KEY_ORG=VPN-TEST<br/> <br/>KEY_CONFIG=/etc/openvpn/2.0/openssl.cnf<br/> <br/>KEY_COUNTRY=CN<br/> <br/>[root@localhost 2.0]#<br/> <br/>[root@localhost 2.0]# ./clean-all (这时会在当前目录生成一个keys的目录)<br/> <br/>生成ca文件<br/> <br/>[root@localhost 2.0]# ./build-ca<br/> <br/>Generating a 1024 bit RSA private key<br/> <br/>….++++++<br/> <br/>..++++++<br/> <br/>writing new private key to ‘ca.key’<br/> <br/>—–<br/> <br/>You are about to be asked to enter information that will be incorporated<br/> <br/>into your certificate request.<br/> <br/>What you are about to enter is what is called a Distinguished Name or a DN.<br/> <br/>There are quite a few fields but you can leave some blank<br/> <br/>For some fields there will be a default value,<br/> <br/>If you enter ‘.’, the field will be left blank.<br/> <br/>—–<br/> <br/>Country Name (2 letter code) [CN]:<br/> <br/>State or Province Name (full name) [SX]:<br/> <br/>Locality Name (eg, city) [XA]:<br/> <br/>Organization Name (eg, company) [VPN-TEST]:<br/> <br/>Organizational Unit Name (eg, section) []:vpn<br/> <br/>Common Name (eg, your name or your server’s hostname) [VPN-TEST CA]:server(注意一定要添server)<br/> <br/>Email Address [ganxing888@qq.com]:<br/> <br/>[root@localhost 2.0]# ls keys/ (可以看到keys下生成了ca.crt ca.key 两个文件)<br/> <br/>(2)生成server key<br/> <br/>[root@localhost 2.0]# ./build-key-server server<br/> <br/>Generating a 1024 bit RSA private key<br/> <br/>………..++++++<br/> <br/>…………………………………………………++++++<br/> <br/>writing new private key to ‘server.key’<br/> <br/>—–<br/> <br/>You are about to be asked to enter information that will be incorporated<br/> <br/>into your certificate request.<br/> <br/>What you are about to enter is what is called a Distinguished Name or a DN.<br/> <br/>There are quite a few fields but you can leave some blank<br/> <br/>For some fields there will be a default value,<br/> <br/>If you enter ‘.’, the field will be left blank.<br/> <br/>—–<br/> <br/>Country Name (2 letter code) [CN]:<br/> <br/>State or Province Name (full name) [SX]:<br/> <br/>Locality Name (eg, city) [XA]:<br/> <br/>Organization Name (eg, company) [VPN-TEST]:<br/> <br/>Organizational Unit Name (eg, section) []:vpn<br/> <br/>Common Name (eg, your name or your server’s hostname) [server]:server<br/> <br/>Email Address [ganxing888@qq.com]:<br/> <br/>Please enter the following ‘extra’ attributes<br/> <br/>to be sent with your certificate request<br/> <br/>A challenge password []:boobooke(注：密码一定要添)<br/> <br/>An optional company name []:<br/> <br/>Using configuration from /etc/openvpn/2.0/openssl.cnf<br/> <br/>Check that the request matches the signature<br/> <br/>Signature ok<br/> <br/>The Subject’s Distinguished Name is as follows<br/> <br/>countryName :PRINTABLE:’CN’<br/> <br/>stateOrProvinceName :PRINTABLE:’SX’<br/> <br/>localityName :PRINTABLE:’XA’<br/> <br/>organizationName :PRINTABLE:’VPN-TEST’<br/> <br/>organizationalUnitName:PRINTABLE:’vpn’<br/> <br/>commonName :PRINTABLE:’server’<br/> <br/>emailAddress :IA5STRING:’ganxing888@qq.com’<br/> <br/>Certificate is to be certified until Dec 31 13:40:06 2019 GMT (3650 days)<br/> <br/>Sign the certificate? [y/n]:y<br/> <br/>1 out of 1 certificate requests certified, commit? [y/n]y<br/> <br/>Write out database with 1 new entries<br/> <br/>Data Base Updated<br/> <br/>[root@localhost 2.0]#<br/> <br/>[root@localhost 2.0]# ls keys/ (可以看到生成了server.crt server.csr server.key)<br/> <br/>(3)生成客户端 key<br/> <br/>[root@localhost 2.0]# ./build-key client1<br/> <br/>Generating a 1024 bit RSA private key<br/> <br/>……………………………..++++++<br/> <br/>…..++++++<br/> <br/>writing new private key to ‘client1.key’<br/> <br/>—–<br/> <br/>You are about to be asked to enter information that will be incorporated<br/> <br/>into your certificate request.<br/> <br/>What you are about to enter is what is called a Distinguished Name or a DN.<br/> <br/>There are quite a few fields but you can leave some blank<br/> <br/>For some fields there will be a default value,<br/> <br/>If you enter ‘.’, the field will be left blank.<br/> <br/>—–<br/> <br/>Country Name (2 letter code) [CN]:<br/> <br/>State or Province Name (full name) [SX]:<br/> <br/>Locality Name (eg, city) [XA]:<br/> <br/>Organization Name (eg, company) [VPN-TEST]:<br/> <br/>Organizational Unit Name (eg, section) []:vpn<br/> <br/>Common Name (eg, your name or your server’s hostname) [client1]:<br/> <br/>Email Address [ganxing888@qq.com]:<br/> <br/>Please enter the following ‘extra’ attributes<br/> <br/>to be sent with your certificate request<br/> <br/>A challenge password []:boobooke<br/> <br/>An optional company name []:<br/> <br/>Using configuration from /etc/openvpn/2.0/openssl.cnf<br/> <br/>Check that the request matches the signature<br/> <br/>Signature ok<br/> <br/>The Subject’s Distinguished Name is as follows<br/> <br/>countryName :PRINTABLE:’CN’<br/> <br/>stateOrProvinceName :PRINTABLE:’SX’<br/> <br/>localityName :PRINTABLE:’XA’<br/> <br/>organizationName :PRINTABLE:’VPN-TEST’<br/> <br/>organizationalUnitName:PRINTABLE:’vpn’<br/> <br/>commonName :PRINTABLE:’client1′<br/> <br/>emailAddress :IA5STRING:’ganxing888@qq.com’<br/> <br/>Certificate is to be certified until Dec 31 13:43:36 2019 GMT (3650 days)<br/> <br/>Sign the certificate? [y/n]:y<br/> <br/>1 out of 1 certificate requests certified, commit? [y/n]y<br/> <br/>Write out database with 1 new entries<br/> <br/>Data Base Updated<br/> <br/>以上选项要和那个server的保持一致。<br/> <br/>[root@localhost 2.0]# ls keys/ (可以看到生成了 client1.crt client1.key client1.csr )<br/> <br/>生成Diffie Hellman<br/> <br/>[root@localhost 2.0]# ./build-dh<br/> <br/>Generating DH parameters, 1024 bit long safe prime, generator 2<br/> <br/>This is going to take a long time<br/> <br/>………………………………………………………………………………………………………………………………………………+……………………………………………+……………………………………+………………………………………………………+……..+………………………….+………………………………………….+…………………………………………………..<br/> <br/>………………………………………+………………………………………………………………..+……………………………………………………………………………………………….+……………………….+……………+……………………………………………..+…………………..+……….+……….+.+………..+…………………………………..+………+…………………………………+…………………………………………+…………………….+…………………….+……………………………………………………………….+…………………………………+…..+……………………………………….+……………………+………………………………………….++*++*++*<br/> <br/>[root@localhost 2.0]#<br/> <br/>创建服务端配置文件<br/> <br/>将keys下的 ca.crt server.crt server.key dh1024.pem 拷贝到/etc/openvpn下。<br/> <br/>配制/etc/openvpn/server.conf<br/> <br/>[root@localhost openvpn]# vi server.conf<br/> <br/>port 1194<br/> <br/>proto udp<br/> <br/>dev tun<br/> <br/>ca ca.crt<br/> <br/>cert server.crt<br/> <br/>key server.key<br/> <br/>dh dh1024.pem<br/> <br/>server 10.8.0.0 255.255.255.0<br/> <br/>client-to-client<br/> <br/>keepalive 10 120<br/> <br/>comp-lzo<br/> <br/>persist-key<br/> <br/>persist-tun<br/> <br/>status openvpn-status.log<br/> <br/>verb 4<br/> <br/>push “dhcp-option DNS “202.98.5.68″<br/> <br/>“server.conf” 16L, 249C written<br/> <br/>[root@localhost openvpn]#<br/> <br/>启动服务<br/> <br/>[root@localhost openvpn]# service openvpn restart<br/> <br/>服务启动后用ifconfig查看 可以看到有一个新的接口tun0<br/> <br/>[root@localhost openvpn]# ifconfig<br/> <br/>tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00<br/> <br/>inet addr:10.8.0.1 P-t-P:10.8.0.2 Mask:255.255.255.255<br/> <br/>UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1<br/> <br/>RX packets:26 errors:0 dropped:0 overruns:0 frame:0<br/> <br/>TX packets:22 errors:0 dropped:0 overruns:0 carrier:0<br/> <br/>collisions:0 txqueuelen:100<br/> <br/>RX bytes:2804 (2.7 KiB) TX bytes:18332 (17.9 KiB)<br/> <br/>Windows上的客户端的设置<br/> <br/>安装openvpn软件<br/> <br/>copy 服务器上的/etc/openvpn/2.0/keys/下的ca.crt ca.key client1.crt client1.csr client1.key 到C:&#92;Program Files&#92;OpenVPN&#92;config下<br/> <br/>copy C:&#92;Program Files&#92;OpenVPN&#92;sample-config&#92;client.ovpn 到C:&#92;Program Files&#92;OpenVPN&#92;config下<br/> <br/>使用记事本编辑client.ovpn<br/> <br/>client<br/> <br/>dev tun<br/> <br/>proto udp<br/> <br/>remote 222.161.0.93 1194<br/> <br/>persist-key<br/> <br/>persist-tun<br/> <br/>ca ca.crt<br/> <br/>cert client1.crt<br/> <br/>key client1.key<br/> <br/>ns-cert-type server<br/> <br/>comp-lzo<br/> <br/>verb 3<br/> <br/>redirect-gateway def1<br/>Tags - <a href="http://www.zhanghaijun.com/tags/openvpn/" rel="tag">openvpn</a>
]]>
</description>
</item><item>
<link>http://www.zhanghaijun.com/post//#blogcomment</link>
<title><![CDATA[[评论] openvpn成功安装笔记 使用rpm包安装]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.zhanghaijun.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>