{"id":193817,"date":"2011-11-03T13:02:00","date_gmt":"2011-11-03T20:02:00","guid":{"rendered":"http:\/\/chinadigitaltimes.net\/chinese\/2011\/11\/%e7%bf%bb%e5%a2%99-openvz-vps-%e9%85%8d%e7%bd%ae-openvpn\/"},"modified":"2011-11-03T13:02:00","modified_gmt":"2011-11-03T20:02:00","slug":"%e7%bf%bb%e5%a2%99-openvz-vps-%e9%85%8d%e7%bd%ae-openvpn","status":"publish","type":"post","link":"https:\/\/chinadigitaltimes.net\/chinese\/193817.html","title":{"rendered":"\u7ffb\u5899 | OpenVZ VPS \u914d\u7f6e OpenVPN"},"content":{"rendered":"<p><p>\u6765\u6e90\uff1a<a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/igfw.tk\/archives\/6129\">http:\/\/igfw.tk\/archives\/6129<\/a><\/p>\n<p>\u524d\u4e24\u5929\u5728hellohost\u4e0a\u8d2d\u4e70\u4e86\u4e00\u6b3e128\u5185\u5b58\u7684linux VPS\uff0c\u65e0\u5948\u53d1\u73b0LNMP\u4e00\u952e\u5305\u88c5\u4e0d\u4e0a\uff0cLAMP\u88c5\u4e0a\u540e\u5185\u5b58\u76f4\u63a5\u7206\u6ee1\uff0c\u8fde\u767b\u5f55\u90fd\u767b\u9646\u4e0d\u4e86\u4e86\uff0c\u5c0f\u5185\u5b58\u7684VPS\u4f24\u4e0d\u8d77\u554a\uff0c\u53ea\u597d\u7528\u6765\u914d\u7f6eVPN\u548cSSH\u7528\u6765\u505a\u4e00\u4e9b\u7279\u6b8a\u7528\u9014\uff0c\u800cOpenVZ VPS\u8c8c\u4f3c\u53ea\u80fd\u914d\u7f6eopenvpn \u3002<\/p>\n<div>\u9996\u5148\u8054\u7cfb\u4f60\u7684VPS\u670d\u52a1\u5546\u8ba9\u4ed6\u628aTUN\/TAP\u529f\u80fd\u6253\u5f00\uff0c\u9ed8\u8ba4\u5927\u90e8\u5206\u90fd\u662f\u5173\u95ed\u7684\uff0c\u4f60\u53ef\u4ee5\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u6d4b\uff1a<br \/>cat \/dev\/net\/tun<br \/>\u82e5\u8fd4\u56de\u4ee5\u4e0b\u7ed3\u679c\u8868\u793aOK<br \/>cat: \/dev\/net\/tun: File descriptor in bad state<\/div>\n<div><span><\/span><\/div>\n<h2>\u5b89\u88c5openvpn<\/h2>\n<div>1\u3001\u6dfb\u52a0\u6e90<\/div>\n<blockquote>\n<div>rpm -Uvh <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/download.fedora.redhat.com\/pub\/epel\/5\/i386\/epel-release-5-4.noarch.rpm\">http:\/\/download.fedora.redhat.com\/pub\/epel\/5\/i386\/epel-release-5-4.noarch.rpm<\/a><\/div>\n<\/blockquote>\n<div>2\u3001\u5b89\u88c5<\/div>\n<blockquote>\n<div>yum -y install openvpn<\/div>\n<\/blockquote>\n<div>3\u3001\u5c06easy-rsa\u79fb\u52a8\u5230\u4e00\u4e2a\u65b9\u4fbf\u64cd\u4f5c\u7684\u4f4d\u7f6e\u3002<\/div>\n<blockquote>\n<div>cp -R \/usr\/share\/openvpn\/easy-rsa \/etc\/openvpn\/<\/div>\n<\/blockquote>\n<div>4\u3001\u8fdb\u5165\u76ee\u5f55<\/div>\n<blockquote>\n<div>cd \/etc\/openvpn\/easy-rsa\/2.0<\/div>\n<\/blockquote>\n<h2>\u751f\u6210\u8bc1\u4e66<\/h2>\n<div>1\u3001\u8bc1\u4e66\u56fd\u522b\u3001\u540d\u5b57\u4e4b\u7c7b\u7684\u4e2a\u4eba\u611f\u89c9\u4e0d\u4fee\u6539\u4e5f\u6ca1\u4ec0\u4e48\u95ee\u9898\uff0c\u5982\u8981\u4fee\u6539\u8fd0\u884c<\/div>\n<blockquote>\n<div>vi vars<\/div>\n<\/blockquote>\n<div>2\u3001\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4<\/div>\n<blockquote>\n<div> .\/clean-all<\/div>\n<div> source .\/vars\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u4f7f\u8bbe\u7f6e\u751f\u6548<\/div>\n<div>.\/build-ca server\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u521b\u5efa\u8bc1\u4e66\u9881\u53d1\u673a\u6784CA\uff0c\u4e00\u8def\u56de\u8f66<\/div>\n<div>.\/build-key-server server\u00a0 #\u751f\u6210\u670d\u52a1\u5668\u8bc1\u4e66\uff0c\u4e00\u8def\u56de\u8f66\uff0c\u6700\u540e\u4e24\u4e2ay<\/div>\n<div>.\/build-key bsk\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u751f\u6210\u540d\u4e3absk\u7684\u5ba2\u6237\u8bc1\u4e66\uff0c\u4e00\u8def\u56de\u8f66\uff0c\u6700\u540e\u4e24\u4e2ay<\/div>\n<div>.\/build-dh\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u751f\u6210Diffie Hellman\u53c2\u6570<\/div>\n<\/blockquote>\n<h2>\u7f16\u8f91openvpn\u914d\u7f6e\u6587\u4ef6<\/h2>\n<div>\n<blockquote>\n<div>cd \/etc\/openvpn\/<\/div>\n<div>vi server.conf<\/div>\n<\/blockquote>\n<\/div>\n<div>\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9<\/div>\n<div>\n<blockquote>\n<div>port 443<\/div>\n<div>proto tcp<\/div>\n<div>dev tun<\/div>\n<div>ca \/etc\/openvpn\/easy-rsa\/2.0\/keys\/ca.crt<\/div>\n<div>cert \/etc\/openvpn\/easy-rsa\/2.0\/keys\/server.crt<\/div>\n<div>key \/etc\/openvpn\/easy-rsa\/2.0\/keys\/server.key<\/div>\n<div>dh \/etc\/openvpn\/easy-rsa\/2.0\/keys\/dh1024.pem<\/div>\n<div>server 192.168.0.0 255.255.255.0<\/div>\n<div>push \u201credirect-gateway def1\u2033<\/div>\n<div>push \u201cdhcp-option DNS 8.8.8.8\u2033<\/div>\n<div>push \u201cdhcp-option DNS 8.8.4.4\u2033<\/div>\n<div>client-to-client<\/div>\n<div>keepalive 10 120<\/div>\n<div>comp-lzo<\/div>\n<div>persist-key<\/div>\n<div>persist-tun<\/div>\n<div>verb 3<\/div>\n<\/blockquote>\n<\/div>\n<h2>\u914d\u7f6e\u7aef\u53e3\u8f6c\u53d1<\/h2>\n<div>\n<blockquote>\n<div>vi \/etc\/sysctl.conf<\/div>\n<\/blockquote>\n<\/div>\n<div>\u5c06net.ipv4.ip_forward = 0\u6539\u6210net.ipv4.ip_forward = 1\uff0c\u5c06net.ipv4.tcp_syncookies = 1\u6539\u4e3a#net.ipv4.tcp_syncookies = 1\u4fdd\u5b58\uff0c\u6267\u884csysctl -p\u4f7f\u4e4b\u751f\u6548\u3002<\/div>\n<div>\u8f93\u5165<\/div>\n<blockquote>\n<div>iptables -t nat -A POSTROUTING -s 192.168.0.0\/24 -j SNAT \u2013to-source 1.2.3.4\u00a0 #1.2.3.4\u4e3a\u4f60\u7684vps IP<\/div>\n<div>\/etc\/init.d\/iptables save\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u4fdd\u5b58iptables\u8bbe\u7f6e<\/div>\n<div>\/etc\/init.d\/iptables restar\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u91cd\u542fiptables<\/div>\n<\/blockquote>\n<h2>\u6dfb\u52a0\u5f00\u673a\u542f\u52a8<\/h2>\n<div>\n<blockquote>\n<div>vi \/etc\/rc.local<\/div>\n<\/blockquote>\n<\/div>\n<div>\u6dfb\u52a0\u4e00\u884c<\/div>\n<div>\n<blockquote>\n<div>\/usr\/sbin\/openvpn \u2013config \/etc\/openvpn\/server.conf &#038;<\/div>\n<\/blockquote>\n<\/div>\n<h2>\u542f\u52a8openvpn<\/h2>\n<blockquote>\n<div>openvpn \u2013config \/etc\/openvpn\/server.conf &#038;<\/div>\n<\/blockquote>\n<div>\u81f3\u6b64\u670d\u52a1\u7aef\u914d\u7f6e\u5b8c\u6bd5\u3002<\/div>\n<h2>\u5728windows\u4f7f\u7528openvpn<\/h2>\n<div>1\u3001\u4e0b\u8f7d\u5b89\u88c5openvpn<\/div>\n<div>2\u3001\u5728\u670d\u52a1\u5668\u00a0 \/etc\/openvpn\/easy-rsa\/2.0\/keys\/ \u6587\u4ef6\u5939\u4e2d\u7528sftp\u7c7b\u8f6f\u4ef6\u4e0b\u8f7dca.crt\u3001bsk.crt\u548cbsk.key\u8fd9\u4e09\u4e2a\u6587\u4ef6\u653e\u5728openvpn\u5ba2\u6237\u7aef\u5b89\u88c5\u8def\u5f84\u4e0b\u5f97config\u6587\u4ef6\u5939\u4e2d\u3002<\/div>\n<div>3\u3001\u5728config\u4e0b\u65b0\u5efa\u4e00\u4e2a\u540d\u5b57\u4e3a\u201cbsk.ovpn\u201d\u7684\u6587\u672c\u6587\u4ef6<\/div>\n<div>\n<blockquote>\n<div>client<\/div>\n<div>dev tun<\/div>\n<div>proto tcp<\/div>\n<div>remote 1.2.3.4 443<\/div>\n<div>resolv-retry infinite<\/div>\n<div>nobind<\/div>\n<div>persist-key<\/div>\n<div>persist-tun<\/div>\n<div>ca ca.crt<\/div>\n<div>cert client1.crt<\/div>\n<div>key client1.key<\/div>\n<div>ns-cert-type server<\/div>\n<div>comp-lzo<\/div>\n<div>verb 3<\/div>\n<\/blockquote>\n<div>\u5c061.2.3.4\u4fee\u6539\u4e3a\u4f60\u7684VPS IP<\/div>\n<div>4\u3001\u8fd0\u884c OpenVPN GUI\uff0c\u7136\u540econnect\u3002<\/div>\n<\/div>\n<div><strong>PS\uff1a<\/strong>\u5982\u679cwindows\u7684openvpn\u53ef\u4ee5\u8fde\u63a5\u5230\u670d\u52a1\u7aef\u4f46\u662f\u6240\u6709\u7f51\u9875\u90fd\u6253\u4e0d\u5f00\u53ef\u80fd\u662fiptables\u6ca1\u6709\u8bbe\u7f6e\u597d\uff0c\u8bf7\u91cd\u65b0\u914d\u7f6e\u7aef\u53e3\u8f6c\u53d1\u3002<\/div>\n<div><strong>PPS\uff1a<\/strong>\u6dfb\u52a0\u65b0\u7528\u6237\u53ea\u9700\u8fd0\u884c\u5982\u4e0b\u4e24\u6761\u547d\u4ee4\u5373\u53ef<\/div>\n<blockquote>\n<div> source .\/vars<\/div>\n<div>.\/build-key bsk<\/div>\n<\/blockquote>\n<div>\u5343\u4e07\u4e0d\u8981\u8fd0\u884c.\/clean-all \uff0c\u5426\u5219\u4f1a\u5c06\u4ee5\u524d\u751f\u6210\u7684\u8bc1\u4e66\u5220\u9664\u3002<\/div>\n<p><strong>\u539f\u6587\uff1a<\/strong><a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/www.lingbaoboy.com\/archives\/592.html\">http:\/\/www.lingbaoboy.com\/archives\/592.html<\/a><\/p>\n<p>  <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/xijie.wordpress.com\/5271\/\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/comments\/xijie.wordpress.com\/5271\/\" \/><\/a> <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/feeds.wordpress.com\/1.0\/godelicious\/xijie.wordpress.com\/5271\/\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/delicious\/xijie.wordpress.com\/5271\/\" \/><\/a> <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gofacebook\/xijie.wordpress.com\/5271\/\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/facebook\/xijie.wordpress.com\/5271\/\" \/><\/a> <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gotwitter\/xijie.wordpress.com\/5271\/\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/twitter\/xijie.wordpress.com\/5271\/\" \/><\/a> <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gostumble\/xijie.wordpress.com\/5271\/\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/stumble\/xijie.wordpress.com\/5271\/\" \/><\/a> <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/feeds.wordpress.com\/1.0\/godigg\/xijie.wordpress.com\/5271\/\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/digg\/xijie.wordpress.com\/5271\/\" \/><\/a> <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/feeds.wordpress.com\/1.0\/goreddit\/xijie.wordpress.com\/5271\/\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/reddit\/xijie.wordpress.com\/5271\/\" \/><\/a> <img loading=\"lazy\" decoding=\"async\" alt=\"\" border=\"0\" height=\"1\" src=\"http:\/\/stats.wordpress.com\/b.gif?host=xijie.wordpress.com&#038;blog=10068099&#038;post=5271&#038;subd=xijie&#038;ref=&#038;feed=1\" width=\"1\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/feeds.wordpress.com\/1.0\/comments\/xijie.wordpress.com\/5271\/\" \/><\/p>\n<p><small>\u672c\u6587\u7531\u81ea\u52a8\u805a\u5408\u7a0b\u5e8f\u53d6\u81ea\u7f51\u7edc\uff0c\u5185\u5bb9\u548c\u89c2\u70b9\u4e0d\u4ee3\u8868\u6570\u5b57\u65f6\u4ee3\u7acb\u573a<\/small><\/p>\n<form method=\"POST\" action=\"http:\/\/www.feedblitz.com\/f\/f.fbz?AddNewUserDirect\">\n\u5b9a\u671f\u83b7\u5f97\u7ffb\u5899\u4fe1\u606f\uff1f<a href=\"http:\/\/www.feedblitz.com\/f\/?Sub=738338\" target=\"_blank\" rel=\"noopener\">\u8bf7\u7535\u90ae\u8ba2\u9605\u6570\u5b57\u65f6\u4ee3<\/a> <br \/><input name=\"EMAIL\" maxlength=\"64\" type=\"text\" size=\"25\" value=\"\"><br \/>\n<input name=\"FEEDID\" type=\"hidden\" value=\"738338\"><br \/>\n<input name=\"PUBLISHER\" type=\"hidden\" value=\"7485568\"><br \/>\n<input type=\"submit\" value=\"\u8ba2\u9605!\"><br \/>\n<\/form>\n","protected":false},"excerpt":{"rendered":"<p> \u6765\u6e90\uff1a http:\/\/igfw.tk\/archives\/6129 \u524d\u4e24\u5929\u5728hellohost\u4e0a\u8d2d\u4e70\u4e86\u4e00\u6b3e128\u5185\u5b58\u7684linux VPS\uff0c\u65e0\u5948\u53d1\u73b0LNMP\u4e00\u952e\u5305\u88c5\u4e0d\u4e0a\uff0cLAMP\u88c5\u4e0a\u540e\u5185\u5b58\u76f4\u63a5\u7206\u6ee1\uff0c\u8fde\u767b\u5f55\u90fd\u767b\u9646\u4e0d\u4e86\u4e86\uff0c\u5c0f\u5185\u5b58\u7684VPS\u4f24\u4e0d\u8d77\u554a\uff0c\u53ea\u597d\u7528\u6765\u914d\u7f6eVPN\u548cSSH\u7528\u6765\u505a\u4e00\u4e9b\u7279\u6b8a\u7528\u9014\uff0c\u800cOpenVZ VPS\u8c8c\u4f3c\u53ea\u80fd\u914d\u7f6eopenvpn \u3002 \u9996\u5148\u8054\u7cfb\u4f60\u7684VPS\u670d\u52a1\u5546\u8ba9\u4ed6\u628aTUN\/TAP\u529f\u80fd\u6253\u5f00\uff0c\u9ed8\u8ba4\u5927\u90e8\u5206\u90fd\u662f\u5173\u95ed\u7684\uff0c\u4f60\u53ef\u4ee5\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u6d4b\uff1a cat \/dev\/net\/tun \u82e5\u8fd4\u56de\u4ee5\u4e0b\u7ed3\u679c\u8868\u793aOK cat: \/dev\/net\/tun: File descriptor in bad state \u5b89\u88c5openvpn 1\u3001\u6dfb\u52a0\u6e90 rpm -Uvh http:\/\/download.fedora.redhat.com\/pub\/epel\/5\/i386\/epel-release-5-4.noarch.rpm 2\u3001\u5b89\u88c5 yum -y install openvpn 3\u3001\u5c06easy-rsa\u79fb\u52a8\u5230\u4e00\u4e2a\u65b9\u4fbf\u64cd\u4f5c\u7684\u4f4d\u7f6e\u3002 cp -R \/usr\/share\/openvpn\/easy-rsa \/etc\/openvpn\/ 4\u3001\u8fdb\u5165\u76ee\u5f55 cd \/etc\/openvpn\/easy-rsa\/2.0 \u751f\u6210\u8bc1\u4e66 1\u3001\u8bc1\u4e66\u56fd\u522b\u3001\u540d\u5b57\u4e4b\u7c7b\u7684\u4e2a\u4eba\u611f\u89c9\u4e0d\u4fee\u6539\u4e5f\u6ca1\u4ec0\u4e48\u95ee\u9898\uff0c\u5982\u8981\u4fee\u6539\u8fd0\u884c vi vars 2\u3001\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4 .\/clean-all source .\/vars\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u4f7f\u8bbe\u7f6e\u751f\u6548 .\/build-ca server\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u521b\u5efa\u8bc1\u4e66\u9881\u53d1\u673a\u6784CA\uff0c\u4e00\u8def\u56de\u8f66 .\/build-key-server server\u00a0 #\u751f\u6210\u670d\u52a1\u5668\u8bc1\u4e66\uff0c\u4e00\u8def\u56de\u8f66\uff0c\u6700\u540e\u4e24\u4e2ay .\/build-key bsk\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u751f\u6210\u540d\u4e3absk\u7684\u5ba2\u6237\u8bc1\u4e66\uff0c\u4e00\u8def\u56de\u8f66\uff0c\u6700\u540e\u4e24\u4e2ay .\/build-dh\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u751f\u6210Diffie Hellman\u53c2\u6570 \u7f16\u8f91openvpn\u914d\u7f6e\u6587\u4ef6 cd \/etc\/openvpn\/ vi server.conf \u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9 port 443 proto tcp dev tun ca \/etc\/openvpn\/easy-rsa\/2.0\/keys\/ca.crt cert \/etc\/openvpn\/easy-rsa\/2.0\/keys\/server.crt key \/etc\/openvpn\/easy-rsa\/2.0\/keys\/server.key dh \/etc\/openvpn\/easy-rsa\/2.0\/keys\/dh1024.pem server 192.168.0.0 255.255.255.0 push \u201credirect-gateway def1\u2033 push \u201cdhcp-option DNS 8.8.8.8\u2033 push \u201cdhcp-option DNS 8.8.4.4\u2033 client-to-client keepalive 10 120 comp-lzo persist-key persist-tun verb 3 \u914d\u7f6e\u7aef\u53e3\u8f6c\u53d1 vi \/etc\/sysctl.conf \u5c06net.ipv4.ip_forward = 0\u6539\u6210net.ipv4.ip_forward = 1\uff0c\u5c06net.ipv4.tcp_syncookies = 1\u6539\u4e3a#net.ipv4.tcp_syncookies = 1\u4fdd\u5b58\uff0c\u6267\u884csysctl -p\u4f7f\u4e4b\u751f\u6548\u3002 \u8f93\u5165 iptables -t nat -A POSTROUTING -s 192.168.0.0\/24 -j SNAT \u2013to-source 1.2.3.4\u00a0 #1.2.3.4\u4e3a\u4f60\u7684vps IP \/etc\/init.d\/iptables save\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u4fdd\u5b58iptables\u8bbe\u7f6e \/etc\/init.d\/iptables restar\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u91cd\u542fiptables \u6dfb\u52a0\u5f00\u673a\u542f\u52a8 vi \/etc\/rc.local \u6dfb\u52a0\u4e00\u884c \/usr\/sbin\/openvpn \u2013config \/etc\/openvpn\/server.conf &#038; \u542f\u52a8openvpn openvpn \u2013config \/etc\/openvpn\/server.conf &#038; \u81f3\u6b64\u670d\u52a1\u7aef\u914d\u7f6e\u5b8c\u6bd5\u3002 \u5728windows\u4f7f\u7528openvpn 1\u3001\u4e0b\u8f7d\u5b89\u88c5openvpn 2\u3001\u5728\u670d\u52a1\u5668\u00a0 \/etc\/openvpn\/easy-rsa\/2.0\/keys\/ \u6587\u4ef6\u5939\u4e2d\u7528sftp\u7c7b\u8f6f\u4ef6\u4e0b\u8f7dca.crt\u3001bsk.crt\u548cbsk.key\u8fd9\u4e09\u4e2a\u6587\u4ef6\u653e\u5728openvpn\u5ba2\u6237\u7aef\u5b89\u88c5\u8def\u5f84\u4e0b\u5f97config\u6587\u4ef6\u5939\u4e2d\u3002 3\u3001\u5728config\u4e0b\u65b0\u5efa\u4e00\u4e2a\u540d\u5b57\u4e3a\u201cbsk.ovpn\u201d\u7684\u6587\u672c\u6587\u4ef6 client dev tun proto tcp remote 1.2.3.4 443 resolv-retry infinite nobind persist-key persist-tun ca ca.crt cert client1.crt key client1.key ns-cert-type server comp-lzo verb 3 \u5c061.2.3.4\u4fee\u6539\u4e3a\u4f60\u7684VPS IP 4\u3001\u8fd0\u884c OpenVPN GUI\uff0c\u7136\u540econnect\u3002 PS\uff1a \u5982\u679cwindows\u7684openvpn\u53ef\u4ee5\u8fde\u63a5\u5230\u670d\u52a1\u7aef\u4f46\u662f\u6240\u6709\u7f51\u9875\u90fd\u6253\u4e0d\u5f00\u53ef\u80fd\u662fiptables\u6ca1\u6709\u8bbe\u7f6e\u597d\uff0c\u8bf7\u91cd\u65b0\u914d\u7f6e\u7aef\u53e3\u8f6c\u53d1\u3002 PPS\uff1a \u6dfb\u52a0\u65b0\u7528\u6237\u53ea\u9700\u8fd0\u884c\u5982\u4e0b\u4e24\u6761\u547d\u4ee4\u5373\u53ef source .\/vars .\/build-key bsk \u5343\u4e07\u4e0d\u8981\u8fd0\u884c.\/clean-all \uff0c\u5426\u5219\u4f1a\u5c06\u4ee5\u524d\u751f\u6210\u7684\u8bc1\u4e66\u5220\u9664\u3002 \u539f\u6587\uff1a http:\/\/www.lingbaoboy.com\/archives\/592.html <\/p>\n","protected":false},"author":983,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","ampforwp-amp-on-off":"","home_featured":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[15300],"tags":[8510,8795],"class_list":["post-193817","post","type-post","status-publish","format-standard","hentry","category-15300","tag-vpn","tag-8795","et-doesnt-have-format-content","et_post_format-et-post-format-standard"],"_links":{"self":[{"href":"https:\/\/chinadigitaltimes.net\/chinese\/wp-json\/wp\/v2\/posts\/193817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chinadigitaltimes.net\/chinese\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chinadigitaltimes.net\/chinese\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chinadigitaltimes.net\/chinese\/wp-json\/wp\/v2\/users\/983"}],"replies":[{"embeddable":true,"href":"https:\/\/chinadigitaltimes.net\/chinese\/wp-json\/wp\/v2\/comments?post=193817"}],"version-history":[{"count":0,"href":"https:\/\/chinadigitaltimes.net\/chinese\/wp-json\/wp\/v2\/posts\/193817\/revisions"}],"wp:attachment":[{"href":"https:\/\/chinadigitaltimes.net\/chinese\/wp-json\/wp\/v2\/media?parent=193817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chinadigitaltimes.net\/chinese\/wp-json\/wp\/v2\/categories?post=193817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chinadigitaltimes.net\/chinese\/wp-json\/wp\/v2\/tags?post=193817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}