<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>openvpn &#8211; richliu&#039;s blog</title>
	<atom:link href="https://blog.richliu.com/tag/openvpn/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.richliu.com</link>
	<description>Linux, 工作, 生活, 家人</description>
	<lastBuildDate>Tue, 26 Apr 2022 01:38:27 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.2</generator>
	<item>
		<title>OpenVPN Client Re-connect Problem When IP Changed</title>
		<link>https://blog.richliu.com/2022/04/26/4564/openvpn-client-re-connect-problem-when-ip-changed/</link>
					<comments>https://blog.richliu.com/2022/04/26/4564/openvpn-client-re-connect-problem-when-ip-changed/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Tue, 26 Apr 2022 01:38:25 +0000</pubDate>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[openvpn]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=4564</guid>

					<description><![CDATA[<p>OpenVPN 是透過 PPPoE 上網時，因為固定時間 IP 會變化，此時 OpenVPN 預設的 clie [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2022/04/26/4564/openvpn-client-re-connect-problem-when-ip-changed/">OpenVPN Client Re-connect Problem When IP Changed</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>OpenVPN 是透過 PPPoE 上網時，因為固定時間 IP 會變化，此時 OpenVPN 預設的 client 會因為斷線而無法重新連上，而且設了 maximum connection 之類的參數也沒有用<br /><br />這時候就要拿掉 persist-tun 這個參數，將該行 Mark 起來就好</p>



<pre class="wp-block-preformatted">; persist-tun</pre>



<p>Ref. <br /><a href="https://serverfault.com/questions/951127/openvpn-reconnect-fails-manual-restart-works" target="_blank" rel="noopener">OpenVPN reconnect fails, manual restart works</a></p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2022/04/26/4564/openvpn-client-re-connect-problem-when-ip-changed/">OpenVPN Client Re-connect Problem When IP Changed</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2022/04/26/4564/openvpn-client-re-connect-problem-when-ip-changed/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>OpenVPN Easy RSA  筆記</title>
		<link>https://blog.richliu.com/2017/01/18/2084/openvpn-easy-rsa-%e7%ad%86%e8%a8%98/</link>
					<comments>https://blog.richliu.com/2017/01/18/2084/openvpn-easy-rsa-%e7%ad%86%e8%a8%98/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 18 Jan 2017 13:26:38 +0000</pubDate>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[easyrsa]]></category>
		<category><![CDATA[openvpn]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=2084</guid>

					<description><![CDATA[<p>時隔 10 年發現 Key 過期了, 所以跑回來加一下 Updater Key 的資訊 安裝 easy-rsa [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2017/01/18/2084/openvpn-easy-rsa-%e7%ad%86%e8%a8%98/">OpenVPN Easy RSA  筆記</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>時隔 10 年發現 Key 過期了, 所以跑回來加一下 Updater Key 的資訊</p>
<p>安裝 easy-rsa 套件</p>
<pre lang=bash> 
$ emerge --ask app-crypt/easy-rsa
</pre>
<p>copy easy-rsa 套件到 openvpn 下</p>
<pre lang=bash>
$ cd /etc/openvpn
$ cp -a /usr/share/easy-rsa .
$ cd easy-rsa
$ mv vars.example vars
</pre>
<p>修改 vars 內, 我比較傳統, 走舊式的方式</p>
<pre lang=text>
set_var EASYRSA_DN      "org"
set_var EASYRSA_REQ_COUNTRY     "TW"
set_var EASYRSA_REQ_PROVINCE    "Taiwan"
set_var EASYRSA_REQ_CITY        "New Taipei"
set_var EASYRSA_REQ_ORG         "domain.com"
set_var EASYRSA_REQ_EMAIL       "email@domain.com"
set_var EASYRSA_REQ_OU          "Organizational Unit"
</pre>
<p>編輯完之後 清除所有的 PKI 設定</p>
<pre lang=bash>
$ ./easyrsa init-pki
</pre>
<p>建立 ca 資訊, ca 要輸入密碼, 請記好. dh 是產生 Diffie-Hellman .pem file</p>
<pre lang=bash>
$ ./easyrsa build-ca
$ ./easyrsa gen-dh
</pre>
<p>建立 Server 和 Client Key 資訊</p>
<pre lang=bash>
$ ./easyrsa build-server-full server1 nopass
$ ./easyrsa build-client-full client1 nopass
</pre>
<p>中間有問密碼就是 ca 的密碼</p>
<p>最後, 編輯 /etc/openvpn/openvpn.conf<br />
加上</p>
<pre lang=text>
dh /etc/openvpn/easy-rsa/pki/dh.pem
ca /etc/openvpn/easy-rsa/pki/ca.crt
cert /etc/openvpn/easy-rsa/pki/issued/server1.crt
key /etc/openvpn/easy-rsa/pki/private/server1.key
</pre>
<p>這樣應該就可以了, 下次更新不知道會不會是十年後的事情了呢? </p>
<p>ref.<br />
<a href="https://wiki.gentoo.org/wiki/Create_a_Public_Key_Infrastructure_Using_the_easy-rsa_Scripts" target="_blank" rel="noopener">Create a Public Key Infrastructure Using the easy-rsa Scripts</a><br />
其實原來是參考 Arch 的文件, 不過太麻煩了<br />
https://wiki.archlinux.org/index.php/Easy-RSA</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2017/01/18/2084/openvpn-easy-rsa-%e7%ad%86%e8%a8%98/">OpenVPN Easy RSA  筆記</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2017/01/18/2084/openvpn-easy-rsa-%e7%ad%86%e8%a8%98/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>OpenVPN 小記</title>
		<link>https://blog.richliu.com/2006/09/05/348/openvpn-%e5%b0%8f%e8%a8%98/</link>
					<comments>https://blog.richliu.com/2006/09/05/348/openvpn-%e5%b0%8f%e8%a8%98/#comments</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Tue, 05 Sep 2006 05:52:04 +0000</pubDate>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[easyrsa]]></category>
		<category><![CDATA[openvpn]]></category>
		<guid isPermaLink="false">http://blog.richliu.com/2006/09/05/348/</guid>

					<description><![CDATA[<p>因為看到有人說 OpenVPN 非常好用, 所以就用 OpenVPN 2.0.7 架了一個站, 在一個晚上試誤 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2006/09/05/348/openvpn-%e5%b0%8f%e8%a8%98/">OpenVPN 小記</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>因為看到有人說 OpenVPN 非常好用, 所以就用 OpenVPN 2.0.7 架了一個站, 在一個晚上試誤之下,<br /></p>



<p>Client Config File</p>



<pre class="wp-block-code"><code>client
dev tun
dev-node MyTap
proto tcp
remote 111.222.333.444 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client1.crt
key client1.key
comp-lzo
verb 3</code></pre>



<p>Server Config File</p>



<pre class="wp-block-code"><code>#
dev tun
port 1194
# use tcp, could pass by proxy server
proto tcp

server 192.168.10.0 255.255.255.0
push "redirect-gateway"
push "dhcp-option DNS 168.95.192.2"
# Let client connect to another client
;client-to-client
ifconfig-pool-persist ipp.txt
keepalive 10 120

tls-server
dh /usr/share/openvpn/easy-rsa/keys/dh2048.pem
ca /usr/share/openvpn/easy-rsa/keys/ca.crt
cert /usr/share/openvpn/easy-rsa/keys/server.crt
key /usr/share/openvpn/easy-rsa/keys/server.key
; user nobody
; group nobody

comp-lzo
; ping 15
; ping-restart 45
; ping-timer-rem
persist-tun
persist-key
status openvpn-status.log
verb 3</code></pre>



<h3 class="wp-block-heading">產生 Key 的部份</h3>



<ol class="wp-block-list"><li>cd /usr/share/openvpn/easy-rsa</li><li>vim vars</li><li>將 Key 長度改 2048</li><li>其他的 Information 也要相對修改</li><li>source ./vars</li><li>./clean-all</li><li>./build-dh</li><li>./build-ca</li><li>./build-key-server server</li><li>修改 /etc/opensvn/opensvn.conf<ol><li>將 ca.crt, server.crt, server.key 指到 /usr/share/openvpn/easy-rsa/keys 下</li></ol></li><li>./build-key client1<ol><li>將 client1.crt , celient1.key, ca.crt copy 到 Windows 端</li></ol></li></ol>



<p>[<a href="https://web.archive.org/web/20120423203456/http://wiki.richliu.com/index.php?title=OpenVPN&amp;action=edit&amp;section=4" target="_blank" rel="noopener">編輯</a>]</p>



<h3 class="wp-block-heading">其他需注意的部份</h3>



<ul class="wp-block-list"><li>使用 OpenVPN GUI 可以即時設定 Proxy</li><li>如果要設定 Proxy, 連線的 Protocol 要使用 TCP.</li><li>如果 syslog 有 &#8220;Note: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2)&#8221;, 請下以下指令</li></ul>



<pre class="wp-block-preformatted">mkdir /dev/net; mknod -m0600 /dev/net/tun c 10 200</pre>



<p>如果有任何問題, 可以在我的 Comment 留言, wiki 不開放修改.</p>



<p>2017/01/18 Update<br />時隔 10 年發現 Key 過期了, 所以跑回來修一下文章 (只有 Key 部份)</p>



<p>安裝 easy-rsa 套件</p>



<pre class="wp-block-preformatted"> 
$ emerge --ask app-crypt/easy-rsa
</pre>



<p>copy easy-rsa 套件到 openvpn 下</p>



<pre class="wp-block-preformatted">$ cd /etc/openvpn
$ cp -a /usr/share/easy-rsa .
$ cd easy-rsa
$ mv vars.example vars
</pre>



<p>修改 vars 內, 我比較傳統, 走舊式的方式</p>



<pre class="wp-block-preformatted">set_var EASYRSA_DN      "org"
set_var EASYRSA_REQ_COUNTRY     "TW"
set_var EASYRSA_REQ_PROVINCE    "Taiwan"
set_var EASYRSA_REQ_CITY        "New Taipei"
set_var EASYRSA_REQ_ORG         "domain.com"
set_var EASYRSA_REQ_EMAIL       "email@domain.com"
set_var EASYRSA_REQ_OU          "Organizational Unit"
</pre>



<p>編輯完之後 清除所有的 PKI 設定</p>



<pre class="wp-block-preformatted">$ ./easyrsa init-pki
</pre>



<p>建立 ca 資訊, ca 要輸入密碼, 請記好. dh 是產生 Diffie-Hellman .pem file</p>



<pre class="wp-block-preformatted">$ ./easyrsa build-ca
$ ./easyrsa gen-dh
</pre>



<p>建立 Server 和 Client Key 資訊</p>



<pre class="wp-block-preformatted">$ ./easyrsa build-server-full server1 nopass
$ ./easyrsa build-client-full client1 nopass
</pre>



<p>中間有問密碼就是 ca 的密碼</p>



<p>最後, 編輯 /etc/openvpn/openvpn.conf<br />加上</p>



<pre class="wp-block-preformatted">dh /etc/openvpn/easy-rsa/pki/dh.pem
ca /etc/openvpn/easy-rsa/pki/ca.crt
cert /etc/openvpn/easy-rsa/pki/issued/server1.crt
key /etc/openvpn/easy-rsa/pki/private/server1.key
</pre>



<p>這樣應該就可以了, 下次更新不知道會不會是十年後的事情了呢?</p>



<p>ref.<br /><a href="https://wiki.gentoo.org/wiki/Create_a_Public_Key_Infrastructure_Using_the_easy-rsa_Scripts" target="_blank" rel="noopener">Create a Public Key Infrastructure Using the easy-rsa Scripts</a> : 其實是我改的, 原來文件過期太久了&#8230; -_-!<br />其實原來是參考 Arch 的文件, 不過太麻煩了<br />https://wiki.archlinux.org/index.php/Easy-RSA</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2006/09/05/348/openvpn-%e5%b0%8f%e8%a8%98/">OpenVPN 小記</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2006/09/05/348/openvpn-%e5%b0%8f%e8%a8%98/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>
