id: 66c1ef7d544e4ebe882d096e1a84802f
parent_id: 
item_type: 1
item_id: d725eaa7abbe48019dc81df37e26fd8d
item_updated_time: 1764365022745
title_diff: "[{\"diffs\":[[1,\"搭建OpenVPN环境\"]],\"start1\":0,\"start2\":0,\"length1\":0,\"length2\":11}]"
body_diff: "[{\"diffs\":[[1,\"<html>\\\r\\\n<head>\\\r\\\n  <title>搭建OpenVPN环境</title>\\\r\\\n  <basefont face=\\\"微软雅黑\\\" size=\\\"2\\\" />\\\r\\\n  <meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html;charset=utf-8\\\" />\\\r\\\n  <meta name=\\\"exporter-version\\\" content=\\\"YXBJ Windows/608924 (zh-CN, DDL); Windows/10.0.0 (Win64); EDAMVersion=V2;\\\"/>\\\r\\\n  <meta name=\\\"content-class\\\" content=\\\"yinxiang.peso.superNote\\\"/>\\\r\\\n  <meta name=\\\"application-data:yinxiang.noteLayout\\\" content=\\\"{\\\"lineSpace\\\":\\\"recommend\\\",\\\"paragraphSpace\\\":\\\"recommend\\\"}\\\"/>\\\r\\\n  <style>\\\r\\\n\\tbody, td {\\\r\\\n\\t  font-family: 微软雅黑;\\\r\\\n\\t  font-size: 12pt;\\\r\\\n\\t}\\\r\\\n  </style>\\\r\\\n</head>\\\r\\\n<body>\\\r\\\n<a name=\\\"39342\\\"></a>\\\r\\\n<h1>搭建OpenVPN环境</h1>\\\r\\\n\\\r\\\n<div><span style=\\\"margin:0px;\\\"><div style=\\\"padding:8px 0px;margin:8px auto;max-width:700px;\\\"> <div><span></span></div>\\\n<p></p>\\\n<div style=\\\"--en-blockquote:true;box-sizing: border-box; padding-left: 19px; padding-top: 6px; padding-bottom: 6px; border-left: 3px solid #b4c0cc; background-position: initial initial; background-repeat: initial initial; margin-top: 6px\\\"><div>原文链接: <a href=\\\"http://mp.weixin.qq.com/s?__biz=MzU0NTkwNzM1Mg==&amp;mid=2247483916&amp;idx=1&amp;sn=56c9c1e984ea3da4deee0e409c4b8981&amp;chksm=fa55dda4e5f19c6bd6d9b979e0d264e17e2844c7c84b6785796620431d09316f627c6ed09d3c&amp;mpshare=1&amp;scene=1&amp;srcid=0405o6Fc0JqmqGHENvLgjeb4&amp;sharer_shareinfo=b6a007d07be34746f96f604e58cd8791&amp;sharer_shareinfo_first=b6a007d07be34746f96f604e58cd8791#rd\\\"><span>http://mp.weixin.qq.com/s?__biz=MzU0NTkwNzM1Mg==&amp;mid=2247483...</span></a></div></div>\\\n<p></p>\\\n<div><span></span></div>\\\n<div style=\\\"\\\"><div><div><h1 style=\\\"margin:0\\\"> 搭建OpenVPN环境 </h1><div><span style=\\\"position:relative\\\">原创</span><span> mxj </span><span><a style=\\\"position:relative\\\"> 编程的起跑线 </a></span><span><em></em></span></div><div style=\\\";\\\"><div style=\\\"margin-bottom: 8px;\\\"><span><span style=\\\"font-size: 20px;font-weight: bold;\\\">一、前言</span></span></div><div style=\\\"text-indent: 2em;margin-left: 8px;margin-right: 8px;line-height: 1.6em;text-align: left;\\\"><span>VPN直译就是虚拟专用通道，是提供给企业之间或者个人与公司之间安全数据传输的隧道，OpenVPN能在Solaris、Linux、OpenBSD、FreeBSD、NetBSD、Mac OS X与Microsoft Windows以及Android和iOS上运行，并包含了许多安全性的功能。它并不是一个基于Web的VPN软件，也不与IPsec及其他VPN软件包兼容。</span></div><div style=\\\"text-indent: 0px;margin-left: 0px;margin-right: 0px;line-height: 1.6em;text-align: left;\\\"><span><span style=\\\"font-size: 20px;font-weight: bold;\\\">二、配置证书 </span><span style=\\\"font-size: 20px;color: rgb(120, 172, 254);font-weight: bold;\\\">OpenVPN</span></span></div><div style=\\\"text-indent: 0px;margin-left: 8px;margin-right: 8px;line-height: 1.6em;text-align: left;margin-bottom: 8px;\\\"><span><span style=\\\"font-size: 20px;color: rgb(0, 0, 0);font-weight: normal;\\\">1）</span><span style=\\\"font-size: 17px;color: rgb(0, 0, 0);font-weight: normal;\\\">下载地址：</span>https://github.com/OpenVPN/easy-rsa-old</span></div><div style=\\\"text-indent: 0px;margin-left: 8px;margin-right: 8px;line-height: 1.6em;text-align: left;margin-bottom: 8px;\\\"><span><span style=\\\"font-size: 20px;color: rgb(0, 0, 0);font-weight: normal;\\\">2）</span>解压：</span><span style=\\\"mso-spacerun:'yes';font-size:8.77908pt;font-family:'Lucida Console';color:rgb(51,51,51);\\\"><span><span style=\\\"font-size: 17px;\\\">unzip easy-rsa-old-master.zip</span></span></span></div><div style=\\\"text-indent: 0px;margin-left: 8px;margin-right: 8px;line-height: 1.6em;text-align: left;margin-bottom: 8px;\\\"><span style=\\\"mso-spacerun:'yes';font-size:8.77908pt;font-family:'Lucida Console';color:rgb(51,51,51);\\\"><span><span style=\\\"font-size: 20px;color: rgb(0, 0, 0);font-weight: normal;\\\">3）</span><span style=\\\"font-size: 17px;\\\">编辑：/easy-rsa-old-master/easy-rsa/2.0/vars</span></span></span></div><div style=\\\"text-align: center;\\\"><img src=\\\"搭建OpenVPN环境_files/640.png\\\" type=\\\"image/png\\\" data-filename=\\\"640.png\\\" style=\\\"--en-marks:%7B%22align%22%3A%22center%22%7D;\\\"/></div><p style=\\\"margin:0;margin-bottom:8px\\\"><b><span style=\\\"mso-spacerun:'yes';font-family:'OpenSans-Bold';color:rgb(51,51,51);font-size:9.75453pt;mso-font-kerning:0pt;\\\"><font face=\\\"OpenSans-Bold\\\"><span><span style=\\\"font-size: 20px;color: rgb(0, 0, 0);font-weight: normal;\\\">3）</span></span></font></span></b><b><span style=\\\"mso-spacerun:'yes';font-family:'MicrosoftYaHei-Bold';color:rgb(51,51,51);font-size:9.75453pt;mso-font-kerning:0pt;\\\"><font face=\\\"MicrosoftYaHei-Bold\\\"><span><span style=\\\"font-size: 17px;font-weight: normal;\\\">加载配置文件修改参数信息：</span><span style=\\\"font-size: 17px;\\\">source vars</span></span></font></span></b></p><div style=\\\"text-indent: 0px;margin-left: 0px;margin-right: 0px;line-height: 1.6em;text-align: left;margin-bottom: 8px;\\\"><span style=\\\"mso-spacerun:'yes';font-size:8.77908pt;font-family:'Lucida Console';color:rgb(51,51,51);\\\"><span><span style=\\\"font-size: 20px;color: rgb(0, 0, 0);font-weight: normal;\\\">4）</span></span></span><b><span style=\\\"mso-spacerun:'yes';font-family:'MicrosoftYaHei-Bold';color:rgb(51,51,51);font-size:9.75453pt;mso-font-kerning:0pt;\\\"><font face=\\\"MicrosoftYaHei-Bold\\\"><span><span style=\\\"font-size: 17px;font-weight: normal;\\\">生成相关证书（在</span></span></font></span></b><b><span style=\\\"mso-spacerun:'yes';font-family:'OpenSans-Bold';color:rgb(51,51,51);font-size:9.75453pt;mso-font-kerning:0pt;\\\"><font face=\\\"OpenSans-Bold\\\"><span><span style=\\\"font-size: 17px;font-weight: normal;\\\">/easy-rsa-old-master/easy-rsa/2.0</span></span></font></span></b><b><span style=\\\"mso-spacerun:'yes';font-family:'MicrosoftYaHei-Bold';color:rgb(51,51,51);font-size:9.75453pt;mso-font-kerning:0pt;\\\"><font face=\\\"MicrosoftYaHei-Bold\\\"><span><span style=\\\"font-size: 17px;font-weight: normal;\\\">目录下执行）</span></span></font></span></b></div><div><pre><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span><span>1).执行./clean-all 会在目录中创建出 keys 目录，专门用于存放证书文件信息</span></span><div><span><span>  ./clean-all</span></span></div><div><span><span>  </span></span></div><div><span><span>2).生成根证书文件和私钥文件信息（在keys目录中会生成ca.crt(根证书)、ca.key(私钥)）</span></span></div><div><span><span>  ./build-ca</span></span></div><div><span><span>  </span></span></div><div><span><span>3).生成服务端证书和秘钥文件信息（在keys目录中会生成server.cst(服务端证书)、server.csr(服务</span></span></div><div><span><span>端请求证书文件)、server.key(服务端私钥文件)）</span></span></div><div><span><span>  ./build-key-server server</span></span></div><div><span><span>  </span></span></div><div><span><span>4).生成客户端证书和秘钥文件信息（在keys目录中会生成client.crt(客户端证书)、client.csr(客户端请求证书文件)、client.key(客户端私钥)）</span></span></div><div><span><span>  ./build-key client</span></span></div><div><span><br/></span></div><div><span><span>5).生成秘钥交换文件信息(在keys目录中会生成dh2048.pem文件)</span></span></div><div><span><span>./build-dh</span></span></div><div><span><br/></span></div></div></pre></div><div style=\\\"margin-bottom: 8px;\\\"><span><span style=\\\"font-size: 20px;font-weight: bold;\\\">三、搭建</span><span style=\\\"font-size: 20px;color: rgb(120, 172, 254);font-weight: bold;\\\">OpenVPN</span><span style=\\\"font-size: 20px;color: rgb(0, 0, 0);font-weight: normal;\\\">(服务端)</span></span></div><div><pre><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span><span>1</span><span>）安装</span><span>EPEL</span></span><div><span><span>   </span><span>1</span><span>. curl </span><span>-</span><span>o </span><span>/etc/</span><span>yum.repos.d</span><span>/epel.repo http://mirrors.aliyun.com/</span><span>repo</span><span>/epel-7.repo</span></span></div><div><span><span>   2. yum clean all &amp;&amp; yum makecache</span></span></div><div><span><span>   </span></span></div><div><span><span>2）安装OpenVPN(默认路径在/etc</span><span>/openvpn/</span><span>)</span></span></div><div><span><span>   yum install </span><span>-</span><span>y openvpn</span></span></div><div><span><span>   </span></span></div><div><span><span>3</span><span>）创建ta.key 文件</span></span></div><div><span><span>   openvpn </span><span>--</span><span>genkey </span><span>--</span><span>secret ta.key</span></span></div><div><span><span>   </span></span></div><div><span><span>4</span><span>）编辑server.conf</span></span></div><div><span><span>   安装openvpn时,默认生成server.conf位置在</span><span>/usr/</span><span>share</span><span>/doc/</span><span>openvpn</span><span>-</span><span>2.4</span><span>.</span><span>12</span><span>/sample/</span><span>sample</span><span>-</span><span>config</span><span>-</span><span>files</span><span>/server.conf,</span></span></div><div><span><span>   文件配置第2步、第3步对应五个文件路径</span></span></div><div><span><span>   </span></span></div><div><span><span>5）设置openvpn 服务路由转发</span></span></div><div><span><span>   echo &quot;net.ipv4.ip_forward = 1&quot; &gt;&gt;/etc</span><span>/</span><span>sysctl.conf</span></span></div><div><span><span>   </span></span></div><div><span><span>6</span><span>）查询:</span></span></div><div><span><span>   sysctl </span><span>-</span><span>p</span></span></div><div><span><span>   </span></span></div><div><span><span>7</span><span>）启动：</span></span></div><div><span><span>   openvpn </span><span>--</span><span>daemon </span><span>--</span><span>config server.conf</span></span></div><div><span><span>  </span></span></div></div></pre></div><div style=\\\"text-align: center;\\\"><img src=\\\"搭建OpenVPN环境_files/640 [1].png\\\" type=\\\"image/png\\\" data-filename=\\\"640.png\\\" style=\\\"--en-marks:%7B%22align%22%3A%22center%22%7D;\\\"/></div><div><span><span style=\\\"font-size: 20px;font-weight: bold;\\\">四、搭建</span><span style=\\\"font-size: 20px;color: rgb(120, 172, 254);font-weight: bold;\\\">OpenVPN</span><span style=\\\"font-size: 20px;color: rgb(0, 0, 0);font-weight: normal;\\\">(客户端)</span></span></div><div><pre><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span><span>1</span><span>) </span><span>OpenVPN需要安装EPEL</span></span><div><span><span>  </span><span>1</span><span>.curl </span><span>-</span><span>o </span><span>/etc/</span><span>yum.repos.d</span><span>/epel.repo http://mirrors.aliyun.com/</span><span>repo</span><span>/epel-7.repo</span></span></div><div><span><span>  2.yum clean all &amp;&amp; yum makecache</span></span></div><div><span><span>  </span></span></div><div><span><span>2)安装(默认路径在/etc</span><span>/openvpn/</span><span>)</span></span></div><div><span><span>  yum install </span><span>-</span><span>y openvpn</span></span></div><div><span><span>  </span></span></div><div><span><span>3</span><span>)在openvpn客户端新建一个目录,拷贝第</span><span>5</span><span>步中keys目录中的client.crt</span><span>、</span><span>client.key</span><span>、</span><span>ca.crt,从第</span></span></div><div><span><span>  </span><span>6</span><span>步中的第</span><span>3</span><span>小步中的ta.key</span></span></div><div><span><span>  </span></span></div><div><span><span>4</span><span>)编辑client.conf(安装openvpn时,默认生成client.conf位置在</span><span>/usr/</span><span>share</span><span>/doc/</span><span>openvpn</span><span>-</span></span></div><div><span><span>2.4</span><span>.</span><span>12</span><span>/sample/</span><span>sample</span><span>-</span><span>config</span><span>-</span><span>files</span><span>/client.conf)文件配置第2步、第3步对应四个文件路径</span></span></div><div><span><br/></span></div><div><span><span>5)将client.conf改名为client.ovpn</span></span></div><div><span><br/></span></div><div><span><span>6)启动vpn（注意命令中的/etc</span><span>/openvpn路径要是对应的client.ovpn文件对应的目录）：</span></span></div><div><span><span>openvpn --daemon --cd /etc</span><span>/openvpn --config client.ovpn --log-append /</span><span>var</span><span>/log/</span><span>openvpn.log</span></span></div></div></pre></div><div style=\\\"text-align: center;margin-bottom: 8px;\\\"><span>其他常见问题，请在评论区留言！ </span></div><div style=\\\"text-align: center;margin-bottom: 0px;\\\"><span>制作不易！ </span></div><div style=\\\"text-align: center;margin-bottom: 8px;\\\"><span>求个 “点赞 + 关注”</span></div><div><span></span></div></div></div></div></div></div></span>\\\n</div></body></html>\\u0000\"]],\"start1\":0,\"start2\":0,\"length1\":0,\"length2\":13322}]"
metadata_diff: {"new":{"id":"d725eaa7abbe48019dc81df37e26fd8d","parent_id":"f67288c3a0be4374b5d532b5dcc3aabc","latitude":"0.00000000","longitude":"0.00000000","altitude":"0.0000","author":"","source_url":"","is_todo":0,"todo_due":0,"todo_completed":0,"source":"joplin-desktop","source_application":"net.cozic.joplin-desktop","application_data":"","order":1764348856957,"user_updated_time":1764345626262,"markup_language":2,"is_shared":0,"share_id":"","conflict_original_id":"","master_key_id":"","user_data":"","deleted_time":1764365022745},"deleted":[]}
encryption_cipher_text: 
encryption_applied: 0
updated_time: 2025-11-28T21:24:52.628Z
created_time: 2025-11-28T21:24:52.628Z
type_: 13