{"id":405,"date":"2012-06-29T17:42:55","date_gmt":"2012-06-29T17:42:55","guid":{"rendered":""},"modified":"2013-02-07T12:10:28","modified_gmt":"2013-02-07T04:10:28","slug":"openvpn%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%8f%8a%e5%ae%a2%e6%88%b7%e7%ab%af%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/dingxuan.info\/wp\/?p=405","title":{"rendered":"OpenVPN\u670d\u52a1\u5668\u53ca\u5ba2\u6237\u7aef\u914d\u7f6e"},"content":{"rendered":"<p>\u672c\u6587\u4ee5CentOS 6 \u4f5c\u4e3aOpenVPN\u670d\u52a1\u5668\uff0cWIN XP\u53caWIN 7\u4f5c\u4e3a\u5ba2\u6237\u7aef\u64cd\u4f5c\u7cfb\u7edf\u3002\u4ee5\u4e0b\u5185\u5bb9\u5927\u91cf\u501f\u9274\u4e86pcman\u5927\u4fa0\u7684\u6587\u7ae0\u3002\u5728\u6b64\u57fa\u7840\u4e0a\uff0c\u8001\u718a\u53c8\u6839\u636e\u5b9e\u9645\u7ecf\u9a8c\u6539\u5199\u4e86\u4e00\u4e9b\u914d\u7f6e\u9009\u9879\u3002<!--more--><br \/><br \/><span style=\"font-size: 24px\">\u5148\u8bf4\u670d\u52a1\u5668\u7aef<\/span>\n<br \/><span style=\"font-size: 18px\">1. \u5b89\u88c5openvpn<\/span>\n<br \/><br \/>openvpn\u4e0d\u5728centos\u9ed8\u8ba4\u7684yum\u5b89\u88c5\u6e90\u5185\u3002\u9700\u8981\u5148\u5b89\u88c5Fedora\u7684EPEL\u6e90\u3002<br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">rpm -Uvh <a href=\"http:\/\/dl.fedoraproject.org\/pub\/epel\/6\/x86_64\/epel-release-6-7.noarch.rpm\">http:\/\/dl.fedoraproject.org\/pub\/epel\/6\/x86_64\/epel-release-6-7.noarch.rpm<\/a>\nyum install openvpn -y<\/pre>\n<br \/><br \/>\u5176\u4ed6\u66f4\u591a\u8f6f\u4ef6\u5305\u6765\u6e90\uff0c\u8bf7\u770b<a href=\"http:\/\/dingxuan.info\/blog\/post\/repo-sources.php\" target=\"_blank\">EPEL\u3001Remi\u3001RPMForge\u3001RPMFusion\u5b89\u88c5\u4ecb\u7ecd<\/a>\n<br \/><br \/><span style=\"font-size: 18px\">2. \u521d\u59cb\u5316<\/span>\n<br \/><br \/>\u521d\u59cb\u5316\u4e3b\u8981\u662f\u914d\u7f6eopenvpn\u7684config\u6587\u4ef6\uff0c\u5e76\u8bbe\u7f6eopenvpn\u81ea\u52a8\u542f\u52a8\u3002<br \/>\u590d\u5236\u914d\u7f6e\u6587\u4ef6\u7684\u6837\u672c\u5230\/etc\/openvpn\u76ee\u5f55\u4e0b\u3002<br \/><br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;root@esojourn.org ~]# cp \/usr\/share\/doc\/openvpn-2.2.2\/sample-config-files\/server.conf \/etc\/openvpn\/\n&#x5B;root@esojourn.org ~]#<\/pre>\n<br \/><br \/>\u7f16\u8f91\/etc\/openvpn\/server.conf\uff0c\u4fee\u6539\u5982\u4e0b\u914d\u7f6e\uff0c<br \/>\u4f7f\u7528TCP\u534f\u8bae\u6765\u8fdb\u884c\u8bbf\u95ee\u3002\u6253\u5f00gateway\uff0c\u63a8\u9001dns\u7b49\u3002<br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">#################################################<\/p>\n<h1 class=\"wp-block-heading\">Sample OpenVPN 2.0 config file for&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/h1>\n<h1 class=\"wp-block-heading\">multi-client server.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/h1>\n<p>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #<\/p>\n<h1 class=\"wp-block-heading\">This file is for the server side&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/h1>\n<h1 class=\"wp-block-heading\">of a many-clients  one-server&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/h1>\n<h1 class=\"wp-block-heading\">OpenVPN configuration.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/h1>\n<p>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #<\/p>\n<h1 class=\"wp-block-heading\">OpenVPN also supports&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/h1>\n<h1 class=\"wp-block-heading\">single-machine  single-machine&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/h1>\n<h1 class=\"wp-block-heading\">configurations (See the Examples page&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/h1>\n<h1 class=\"wp-block-heading\">on the web site for more info).&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/h1>\n<p>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #<\/p>\n<h1 class=\"wp-block-heading\">This config should work on Windows&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/h1>\n<h1 class=\"wp-block-heading\">or Linux\/BSD systems.&nbsp;&nbsp;Remember on&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/h1>\n<h1 class=\"wp-block-heading\">Windows to quote pathnames and use&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/h1>\n<h1 class=\"wp-block-heading\">double backslashes, e.g.:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/h1>\n<h1 class=\"wp-block-heading\">\"C:&#092;&#092;Program Files&#092;&#092;OpenVPN&#092;&#092;config&#092;&#092;foo.key\"<\/h1>\n<p>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #<\/p>\n<h1 class=\"wp-block-heading\">Comments are preceded with &#039;#&#039; or &#039;;&#039;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/h1>\n<p>#################################################<\/p>\n<h1 class=\"wp-block-heading\">Which local IP address should OpenVPN<\/h1>\n<h1 class=\"wp-block-heading\">listen on? (optional)<\/h1>\n<p>;local a.b.c.d<\/p>\n<h1 class=\"wp-block-heading\">Which TCP\/UDP port should OpenVPN listen on?<\/h1>\n<h1 class=\"wp-block-heading\">If you want to run multiple OpenVPN instances<\/h1>\n<h1 class=\"wp-block-heading\">on the same machine, use a different port<\/h1>\n<h1 class=\"wp-block-heading\">number for each one.&nbsp;&nbsp;You will need to<\/h1>\n<h1 class=\"wp-block-heading\">open up this port on your firewall.<\/h1>\n<p>port 1194<\/p>\n<h1 class=\"wp-block-heading\">TCP or UDP server?<\/h1>\n<p>proto tcp<\/p>\n<h1 class=\"wp-block-heading\">proto udp<\/h1>\n<h1 class=\"wp-block-heading\">\"dev tun\" will create a routed IP tunnel,<\/h1>\n<h1 class=\"wp-block-heading\">\"dev tap\" will create an ethernet tunnel.<\/h1>\n<h1 class=\"wp-block-heading\">Use \"dev tap0\" if you are ethernet bridging<\/h1>\n<h1 class=\"wp-block-heading\">and have precreated a tap0 virtual interface<\/h1>\n<h1 class=\"wp-block-heading\">and bridged it with your ethernet interface.<\/h1>\n<h1 class=\"wp-block-heading\">If you want to control access policies<\/h1>\n<h1 class=\"wp-block-heading\">over the VPN, you must create firewall<\/h1>\n<h1 class=\"wp-block-heading\">rules for the the TUN\/TAP interface.<\/h1>\n<h1 class=\"wp-block-heading\">On non-Windows systems, you can give<\/h1>\n<h1 class=\"wp-block-heading\">an explicit unit number, such as tun0.<\/h1>\n<h1 class=\"wp-block-heading\">On Windows, use \"dev-node\" for this.<\/h1>\n<h1 class=\"wp-block-heading\">On most systems, the VPN will not function<\/h1>\n<h1 class=\"wp-block-heading\">unless you partially or fully disable<\/h1>\n<h1 class=\"wp-block-heading\">the firewall for the TUN\/TAP interface.<\/h1>\n<p>;dev tap\ndev tun<\/p>\n<h1 class=\"wp-block-heading\">Windows needs the TAP-Win32 adapter name<\/h1>\n<h1 class=\"wp-block-heading\">from the Network Connections panel if you<\/h1>\n<h1 class=\"wp-block-heading\">have more than one.&nbsp;&nbsp;On XP SP2 or higher,<\/h1>\n<h1 class=\"wp-block-heading\">you may need to selectively disable the<\/h1>\n<h1 class=\"wp-block-heading\">Windows firewall for the TAP adapter.<\/h1>\n<h1 class=\"wp-block-heading\">Non-Windows systems usually don&#039;t need this.<\/h1>\n<p>;dev-node MyTap<\/p>\n<h1 class=\"wp-block-heading\">SSL\/TLS root certificate (ca), certificate<\/h1>\n<h1 class=\"wp-block-heading\">(cert), and private key (key).&nbsp;&nbsp;Each client<\/h1>\n<h1 class=\"wp-block-heading\">and the server must have their own cert and<\/h1>\n<h1 class=\"wp-block-heading\">key file.&nbsp;&nbsp;The server and all clients will<\/h1>\n<h1 class=\"wp-block-heading\">use the same ca file.<\/h1>\n<p>#<\/p>\n<h1 class=\"wp-block-heading\">See the \"easy-rsa\" directory for a series<\/h1>\n<h1 class=\"wp-block-heading\">of scripts for generating RSA certificates<\/h1>\n<h1 class=\"wp-block-heading\">and private keys.&nbsp;&nbsp;Remember to use<\/h1>\n<h1 class=\"wp-block-heading\">a unique Common Name for the server<\/h1>\n<h1 class=\"wp-block-heading\">and each of the client certificates.<\/h1>\n<p>#<\/p>\n<h1 class=\"wp-block-heading\">Any X509 key management system can be used.<\/h1>\n<h1 class=\"wp-block-heading\">OpenVPN can also use a PKCS #12 formatted key file<\/h1>\n<h1 class=\"wp-block-heading\">(see \"pkcs12\" directive in man page).<\/h1>\n<p>ca ca.crt\ncert server.crt\nkey server.key&nbsp;&nbsp;# This file should be kept secret<\/p>\n<h1 class=\"wp-block-heading\">Diffie hellman parameters.<\/h1>\n<h1 class=\"wp-block-heading\">Generate your own with:<\/h1>\n<p>#&nbsp;&nbsp; openssl dhparam -out dh1024.pem 1024<\/p>\n<h1 class=\"wp-block-heading\">Substitute 2048 for 1024 if you are using<\/h1>\n<h1 class=\"wp-block-heading\">2048 bit keys.<\/h1>\n<p>dh dh1024.pem<\/p>\n<h1 class=\"wp-block-heading\">Configure server mode and supply a VPN subnet<\/h1>\n<h1 class=\"wp-block-heading\">for OpenVPN to draw client addresses from.<\/h1>\n<h1 class=\"wp-block-heading\">The server will take 10.8.0.1 for itself,<\/h1>\n<h1 class=\"wp-block-heading\">the rest will be made available to clients.<\/h1>\n<h1 class=\"wp-block-heading\">Each client will be able to reach the server<\/h1>\n<h1 class=\"wp-block-heading\">on 10.8.0.1. Comment this line out if you are<\/h1>\n<h1 class=\"wp-block-heading\">ethernet bridging. See the man page for more info.<\/h1>\n<p>server 10.8.0.0 255.255.255.0<\/p>\n<h1 class=\"wp-block-heading\">Maintain a record of client  virtual IP address<\/h1>\n<h1 class=\"wp-block-heading\">associations in this file.&nbsp;&nbsp;If OpenVPN goes down or<\/h1>\n<h1 class=\"wp-block-heading\">is restarted, reconnecting clients can be assigned<\/h1>\n<h1 class=\"wp-block-heading\">the same virtual IP address from the pool that was<\/h1>\n<h1 class=\"wp-block-heading\">previously assigned.<\/h1>\n<p>ifconfig-pool-persist ipp.txt<\/p>\n<h1 class=\"wp-block-heading\">Configure server mode for ethernet bridging.<\/h1>\n<h1 class=\"wp-block-heading\">You must first use your OS&#039;s bridging capability<\/h1>\n<h1 class=\"wp-block-heading\">to bridge the TAP interface with the ethernet<\/h1>\n<h1 class=\"wp-block-heading\">NIC interface.&nbsp;&nbsp;Then you must manually set the<\/h1>\n<h1 class=\"wp-block-heading\">IP\/netmask on the bridge interface, here we<\/h1>\n<h1 class=\"wp-block-heading\">assume 10.8.0.4\/255.255.255.0.&nbsp;&nbsp;Finally we<\/h1>\n<h1 class=\"wp-block-heading\">must set aside an IP range in this subnet<\/h1>\n<h1 class=\"wp-block-heading\">(start=10.8.0.50 end=10.8.0.100) to allocate<\/h1>\n<h1 class=\"wp-block-heading\">to connecting clients.&nbsp;&nbsp;Leave this line commented<\/h1>\n<h1 class=\"wp-block-heading\">out unless you are ethernet bridging.<\/h1>\n<p>;server-bridge 10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100<\/p>\n<h1 class=\"wp-block-heading\">Configure server mode for ethernet bridging<\/h1>\n<h1 class=\"wp-block-heading\">using a DHCP-proxy, where clients talk<\/h1>\n<h1 class=\"wp-block-heading\">to the OpenVPN server-side DHCP server<\/h1>\n<h1 class=\"wp-block-heading\">to receive their IP address allocation<\/h1>\n<h1 class=\"wp-block-heading\">and DNS server addresses.&nbsp;&nbsp;You must first use<\/h1>\n<h1 class=\"wp-block-heading\">your OS&#039;s bridging capability to bridge the TAP<\/h1>\n<h1 class=\"wp-block-heading\">interface with the ethernet NIC interface.<\/h1>\n<h1 class=\"wp-block-heading\">Note: this mode only works on clients (such as<\/h1>\n<h1 class=\"wp-block-heading\">Windows), where the client-side TAP adapter is<\/h1>\n<h1 class=\"wp-block-heading\">bound to a DHCP client.<\/h1>\n<p>;server-bridge<\/p>\n<h1 class=\"wp-block-heading\">Push routes to the client to allow it<\/h1>\n<h1 class=\"wp-block-heading\">to reach other private subnets behind<\/h1>\n<h1 class=\"wp-block-heading\">the server.&nbsp;&nbsp;Remember that these<\/h1>\n<h1 class=\"wp-block-heading\">private subnets will also need<\/h1>\n<h1 class=\"wp-block-heading\">to know to route the OpenVPN client<\/h1>\n<h1 class=\"wp-block-heading\">address pool (10.8.0.0\/255.255.255.0)<\/h1>\n<h1 class=\"wp-block-heading\">back to the OpenVPN server.<\/h1>\n<p>push \"route 10.8.0.0 255.255.255.0\"\npush \"route 192.168.5.0 255.255.255.0\"\n;push \"route 192.168.20.0 255.255.255.0\"<\/p>\n<h1 class=\"wp-block-heading\">To assign specific IP addresses to specific<\/h1>\n<h1 class=\"wp-block-heading\">clients or if a connecting client has a private<\/h1>\n<h1 class=\"wp-block-heading\">subnet behind it that should also have VPN access,<\/h1>\n<h1 class=\"wp-block-heading\">use the subdirectory \"ccd\" for client-specific<\/h1>\n<h1 class=\"wp-block-heading\">configuration files (see man page for more info).<\/h1>\n<h1 class=\"wp-block-heading\">EXAMPLE: Suppose the client<\/h1>\n<h1 class=\"wp-block-heading\">having the certificate common name \"Thelonious\"<\/h1>\n<h1 class=\"wp-block-heading\">also has a small subnet behind his connecting<\/h1>\n<h1 class=\"wp-block-heading\">machine, such as 192.168.40.128\/255.255.255.248.<\/h1>\n<h1 class=\"wp-block-heading\">First, uncomment out these lines:<\/h1>\n<p>;client-config-dir ccd\n;route 192.168.40.128 255.255.255.248<\/p>\n<h1 class=\"wp-block-heading\">Then create a file ccd\/Thelonious with this line:<\/h1>\n<p>#&nbsp;&nbsp; iroute 192.168.40.128 255.255.255.248<\/p>\n<h1 class=\"wp-block-heading\">This will allow Thelonious&#039; private subnet to<\/h1>\n<h1 class=\"wp-block-heading\">access the VPN.&nbsp;&nbsp;This example will only work<\/h1>\n<h1 class=\"wp-block-heading\">if you are routing, not bridging, i.e. you are<\/h1>\n<h1 class=\"wp-block-heading\">using \"dev tun\" and \"server\" directives.<\/h1>\n<h1 class=\"wp-block-heading\">EXAMPLE: Suppose you want to give<\/h1>\n<h1 class=\"wp-block-heading\">Thelonious a fixed VPN IP address of 10.9.0.1.<\/h1>\n<h1 class=\"wp-block-heading\">First uncomment out these lines:<\/h1>\n<p>;client-config-dir ccd\n;route 10.9.0.0 255.255.255.252<\/p>\n<h1 class=\"wp-block-heading\">Then add this line to ccd\/Thelonious:<\/h1>\n<p>#&nbsp;&nbsp; ifconfig-push 10.9.0.1 10.9.0.2<\/p>\n<h1 class=\"wp-block-heading\">Suppose that you want to enable different<\/h1>\n<h1 class=\"wp-block-heading\">firewall access policies for different groups<\/h1>\n<h1 class=\"wp-block-heading\">of clients.&nbsp;&nbsp;There are two methods:<\/h1>\n<h1 class=\"wp-block-heading\">(1) Run multiple OpenVPN daemons, one for each<\/h1>\n<p>#&nbsp;&nbsp;&nbsp;&nbsp; group, and firewall the TUN\/TAP interface\n#&nbsp;&nbsp;&nbsp;&nbsp; for each group\/daemon appropriately.<\/p>\n<h1 class=\"wp-block-heading\">(2) (Advanced) Create a script to dynamically<\/h1>\n<p>#&nbsp;&nbsp;&nbsp;&nbsp; modify the firewall in response to access\n#&nbsp;&nbsp;&nbsp;&nbsp; from different clients.&nbsp;&nbsp;See man\n#&nbsp;&nbsp;&nbsp;&nbsp; page for more info on learn-address script.\n;learn-address .\/script<\/p>\n<h1 class=\"wp-block-heading\">If enabled, this directive will configure<\/h1>\n<h1 class=\"wp-block-heading\">all clients to redirect their default<\/h1>\n<h1 class=\"wp-block-heading\">network gateway through the VPN, causing<\/h1>\n<h1 class=\"wp-block-heading\">all IP traffic such as web browsing and<\/h1>\n<h1 class=\"wp-block-heading\">and DNS lookups to go through the VPN<\/h1>\n<h1 class=\"wp-block-heading\">(The OpenVPN server machine may need to NAT<\/h1>\n<h1 class=\"wp-block-heading\">or bridge the TUN\/TAP interface to the internet<\/h1>\n<h1 class=\"wp-block-heading\">in order for this to work properly).<\/h1>\n<p>;push \"redirect-gateway def1 bypass-dhcp\"\npush \"redirect-gateway\"<\/p>\n<h1 class=\"wp-block-heading\">Certain Windows-specific network settings<\/h1>\n<h1 class=\"wp-block-heading\">can be pushed to clients, such as DNS<\/h1>\n<h1 class=\"wp-block-heading\">or WINS server addresses.&nbsp;&nbsp;CAVEAT:<\/h1>\n<h1 class=\"wp-block-heading\"><a href=\"http:\/\/openvpn.net\/faq.html#dhcpcaveats\">http:\/\/openvpn.net\/faq.html#dhcpcaveats<\/a><\/h1>\n<h1 class=\"wp-block-heading\">The addresses below refer to the public<\/h1>\n<h1 class=\"wp-block-heading\">DNS servers provided by opendns.com.<\/h1>\n<p>push \"dhcp-option DNS 60.195.250.225\"\npush \"dhcp-option DNS 8.8.8.8\"<\/p>\n<h1 class=\"wp-block-heading\">Uncomment this directive to allow different<\/h1>\n<h1 class=\"wp-block-heading\">clients to be able to \"see\" each other.<\/h1>\n<h1 class=\"wp-block-heading\">By default, clients will only see the server.<\/h1>\n<h1 class=\"wp-block-heading\">To force clients to only see the server, you<\/h1>\n<h1 class=\"wp-block-heading\">will also need to appropriately firewall the<\/h1>\n<h1 class=\"wp-block-heading\">server&#039;s TUN\/TAP interface.<\/h1>\n<p>;client-to-client<\/p>\n<h1 class=\"wp-block-heading\">Uncomment this directive if multiple clients<\/h1>\n<h1 class=\"wp-block-heading\">might connect with the same certificate\/key<\/h1>\n<h1 class=\"wp-block-heading\">files or common names.&nbsp;&nbsp;This is recommended<\/h1>\n<h1 class=\"wp-block-heading\">only for testing purposes.&nbsp;&nbsp;For production use,<\/h1>\n<h1 class=\"wp-block-heading\">each client should have its own certificate\/key<\/h1>\n<h1 class=\"wp-block-heading\">pair.<\/h1>\n<p>#<\/p>\n<h1 class=\"wp-block-heading\">IF YOU HAVE NOT GENERATED INDIVIDUAL<\/h1>\n<h1 class=\"wp-block-heading\">CERTIFICATE\/KEY PAIRS FOR EACH CLIENT,<\/h1>\n<h1 class=\"wp-block-heading\">EACH HAVING ITS OWN UNIQUE \"COMMON NAME\",<\/h1>\n<h1 class=\"wp-block-heading\">UNCOMMENT THIS LINE OUT.<\/h1>\n<p>;duplicate-cn<\/p>\n<h1 class=\"wp-block-heading\">The keepalive directive causes ping-like<\/h1>\n<h1 class=\"wp-block-heading\">messages to be sent back and forth over<\/h1>\n<h1 class=\"wp-block-heading\">the link so that each side knows when<\/h1>\n<h1 class=\"wp-block-heading\">the other side has gone down.<\/h1>\n<h1 class=\"wp-block-heading\">Ping every 10 seconds, assume that remote<\/h1>\n<h1 class=\"wp-block-heading\">peer is down if no ping received during<\/h1>\n<h1 class=\"wp-block-heading\">a 120 second time period.<\/h1>\n<p>keepalive 10 120<\/p>\n<h1 class=\"wp-block-heading\">For extra security beyond that provided<\/h1>\n<h1 class=\"wp-block-heading\">by SSL\/TLS, create an \"HMAC firewall\"<\/h1>\n<h1 class=\"wp-block-heading\">to help block DoS attacks and UDP port flooding.<\/h1>\n<p>#<\/p>\n<h1 class=\"wp-block-heading\">Generate with:<\/h1>\n<p>#&nbsp;&nbsp; openvpn --genkey --secret ta.key\n#<\/p>\n<h1 class=\"wp-block-heading\">The server and each client must have<\/h1>\n<h1 class=\"wp-block-heading\">a copy of this key.<\/h1>\n<h1 class=\"wp-block-heading\">The second parameter should be &#039;0&#039;<\/h1>\n<h1 class=\"wp-block-heading\">on the server and &#039;1&#039; on the clients.<\/h1>\n<p>;tls-auth ta.key 0 # This file is secret<\/p>\n<h1 class=\"wp-block-heading\">Select a cryptographic cipher.<\/h1>\n<h1 class=\"wp-block-heading\">This config item must be copied to<\/h1>\n<h1 class=\"wp-block-heading\">the client config file as well.<\/h1>\n<p>;cipher BF-CBC&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Blowfish (default)\n;cipher AES-128-CBC&nbsp;&nbsp; # AES\n;cipher DES-EDE3-CBC&nbsp;&nbsp;# Triple-DES<\/p>\n<h1 class=\"wp-block-heading\">Enable compression on the VPN link.<\/h1>\n<h1 class=\"wp-block-heading\">If you enable it here, you must also<\/h1>\n<h1 class=\"wp-block-heading\">enable it in the client config file.<\/h1>\n<p>comp-lzo<\/p>\n<h1 class=\"wp-block-heading\">The maximum number of concurrently connected<\/h1>\n<h1 class=\"wp-block-heading\">clients we want to allow.<\/h1>\n<p>;max-clients 100<\/p>\n<h1 class=\"wp-block-heading\">It&#039;s a good idea to reduce the OpenVPN<\/h1>\n<h1 class=\"wp-block-heading\">daemon&#039;s privileges after initialization.<\/h1>\n<p>#<\/p>\n<h1 class=\"wp-block-heading\">You can uncomment this out on<\/h1>\n<h1 class=\"wp-block-heading\">non-Windows systems.<\/h1>\n<p>;user nobody\n;group nobody<\/p>\n<h1 class=\"wp-block-heading\">The persist options will try to avoid<\/h1>\n<h1 class=\"wp-block-heading\">accessing certain resources on restart<\/h1>\n<h1 class=\"wp-block-heading\">that may no longer be accessible because<\/h1>\n<h1 class=\"wp-block-heading\">of the privilege downgrade.<\/h1>\n<p>persist-key\npersist-tun<\/p>\n<h1 class=\"wp-block-heading\">Output a short status file showing<\/h1>\n<h1 class=\"wp-block-heading\">current connections, truncated<\/h1>\n<h1 class=\"wp-block-heading\">and rewritten every minute.<\/h1>\n<p>status openvpn-status.log<\/p>\n<h1 class=\"wp-block-heading\">By default, log messages will go to the syslog (or<\/h1>\n<h1 class=\"wp-block-heading\">on Windows, if running as a service, they will go to<\/h1>\n<h1 class=\"wp-block-heading\">the \"&#092;Program Files&#092;OpenVPN&#092;log\" directory).<\/h1>\n<h1 class=\"wp-block-heading\">Use log or log-append to override this default.<\/h1>\n<h1 class=\"wp-block-heading\">\"log\" will truncate the log file on OpenVPN startup,<\/h1>\n<h1 class=\"wp-block-heading\">while \"log-append\" will append to it.&nbsp;&nbsp;Use one<\/h1>\n<h1 class=\"wp-block-heading\">or the other (but not both).<\/h1>\n<p>;log&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; openvpn.log\n;log-append&nbsp;&nbsp;openvpn.log<\/p>\n<h1 class=\"wp-block-heading\">Set the appropriate level of log<\/h1>\n<h1 class=\"wp-block-heading\">file verbosity.<\/h1>\n<p>#<\/p>\n<h1 class=\"wp-block-heading\">0 is silent, except for fatal errors<\/h1>\n<h1 class=\"wp-block-heading\">4 is reasonable for general usage<\/h1>\n<h1 class=\"wp-block-heading\">5 and 6 can help to debug connection problems<\/h1>\n<h1 class=\"wp-block-heading\">9 is extremely verbose<\/h1>\n<p>verb 3<\/p>\n<h1 class=\"wp-block-heading\">Silence repeating messages.&nbsp;&nbsp;At most 20<\/h1>\n<h1 class=\"wp-block-heading\">sequential messages of the same message<\/h1>\n<h1 class=\"wp-block-heading\">category will be output to the log.<\/h1>\n<p>;mute 20<\/pre>\n<br \/><br \/>vi \/etc\/sysctl.conf\u3002\u5728\u6700\u4e0b\u9762\u52a0\u5165\u5982\u4e0b\u5185\u5bb9\u3002<br \/>\u5982\u679c\u662fRHEL5\uff0c\u5efa\u8bae\u628a\u4ee5#\u5c4f\u853d\u7684\u9009\u9879\u5168\u6253\u5f00\u3002\u662f\u7167\u67d0\u516c\u53f8\u4e45\u7ecf\u8003\u9a8c\u7684\u6587\u6863\u5199\u7684\u3002<br \/>\u636e\u795e\u79d8\u7684\u8001\u718a\u5206\u4eab\uff0c\u5728RHEL6\u4e0b\u5e94\u8be5\u628a\u90a3\u4e00\u5806\u53c2\u6570\u5c4f\u853d\u3002\u6211\u5728centos 6\u4e0b\uff0c\u5df2\u7ecf\u7167\u6b64\u914d\u7f6e\u6d4b\u8bd5\u901a\u8fc7\u4e86\u3002<br \/><br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\"># Added for&nbsp;&nbsp;openvpn.&nbsp;&nbsp; esojourn.org\nnet.ipv6.conf.eth0.forwarding = 1\nnet.ipv6.conf.default.forwarding = 1\nnet.ipv6.conf.all.forwarding = 1\nnet.ipv6.conf.lo.forwarding = 1<\/p>\n<h1 class=\"wp-block-heading\">net.ipv4.conf.tun0.mc_forwarding = 1<\/h1>\n<h1 class=\"wp-block-heading\">net.ipv4.conf.tun0.forwarding = 1<\/h1>\n<h1 class=\"wp-block-heading\">net.ipv4.conf.eth0.mc_forwarding = 1<\/h1>\n<p>net.ipv4.conf.eth0.forwarding = 1<\/p>\n<h1 class=\"wp-block-heading\">net.ipv4.conf.lo.mc_forwarding = 1<\/h1>\n<p>net.ipv4.conf.lo.forwarding = 1<\/p>\n<h1 class=\"wp-block-heading\">net.ipv4.conf.default.mc_forwarding = 1<\/h1>\n<p>net.ipv4.conf.default.forwarding = 1<\/p>\n<h1 class=\"wp-block-heading\">net.ipv4.conf.all.mc_forwarding = 1<\/h1>\n<p>net.ipv4.conf.all.forwarding = 1<\/p>\n<h1 class=\"wp-block-heading\">net.ipv4.ip_forward = 1<\/h1>\n<dl>\n<dt><\/pre><\/dt>\n<dt><br \/><br \/>sysctl -p\u4f7f\u89c4\u5219\u751f\u6548<br \/><br \/>vi \/etc\/sysconfig\/iptables \u5728\u6700\u4e0a\u9762\u52a0\u4e0bnat\u8868<br \/>\u8bf8\u4f4d\u65b0\u624b\u3001\u51c6\u65b0\u624b\u4eec\uff0c\u5343\u4e07\u522b\u7528\u5929\u6740\u7684setup\u6216\u8005system-config-firewall\u6765\u914d\u9632\u706b\u5899\u4e86\u3002<br \/>\u8840\u6cea\u53f2\u554a\uff0c\u4e0d\u591a\u89e3\u91ca\u4e86\u3002\u597d\u597d\u5b66\u57fa\u672c\u529f\u5427\u3002\u6211\u4e5f\u5728\u5b66\u4e60\u4e2d\u3002<br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">*nat<\/dt>\n<dd>PREROUTING ACCEPT &#x5B;0:0]<\/dd>\n<dd>POSTROUTING ACCEPT &#x5B;0:0]<\/dd>\n<dd>OUTPUT ACCEPT &#x5B;0:0]\n-A POSTROUTING -s 10.8.0.0\/24 -o eth0 -j MASQUERADE\nCOMMIT<\/pre>\n<br \/>\u7136\u540e\u5728\u4e0b\u9762<em>filter\u8868\u91cc\uff0c\u6700\u540e\u4e00\u6761\u62d2\u7edd\u89c4\u5219\u524d\u9762\uff0c\u52a0\u4e0a<br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">-A FORWARD -d 10.8.0.0\/24 -j ACCEPT\n-A FORWARD -s 10.8.0.0\/24 -j ACCEPT<\/pre>\n<br \/><br \/>service iptables restart<br \/><br \/><span style=\"font-size: 18px\">3. \u751f\u6210\u670d\u52a1\u5668\u7aef\u8bc1\u4e66<\/span>\n<br \/>\u751f\u6210\u670d\u52a1\u5668\u7aef\u8bc1\u4e66\u4e3b\u8981\u6709\u5982\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a<br \/>1\uff0e \u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<br \/>2\uff0e \u751f\u6210ca\u6587\u4ef6<br \/>3\uff0e \u751f\u6210cert\/key\u6587\u4ef6<br \/>4\uff0e \u751f\u6210dh\u6587\u4ef6<br \/><br \/>\u8fdb\u5165openvpn\u7684\u5bf9\u5e94\u5b89\u88c5\u76ee\u5f55\u3002\u5c06\u6240\u6709\u811a\u672c\u8bbe\u7f6e\u4e3a\u53ef\u6267\u884c\u5c5e\u6027<br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">cd \/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa\nchmod 700 build<\/em><\/pre>\n<br \/><br \/>vi \/etc\/bashrc\uff0c\u5728\u6700\u4e0b\u9762\u52a0\u4e0a\u73af\u5883\u53d8\u91cf<br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\"># Add for openvpn\nexport KEY_CONFIG=\/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa\/openssl.cnf\nexport KEY_DIR=\/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa\/keys\nexport KEY_SIZE=1024\nexport KEY_COUNTRY=CN\nexport KEY_PROVINCE=BJ\nexport KEY_CITY=BJ\nexport KEY_ORG=\"www.esojourn.org\"\nexport KEY_EMAIL=\"&#x5B;email]abc@esojourn.org&#x5B;\/email]\"\n<\/pre>\n<br \/><br \/>\u5efa\u7acb\u5b58\u653ekey\u7684\u76ee\u5f55 mkdir cd \/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa\/keys<br \/>\u901a\u8fc7clean-all\u751f\u6210serial\u548cindex.txt<br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">chmod 700 clean-all\n.\/clean-all<\/pre>\n<br \/><br \/>\u5f00\u59cb\u751f\u6210ca\u6587\u4ef6\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cca\u4e00\u65e6\u751f\u6210\u5c31\u4e0d\u80fd\u66f4\u6362\u4e86\uff0c\u5426\u5219\u6240\u6709key\u90fd\u4f1a\u5931\u6548\uff0c\u8981\u91cd\u65b0\u7b7e\u7f72\u3002<br \/><br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;root@esojourn.org \/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa]# .\/build-ca\nGenerating a 1024 bit RSA private key\n..............................................................................................++++++\n..........++++++\nwriting new private key to &#039;ca.key&#039;\n-----\nYou are about to be asked to enter information that will be incorporated\ninto your certificate request.\nWhat you are about to enter is what is called a Distinguished Name or a DN.\nThere are quite a few fields but you can leave some blank\nFor some fields there will be a default value,\nIf you enter &#039;.&#039;, the field will be left blank.\n-----\nCountry Name (2 letter code) &#x5B;CN]:\nState or Province Name (full name) &#x5B;BJ]:\nLocality Name (eg, city) &#x5B;BJ]:\nOrganization Name (eg, company) &#x5B;esojourn.org]:\nOrganizational Unit Name (eg, section) &#x5B;]:\nCommon Name (eg, your name or your server&#039;s hostname) &#x5B;]:\nEmail Address &#x5B;&#x5B;email]pcman@esojourn.org&#x5B;\/email]]:\n&#x5B;root@esojourn.org \/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa]#\n<\/pre>\n<br \/><br \/>\u751f\u6210server\u7aefkey\u548ccrt\u6587\u4ef6\u3002\u6ce8\u610f\uff0c<strong>\u5176\u4e2dCommon Name\u9879\u76ee\u5fc5\u987b\u586b\u5199<\/strong>\uff0c\u5176\u4f59\u9879\u76ee\u53ef\u76f4\u63a5\u6309\u56de\u8f66\u4f7f\u7528\u73af\u5883\u53d8\u91cf\u9884\u5148\u8bbe\u7f6e\u7684\u9ed8\u8ba4\u503c\u3002<br \/><br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;root@esojourn.org \/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa]# .\/build-key-server server\nGenerating a 1024 bit RSA private key\n............++++++\n..........++++++\nwriting new private key to &#039;server.key&#039;\n-----\nYou are about to be asked to enter information that will be incorporated\ninto your certificate request.\nWhat you are about to enter is what is called a Distinguished Name or a DN.\nThere are quite a few fields but you can leave some blank\nFor some fields there will be a default value,\nIf you enter &#039;.&#039;, the field will be left blank.\n-----\nCountry Name (2 letter code) &#x5B;CN]:\nState or Province Name (full name) &#x5B;BJ]:\nLocality Name (eg, city) &#x5B;BJ]:\nOrganization Name (eg, company) &#x5B;esojourn.org]:\nOrganizational Unit Name (eg, section) &#x5B;]:\nCommon Name (eg, your name or your server&#039;s hostname) &#x5B;]:openvpn.esojourn.org\nEmail Address &#x5B;&#x5B;email]pcman@esojourn.org&#x5B;\/email]]:\nPlease enter the following &#039;extra&#039; attributes\nto be sent with your certificate request\nA challenge password &#x5B;]:\nAn optional company name &#x5B;]:\nUsing configuration from \/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa\/openssl.cnf\nCheck that the request matches the signature\nSignature ok\nThe Subject&#039;s Distinguished Name is as follows\ncountryName :PRINTABLE:&#039;CN&#039;\nstateOrProvinceName :PRINTABLE:&#039;BJ&#039;\nlocalityName :PRINTABLE:&#039;BJ&#039;\norganizationName :PRINTABLE:&#039;esojourn.org&#039;\ncommonName :PRINTABLE:&#039;openvpn.esojourn.org&#039;\nemailAddress :IA5STRING:&#039;&#x5B;email]pcman@esojourn.org&#x5B;\/email]&#039;\nCertificate is to be certified until Jul 13 16:17:39 2017 GMT (3650 days)\nSign the certificate? &#x5B;y\/n]:y\n1 out of 1 certificate requests certified, commit? &#x5B;y\/n]y\nWrite out database with 1 new entries\nData Base Updated\n&#x5B;root@esojourn.org \/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa]#\n<\/pre>\n<br \/><br \/>\u8bc1\u4e66\u751f\u6210\u5b8c\u6bd5\u3002\u751f\u6210dh\u6587\u4ef6\u3002<br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;root@esojourn.org \/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa]# .\/build-dh\nGenerating DH parameters, 1024 bit long safe prime, generator 2\nThis is going to take a long time\n..............................+........................................................................................................+.......................................................+.........................................................<\/pre>\n<br \/><br \/>\u73b0\u5728\u5c06\u521a\u624d\u751f\u6210\u7684\u8bc1\u4e66\u548c\u914d\u7f6e\u6587\u4ef6\u590d\u5236\u5230\u76f8\u5e94\u76ee\u5f55\u4e0b\u3002<br \/><br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;root@esojourn.org \/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa]# cp keys\/ca.crt \/etc\/openvpn\/\n&#x5B;root@esojourn.org \/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa]# cp keys\/server.crt \/etc\/openvpn\/\n&#x5B;root@esojourn.org \/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa]# cp keys\/server.key \/etc\/openvpn\/\n&#x5B;root@esojourn.org \/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa]# cp keys\/dh1024.pem \/etc\/openvpn\/\nsysctl -p<\/pre>\n<br \/><br \/><span style=\"font-size: 18px\">4. \u521b\u5efa\u65b0\u7684\u5ba2\u6237\u7aef<\/span>\n<br \/>openvpn\u670d\u52a1\u5668\u914d\u7f6e\u597d\u4e4b\u540e\uff0c\u65b0\u7684\u5ba2\u6237\u7aef\u8fd8\u4e0d\u80fd\u7acb\u523b\u8fde\u63a5\u8fdb\u6765\uff0c\u9700\u8981\u4e3a\u5ba2\u6237\u7aef\u5206\u522b\u521b\u5efa\u5c5e\u4e8e\u81ea\u5df1\u7684ssl\u8bc1\u4e66\u65b9\u53ef\u3002\u521b\u5efa\u7684\u65b9\u5f0f\u5982\u4e0b\uff1a<br \/>\u8fdb\u5165openvpn\u7684\u5bf9\u5e94\u5b89\u88c5\u76ee\u5f55\u3002\u751f\u6210\u8bc1\u4e66\u6587\u4ef6\u3002\u6ce8\u610f\uff0c\u5728\u63d0\u793a\u8f93\u5165CommonName\u7684\u65f6\u5019\uff0c\u5fc5\u987b\u8f93\u5165\u552f\u4e00\u4e00\u4e2a\u7528\u6237\u540d\u540d\u5b57\u6216\u8005\u57df\u540d\uff0c\u4ee5\u548c\u5176\u4ed6\u7684\u7528\u6237\u8bc1\u4e66\u76f8\u533a\u522b\u3002<br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">cd \/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa&#x5B;root@esojourn.org \/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa]# .\/build-key client\nGenerating a 1024 bit RSA private key\n....++++++\n.......++++++\nwriting new private key to &#039;client.key&#039;\n-----\nYou are about to be asked to enter information that will be incorporated\ninto your certificate request.\nWhat you are about to enter is what is called a Distinguished Name or a DN.\nThere are quite a few fields but you can leave some blank\nFor some fields there will be a default value,\nIf you enter &#039;.&#039;, the field will be left blank.\n-----\nCountry Name (2 letter code) &#x5B;CN]:\nState or Province Name (full name) &#x5B;BJ]:\nLocality Name (eg, city) &#x5B;BJ]:\nOrganization Name (eg, company) &#x5B;esojourn.org]:\nOrganizational Unit Name (eg, section) &#x5B;]:\nCommon Name (eg, your name or your server&#039;s hostname) &#x5B;]:pcman\nEmail Address &#x5B;&#x5B;email]pcman@esojourn.org&#x5B;\/email]]:\nPlease enter the following &#039;extra&#039; attributes\nto be sent with your certificate request\nA challenge password &#x5B;]:\nAn optional company name &#x5B;]:\nUsing configuration from \/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa\/openssl.cnf\nCheck that the request matches the signature\nSignature ok\nThe Subject&#039;s Distinguished Name is as follows\ncountryName :PRINTABLE:&#039;CN&#039;\nstateOrProvinceName :PRINTABLE:&#039;BJ&#039;\nlocalityName :PRINTABLE:&#039;BJ&#039;\norganizationName :PRINTABLE:&#039;esojourn.org&#039;\ncommonName :PRINTABLE:&#039;pcman&#039;\nemailAddress :IA5STRING:&#039;&#x5B;email]pcman@esojourn.org&#x5B;\/email]&#039;\nCertificate is to be certified until Jul 13 17:08:27 2017 GMT (3650 days)\nSign the certificate? &#x5B;y\/n]:y\n1 out of 1 certificate requests certified, commit? &#x5B;y\/n]y\nWrite out database with 1 new entries\nData Base Updated\n&#x5B;root@esojourn.org \/usr\/share\/doc\/openvpn-2.2.2\/easy-rsa]#<\/pre>\n<br \/><br \/>\u751f\u6210\u5b8c\u6bd5\u3002\u5728keys\u76ee\u5f55\u4e0b\u5373\u53ef\u627e\u5230client.key\u548cclient.crt\u3002<br \/><br \/><span style=\"font-size: 24px\">\u4e0b\u9762\u518d\u6765\u770b\u770b\u5ba2\u6237\u7aef<\/span>\n<br \/><span style=\"font-size: 18px\">5. \u5ba2\u6237\u7aef\u7684\u4e0b\u8f7d\u5b89\u88c5<\/span>\n<br \/>\u5b98\u7f51\u4e0b\u8f7d <a href=\"http:\/\/openvpn.net\/index.php\/download.html\">http:\/\/openvpn.net\/index.php\/download.html<\/a><br \/>Windows Installer v2.2.2\uff1a<a href=\"http:\/\/swupdate.openvpn.org\/community\/releases\/openvpn-2.2.2-install.exe\">http:\/\/swupdate.openvpn.org\/community\/releases\/openvpn-2.2.2-install.exe<\/a><br \/><br \/>\u5b89\u88c5\u65f6\u6240\u6709\u7ec4\u4ef6\u5168\u88c5\u3002\u5b89\u88c5\u65f6\u4f1a\u88c5\u4e0a\u4e00\u4e2a\u865a\u62df\u7f51\u5361\uff0c\u7cfb\u7edf\u53ef\u80fd\u4f1a\u63d0\u793a\u4e0d\u517c\u5bb9\uff0c\u4e0d\u5b89\u5168\u4ec0\u4e48\u7684\u3002\u4e0d\u7528\u7ba1\uff0c\u7ee7\u7eed\u786e\u5b9a\u5b89\u88c5\u5373\u53ef\u3002<br \/><br \/><span style=\"font-size: 18px\">6. \u521d\u59cb\u5316<\/span>\n<br \/>OpenVPN\u7684\u6570\u636e\u4f20\u8f93\u8fc7\u7a0b\u662f\u57fa\u4e8eOpenSSL\u5b89\u5168\u52a0\u5bc6\u7684\uff0c\u901a\u4fe1\u7684\u53cc\u65b9\uff1aVPN\u670d\u52a1\u5668\u7aef\u3001VPN\u5ba2\u6237\u7aef\u90fd\u9700\u8981IP\u5b89\u5168\u8bc1\u4e66\uff0c\u5426\u5219\u65e0\u6cd5\u5efa\u7acb\u8fde\u63a5\u3002IP\u8bc1\u4e66\u4e5f\u662f\u5efa\u7acb\u8fde\u63a5\u7684\u5fc5\u987b\u6761\u4ef6\uff0c\u57fa\u4e8eOpenVPN\u7684VPN\u5efa\u7acb\u662f\u6ca1\u6709\u4f20\u7edf\u5bc6\u7801\u9a8c\u8bc1\u7684\u3002\u4e0b\u8fb9\u914d\u7f6e\u8bc1\u4e66\u3002<br \/><br \/>\u9996\u5148\u83b7\u5f97\u8bc1\u4e66\u3002\u628a\u521a\u624d\u5347\u6210\u7684\u5ba2\u6237\u7aef\u8bc1\u4e66\u62f7\u8fc7\u6765\u30023\u4e2a\u6587\u4ef6! ca.crt, client.crt, client.key\u3002<br \/>\u53e6\u5916\u65b0\u5efa\u4e00\u4e2aesojourn.org.ovpn\u7684\u6587\u4ef6\uff0c\u7528\u4e8e\u5ba2\u6237\u7aef\u914d\u7f6e\u3002\u5305\u542b\u8bc1\u4e66\u6587\u4ef6\u540d\u3001\u5730\u5740\u7b49\u76f8\u5e94\u53c2\u6570\u3002ca.crt\u662f\u5168\u5c40\u7684CA\u8bc1\u4e66\uff0c\u800cclient.crt\u548cclient.key\u5219\u662f\u9881\u53d1\u7ed9\u6bcf\u4e2a\u4eba\u7684\u4e2a\u4eba\u8bc1\u4e66\u3002\u6bcf\u4e2a\u4eba\u7684\u4e2a\u4eba\u8bc1\u4e66\u6587\u4ef6\u4e0d\u4e00\u6837\uff0c\u800c\u53e6\u5916\u4e24\u4e2a\u6587\u4ef6\u5219\u4e00\u6837\u3002<br \/><br \/>ovpn\u6587\u4ef6\u5982\u4e0b\uff0c\u5176\u4ed6ca ca.crt\uff0ccert client.crt\uff0ckey client.key\uff0c\u6839\u636e\u81ea\u5df1\u7684\u6587\u4ef6\u540d\u6539\u3002<br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n##############################################\n# Sample client-side OpenVPN 2.0 config file #\n# for connecting to multi-client server.&nbsp;&nbsp;&nbsp;&nbsp; #\n#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\n# This configuration can be used by multiple #\n# clients, however each client should have&nbsp;&nbsp; #\n# its own cert and key files.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\n#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\n# On Windows, you might want to rename this&nbsp;&nbsp;#\n# file so it has a .ovpn extension&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #\n##############################################<\/dd>\n<\/dl>\n<h1 class=\"wp-block-heading\">Specify that we are a client and that we<\/h1>\n<h1 class=\"wp-block-heading\">will be pulling certain config file directives<\/h1>\n<h1 class=\"wp-block-heading\">from the server.<\/h1>\n<p>client<\/p>\n<h1 class=\"wp-block-heading\">Use the same setting as you are using on<\/h1>\n<h1 class=\"wp-block-heading\">the server.<\/h1>\n<h1 class=\"wp-block-heading\">On most systems, the VPN will not function<\/h1>\n<h1 class=\"wp-block-heading\">unless you partially or fully disable<\/h1>\n<h1 class=\"wp-block-heading\">the firewall for the TUN\/TAP interface.<\/h1>\n<p>;dev tap\ndev tun<\/p>\n<h1 class=\"wp-block-heading\">Windows needs the TAP-Win32 adapter name<\/h1>\n<h1 class=\"wp-block-heading\">from the Network Connections panel<\/h1>\n<h1 class=\"wp-block-heading\">if you have more than one.&nbsp;&nbsp;On XP SP2,<\/h1>\n<h1 class=\"wp-block-heading\">you may need to disable the firewall<\/h1>\n<h1 class=\"wp-block-heading\">for the TAP adapter.<\/h1>\n<p>;dev-node MyTap<\/p>\n<h1 class=\"wp-block-heading\">Are we connecting to a TCP or<\/h1>\n<h1 class=\"wp-block-heading\">UDP server?&nbsp;&nbsp;Use the same setting as<\/h1>\n<h1 class=\"wp-block-heading\">on the server.<\/h1>\n<p>proto tcp<\/p>\n<h1 class=\"wp-block-heading\">proto udp<\/h1>\n<h1 class=\"wp-block-heading\">The hostname\/IP and port of the server.<\/h1>\n<h1 class=\"wp-block-heading\">You can have multiple remote entries<\/h1>\n<h1 class=\"wp-block-heading\">to load balance between the servers.<\/h1>\n<p>remote www.esojourn.org 1194\n;remote my-server-2 1194<\/p>\n<h1 class=\"wp-block-heading\">Choose a random host from the remote<\/h1>\n<h1 class=\"wp-block-heading\">list for load-balancing.&nbsp;&nbsp;Otherwise<\/h1>\n<h1 class=\"wp-block-heading\">try hosts in the order specified.<\/h1>\n<p>;remote-random<\/p>\n<h1 class=\"wp-block-heading\">Keep trying indefinitely to resolve the<\/h1>\n<h1 class=\"wp-block-heading\">host name of the OpenVPN server.&nbsp;&nbsp;Very useful<\/h1>\n<h1 class=\"wp-block-heading\">on machines which are not permanently connected<\/h1>\n<h1 class=\"wp-block-heading\">to the internet such as laptops.<\/h1>\n<p>resolv-retry infinite<\/p>\n<h1 class=\"wp-block-heading\">Most clients don&#039;t need to bind to<\/h1>\n<h1 class=\"wp-block-heading\">a specific local port number.<\/h1>\n<p>nobind<\/p>\n<h1 class=\"wp-block-heading\">Downgrade privileges after initialization (non-Windows only)<\/h1>\n<p>;user nobody\n;group nobody<\/p>\n<h1 class=\"wp-block-heading\">Try to preserve some state across restarts.<\/h1>\n<p>persist-key\npersist-tun<\/p>\n<h1 class=\"wp-block-heading\">If you are connecting through an<\/h1>\n<h1 class=\"wp-block-heading\">HTTP proxy to reach the actual OpenVPN<\/h1>\n<h1 class=\"wp-block-heading\">server, put the proxy server\/IP and<\/h1>\n<h1 class=\"wp-block-heading\">port number here.&nbsp;&nbsp;See the man page<\/h1>\n<h1 class=\"wp-block-heading\">if your proxy server requires<\/h1>\n<h1 class=\"wp-block-heading\">authentication.<\/h1>\n<p>;http-proxy-retry # retry on connection failures\n;http-proxy &#x5B;proxy server] &#x5B;proxy port #]<\/p>\n<h1 class=\"wp-block-heading\">Wireless networks often produce a lot<\/h1>\n<h1 class=\"wp-block-heading\">of duplicate packets.&nbsp;&nbsp;Set this flag<\/h1>\n<h1 class=\"wp-block-heading\">to silence duplicate packet warnings.<\/h1>\n<p>;mute-replay-warnings<\/p>\n<h1 class=\"wp-block-heading\">SSL\/TLS parms.<\/h1>\n<h1 class=\"wp-block-heading\">See the server config file for more<\/h1>\n<h1 class=\"wp-block-heading\">description.&nbsp;&nbsp;It&#039;s best to use<\/h1>\n<h1 class=\"wp-block-heading\">a separate .crt\/.key file pair<\/h1>\n<h1 class=\"wp-block-heading\">for each client.&nbsp;&nbsp;A single ca<\/h1>\n<h1 class=\"wp-block-heading\">file can be used for all clients.<\/h1>\n<p>ca ca.crt\ncert client.crt\nkey client.key<\/p>\n<h1 class=\"wp-block-heading\">Verify server certificate by checking<\/h1>\n<h1 class=\"wp-block-heading\">that the certicate has the nsCertType<\/h1>\n<h1 class=\"wp-block-heading\">field set to \"server\".&nbsp;&nbsp;This is an<\/h1>\n<h1 class=\"wp-block-heading\">important precaution to protect against<\/h1>\n<h1 class=\"wp-block-heading\">a potential attack discussed here:<\/h1>\n<p>#&nbsp;&nbsp;<a href=\"http:\/\/openvpn.net\/howto.html#mitm\">http:\/\/openvpn.net\/howto.html#mitm<\/a>\n#<\/p>\n<h1 class=\"wp-block-heading\">To use this feature, you will need to generate<\/h1>\n<h1 class=\"wp-block-heading\">your server certificates with the nsCertType<\/h1>\n<h1 class=\"wp-block-heading\">field set to \"server\".&nbsp;&nbsp;The build-key-server<\/h1>\n<h1 class=\"wp-block-heading\">script in the easy-rsa folder will do this.<\/h1>\n<p>ns-cert-type server<\/p>\n<h1 class=\"wp-block-heading\">If a tls-auth key is used on the server<\/h1>\n<h1 class=\"wp-block-heading\">then every client must also have the key.<\/h1>\n<p>;tls-auth ta.key 1<\/p>\n<h1 class=\"wp-block-heading\">Select a cryptographic cipher.<\/h1>\n<h1 class=\"wp-block-heading\">If the cipher option is used on the server<\/h1>\n<h1 class=\"wp-block-heading\">then you must also specify it here.<\/h1>\n<p>;cipher x<\/p>\n<h1 class=\"wp-block-heading\">Enable compression on the VPN link.<\/h1>\n<h1 class=\"wp-block-heading\">Don&#039;t enable this unless it is also<\/h1>\n<h1 class=\"wp-block-heading\">enabled in the server config file.<\/h1>\n<p>comp-lzo<\/p>\n<h1 class=\"wp-block-heading\">Set log file verbosity.<\/h1>\n<p>verb 3<\/p>\n<h1 class=\"wp-block-heading\">Silence repeating messages<\/h1>\n<p>;mute 20\n<\/pre>\n<br \/><br \/><br \/>\u5c06\u8fd9\u51e0\u4e2a\u6587\u4ef6\u5168\u90e8\u590d\u5236\u5230OpenVPN\u7684\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684\u201cconfig\u201d\u76ee\u5f55\u4e2d\u3002\u5982\uff1aC:&#092;Program Files&#092;OpenVPN&#092;config<br \/><br \/>\u914d\u7f6e\u5b8c\u6210\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u4ee5CentOS 6 \u4f5c\u4e3aOpenVPN\u670d\u52a1\u5668\uff0cWIN XP\u53caWIN 7\u4f5c\u4e3a\u5ba2\u6237\u7aef\u64cd\u4f5c\u7cfb\u7edf\u3002\u4ee5\u4e0b\u5185\u5bb9\u5927\u91cf\u501f\u9274 &hellip; <a href=\"https:\/\/dingxuan.info\/wp\/?p=405\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">OpenVPN\u670d\u52a1\u5668\u53ca\u5ba2\u6237\u7aef\u914d\u7f6e<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[117],"tags":[78,110],"class_list":["post-405","post","type-post","status-publish","format-standard","hentry","category-network","tag-linux","tag-vpn"],"_links":{"self":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=405"}],"version-history":[{"count":0,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/405\/revisions"}],"wp:attachment":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}