update some content

This commit is contained in:
2021-10-28 14:15:01 +08:00
parent b8600ab259
commit 27b5a11382
163 changed files with 951 additions and 922 deletions

View File

@@ -45,9 +45,9 @@
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<link href="https://h.cowbay.org/css/style.css?v=1634607506" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
<link href="https://h.cowbay.org/css/style.css?v=1635401692" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
<link href="https://h.cowbay.org/css/custom.css?v=1634607506" rel="stylesheet" type='text/css' media='all'>
<link href="https://h.cowbay.org/css/custom.css?v=1635401692" rel="stylesheet" type='text/css' media='all'>
<link rel="shortcut icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
<link rel="icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
@@ -320,48 +320,48 @@ if (!doNotTrack) {
<hr>
<h4 id="安裝基本套件">安裝基本套件</h4>
<p>因為是選擇 ubuntu 20.04 minimal 所以有很多套件都沒有,要先安裝這些基本套件</p>
<pre tabindex="0"><code>sudo apt update &amp;&amp; sudo apt install -y vim git net-tools software-properties-common iptables python3-pip qrencode
<pre><code>sudo apt update &amp;&amp; sudo apt install -y vim git net-tools software-properties-common iptables python3-pip qrencode
</code></pre><h4 id="取得安裝script">取得安裝script</h4>
<pre tabindex="0"><code>mkdir git &amp;&amp; cd git
<pre><code>mkdir git &amp;&amp; cd git
git clone https://github.com/racbart/wireguard-pihole
</code></pre><h4 id="修改-installsh">修改 install.sh</h4>
<p>因為我的目的是只想要把DNS 查詢透過wireguard 丟去 pihole</p>
<p>而不是把所有流量都轉給wireguard</p>
<p>所以要修改一下剛剛clone 下來的 script</p>
<pre tabindex="0"><code>cd wireguard-pihole
<pre><code>cd wireguard-pihole
vim install.sh
</code></pre><p>有點忘了改了哪些東西,就大概說一下吧</p>
<h5 id="ipv4_address">IPV4_ADDRESS</h5>
<p>原本的判斷VPS WAN IP 的指令在GCE上會抓到private ip</p>
<p>所以要改一下,在 install.sh 中找到底下這行註解掉,並修改成其他指令</p>
<pre tabindex="0"><code>#IPV4_ADDRESS=$(ip addr list &quot;$INTERFACE&quot; | grep &quot;inet &quot; | xargs | cut -d &quot; &quot; -f 2)
<pre><code>#IPV4_ADDRESS=$(ip addr list &quot;$INTERFACE&quot; | grep &quot;inet &quot; | xargs | cut -d &quot; &quot; -f 2)
IPV4_ADDRESS=$(dig +short myip.opendns.com @resolver1.opendns.com)
</code></pre><h5 id="install-wireguard-in-ubuntu-2004">install wireguard in ubuntu 20.04</h5>
<p>ubuntu 20.04 安裝wireguard 的方式和 18.04 有點差別,需要多裝一個 wireguard-dkms</p>
<p>找到底下這行註解掉改成我們要的指令python-pip 我們用 python3-pip 取代</p>
<p>在一開始就已經先裝了,所以這邊不需要再裝一次</p>
<pre tabindex="0"><code>#apt install -y wireguard python-pip
<pre><code>#apt install -y wireguard python-pip
apt install -y wireguard wireguard-dkms
</code></pre><h5 id="啟用query-logging">啟用query logging</h5>
<p>找到底下這行,註解掉,改成啟用 query logging</p>
<pre tabindex="0"><code>#QUERY_LOGGING=false
<pre><code>#QUERY_LOGGING=false
QUERY_LOGGING=true
</code></pre><p>存檔後離開</p>
<p>然後執行</p>
<pre tabindex="0"><code>sudo ./install.sh
<pre><code>sudo ./install.sh
</code></pre><p>開始進行安裝,基本上是全自動的,應該沒有錯誤,可以順利跑完 (應該啦&hellip;)</p>
<hr>
<p>接著來依照我自己的需求來修改一下 add-client.sh</p>
<h5 id="修改-ipv4_address">修改 IPV4_ADDRESS</h5>
<p>找到底下這行註解掉,並修改成其他指令</p>
<pre tabindex="0"><code>#IPV4_ADDRESS=$(ip addr list &quot;$INTERFACE&quot; | grep &quot;inet &quot; | xargs | cut -d &quot; &quot; -f 2)
<pre><code>#IPV4_ADDRESS=$(ip addr list &quot;$INTERFACE&quot; | grep &quot;inet &quot; | xargs | cut -d &quot; &quot; -f 2)
IPV4_ADDRESS=$(dig +short myip.opendns.com @resolver1.opendns.com)
</code></pre><h5 id="改一下-port">改一下 port</h5>
<pre tabindex="0"><code>#SERVER_PORT=$(cat /etc/wireguard/wg0.conf | grep ListenPort | rev | cut -d &quot; &quot; -f 1 | rev)
<pre><code>#SERVER_PORT=$(cat /etc/wireguard/wg0.conf | grep ListenPort | rev | cut -d &quot; &quot; -f 1 | rev)
SERVER_PORT=12000
</code></pre><h5 id="display-client-and-save-conf">display client and save conf</h5>
<p>找到底下這一段</p>
<pre tabindex="0"><code>echo &quot;
<pre><code>echo &quot;
[Interface]
PrivateKey = ${CLIENT_PRIVKEY}
Address = ${NEXT_IP}/32
@@ -372,7 +372,7 @@ AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = ${SERVER_ADDRESS}:${SERVER_PORT}
&quot;
</code></pre><p>改成</p>
<pre tabindex="0"><code># Display client config
<pre><code># Display client config
echo &quot;
[Interface]
@@ -387,7 +387,7 @@ AllowedIPs = 10.10.0.1/32
Endpoint = ${SERVER_ADDRESS}:${SERVER_PORT}&quot;|tee ${CLIENT_NAME}.conf &amp;&amp; qrencode -t ansiutf8 -l L &lt; ${CLIENT_NAME}.conf
</code></pre><p>之後要新增 client</p>
<p>就只要輸入</p>
<pre tabindex="0"><code>sudo bash add-client.sh &quot;CLIENT_NAME&quot;
<pre><code>sudo bash add-client.sh &quot;CLIENT_NAME&quot;
</code></pre><p>就會在當前目錄底下產生 ${CLIENT_NAME}.conf 的設定檔,並顯示 qrcode</p>
<p>而且也不用去管 client ip 發到哪了script 會自己去計算</p>
<p>再次強調,這只會把手機上的 dns 查詢透過wireguard指向到 pihole</p>
@@ -395,7 +395,7 @@ Endpoint = ${SERVER_ADDRESS}:${SERVER_PORT}&quot;|tee ${CLIENT_NAME}.conf &amp;&
<p>如果要改成都走wireguard 出去,那就把最後一段的 Endpoint 後面改成 0.0.0.0/0</p>
<p>PC的話wireguard 連上之後要去手動修改DNS</p>
<p>成功的話在PC上可以看到這樣的查詢結果</p>
<pre tabindex="0"><code>peer: mVRp+fjHKW1/n/j5Cwn9zOlLsgtHsvoiNHPSn4bHLHg=
<pre><code>peer: mVRp+fjHKW1/n/j5Cwn9zOlLsgtHsvoiNHPSn4bHLHg=
endpoint: 23.34.45.67:12000
allowed ips: 10.10.0.1/32
latest handshake: 1 hour, 48 minutes, 39 seconds ago
@@ -501,7 +501,7 @@ sudo mkdir /var/cache/stubby
</code></pre></div><h5 id="修改pihole-相關設定">修改pihole 相關設定</h5>
<p>開啟 pihole web 管理界面 settings -&gt; dns -&gt; 左邊預設的DNS 都不要選,在右邊的 custom 1(IPV4) 填入</p>
<p>存檔後離開</p>
<pre tabindex="0"><code>127.0.0.1#5453
<pre><code>127.0.0.1#5453
</code></pre>
</article>
</div>
@@ -793,7 +793,7 @@ title="pinterest icon"></i>
</div>
<script src="https://h.cowbay.org/js/jquery.min.js"></script>
<script src="https://h.cowbay.org/js/jquerymigrate.js"></script>
<script src="https://h.cowbay.org/js/production.min.js?v=1634607506"></script>
<script src="https://h.cowbay.org/js/production.min.js?v=1635401692"></script>
</body>
</html>