<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="https://xuebaxi.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://xuebaxi.com/" rel="alternate" type="text/html" /><updated>2020-09-05T13:47:11+00:00</updated><id>https://xuebaxi.com/feed.xml</id><title type="html">小學霸</title><subtitle>小学霸的博客</subtitle><author><name>小學霸</name></author><entry><title type="html">ipv6透明代理</title><link href="https://xuebaxi.com/blog/2020_09_05_01" rel="alternate" type="text/html" title="ipv6透明代理" /><published>2020-09-05T00:00:00+00:00</published><updated>2020-09-05T00:00:00+00:00</updated><id>https://xuebaxi.com/blog/ipv6%E9%80%8F%E6%98%8E%E4%BB%A3%E7%90%86</id><content type="html" xml:base="https://xuebaxi.com/blog/2020_09_05_01">&lt;p&gt;因爲我本地沒有ipv6的地址，所以我的ipv6走的v2ray。&lt;/p&gt;

&lt;h3 id=&quot;1-ipset-設置&quot;&gt;1. ipset 設置&lt;/h3&gt;

&lt;p&gt;添加保留地址&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ipset &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; reservedip6 nethash family inet6
ipset add reservedip6 ::/128 
ipset add reservedip6 ::1/128 
ipset add reservedip6 ::ffff:0:0/96 
ipset add reservedip6 100::/64 
ipset add reservedip6 64:ff9b::/96 
ipset add reservedip6 2001::/32
ipset add reservedip6 2001:10::/28 
ipset add reservedip6 2001:20::/28 
ipset add reservedip6 2001:db8::/32 
ipset add reservedip6 2002::/16 
ipset add reservedip6 fc00::/7
ipset add reservedip6 fe80::/10 
ipset add reservedip6 ff00::/8 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;添加服務器地址（因爲我的流量全部走的ipv4，所以不用設置）&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ipset &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; noproxy6 nethash family inet6
ipset add noproxy6 服務器ipv6地址 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;2-iptables設置&quot;&gt;2. iptables設置&lt;/h3&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ip &lt;span class=&quot;nt&quot;&gt;-6&lt;/span&gt; rule add fwmark 1 table 100
ip &lt;span class=&quot;nt&quot;&gt;-6&lt;/span&gt; route add &lt;span class=&quot;nb&quot;&gt;local&lt;/span&gt; ::/0 dev lo table 100

ip6tables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; V2RAY
ip6tables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; mark &lt;span class=&quot;nt&quot;&gt;--mark&lt;/span&gt; 2
ip6tables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; reservedip6 dst  &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
ip6tables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; noproxy6 dst    &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
ip6tables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; udp &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; TPROXY &lt;span class=&quot;nt&quot;&gt;--on-port&lt;/span&gt; 12345 &lt;span class=&quot;nt&quot;&gt;--tproxy-mark&lt;/span&gt; 0x01/0x01 
ip6tables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; tcp &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; TPROXY &lt;span class=&quot;nt&quot;&gt;--on-port&lt;/span&gt; 12345 &lt;span class=&quot;nt&quot;&gt;--tproxy-mark&lt;/span&gt; 0x01/0x01 
ip6tables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; V2RAY_MARK
ip6tables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; reservedip6 dst &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
ip6tables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; noproxy6 dst &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
ip6tables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; mark &lt;span class=&quot;nt&quot;&gt;--mark&lt;/span&gt; 2 &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN 
ip6tables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; udp &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; MARK &lt;span class=&quot;nt&quot;&gt;--set-mark&lt;/span&gt; 1
ip6tables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; tcp &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; MARK &lt;span class=&quot;nt&quot;&gt;--set-mark&lt;/span&gt; 1
ip6tables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; PREROUTING &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; V2RAY
ip6tables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; OUTPUT &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; V2RAY_MARK
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;最後使用 v2ray 的 Dokodemo-door 監聽 12345 端口即可。&lt;/p&gt;</content><author><name>小學霸</name></author><category term="tproxy" /><category term="ipv6" /><summary type="html">因爲我本地沒有ipv6的地址，所以我的ipv6走的v2ray。</summary></entry><entry><title type="html">linux下SurfaceGo的wifi網卡固件</title><link href="https://xuebaxi.com/blog/2020_08_09_01" rel="alternate" type="text/html" title="linux下SurfaceGo的wifi網卡固件" /><published>2020-08-09T00:00:00+00:00</published><updated>2020-08-09T00:00:00+00:00</updated><id>https://xuebaxi.com/blog/linux%E4%B8%8BSurfaceGo%E7%9A%84wifi%E7%B6%B2%E5%8D%A1%E5%9B%BA%E4%BB%B6</id><content type="html" xml:base="https://xuebaxi.com/blog/2020_08_09_01">&lt;h2 id=&quot;1-去微軟官網下載固件&quot;&gt;1. 去微軟官網下載固件&lt;/h2&gt;

&lt;p&gt;更新的名字叫做Qualcomm Atheros Communications Inc. - Net - 8/24/2018 12:00:00 AM - 12.0.0.722 &lt;a href=&quot;https://www.catalog.update.microsoft.com/Search.aspx?q=Qualcomm%20Atheros%20Communications%20Inc.%20-%20Net%20-%208%2F24%2F2018%2012%3A00%3A00%20AM%20-%2012.0.0.722&quot;&gt;下載地址&lt;/a&gt;
我下載的是11/16/2018 的&lt;/p&gt;

&lt;h2 id=&quot;2解壓得到固件&quot;&gt;2.解壓得到固件&lt;/h2&gt;

&lt;p&gt;使用cabextract解壓cab文件，其中有我們需要的 eeprom_ar6320_3p0_TX8_lte_clpc.bin 文件相關信息如下&lt;/p&gt;

&lt;p&gt;sha256sum: aec1c85301c593e303422cb2f54d27b27eca4efce59f065a127e8fb205233b37&lt;/p&gt;

&lt;p&gt;md5sum: 8f2895dd63a0c8f11e2d051f0ed4e0a8&lt;/p&gt;

&lt;h2 id=&quot;3覆蓋原有的固件&quot;&gt;3.覆蓋原有的固件&lt;/h2&gt;

&lt;p&gt;將/lib/firmware/ath10k/QCA6174/hw3.0中的board-2.bin 和 board.bin刪除，用eeprom_ar6320_3p0_TX8_lte_clpc.bin替代board.bin。&lt;/p&gt;

&lt;h3 id=&quot;参见&quot;&gt;参见&lt;/h3&gt;
&lt;hr /&gt;
&lt;blockquote&gt;
  &lt;h5 id=&quot;--httpsbugsdebianorgcgi-binbugreportcgibug919652&quot;&gt;- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=919652&lt;/h5&gt;
&lt;/blockquote&gt;</content><author><name>小學霸</name></author><category term="SurfaceGo" /><category term="Linux" /><summary type="html">1. 去微軟官網下載固件</summary></entry><entry><title type="html">在OBS實況中插入YouTube聊天室</title><link href="https://xuebaxi.com/blog/2019_12_05_01" rel="alternate" type="text/html" title="在OBS實況中插入YouTube聊天室" /><published>2019-12-05T00:00:00+00:00</published><updated>2019-12-05T00:00:00+00:00</updated><id>https://xuebaxi.com/blog/%E5%9C%A8OBS%E5%AF%A6%E6%B3%81%E4%B8%AD%E6%8F%92%E5%85%A5YouTube%E8%81%8A%E5%A4%A9%E5%AE%A4</id><content type="html" xml:base="https://xuebaxi.com/blog/2019_12_05_01">&lt;h3 id=&quot;1-獲得直播的url&quot;&gt;1. 獲得直播的URL&lt;/h3&gt;

&lt;p&gt;在直播信息左下角分享中可以找到直播的URL例如&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://www.youtube.com/channel/UC_NpCQY-99aJGsRt99tcVsw/live
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;如果有自定義網址格式會是這樣&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://www.youtube.com/c/Channel/live
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;2-獲得聊天室的url&quot;&gt;2. 獲得聊天室的URL&lt;/h3&gt;

&lt;p&gt;因爲每次YouTube直播聊天室URL都會變動,所以我們需要其他網站幫我們自動獲得聊天室URL,比如下面這個:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;http://bigmond.co.uk/p/youtube_chat.php?channel=https://www.youtube.com/channel/UC_NpCQY-99aJGsRt99tcVsw/live
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;?channel=之後為第一步獲得的直播URL&lt;/p&gt;
&lt;h3 id=&quot;3-將聊天室url添加到obs&quot;&gt;3. 將聊天室URL添加到OBS&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;打開OBS,添加瀏覽器源&lt;br /&gt;
&lt;img src=&quot;/assets/images/2019_12_05_01/2019_12_06_001849.jpg&quot; alt=&quot;&quot; /&gt;&lt;/li&gt;
  &lt;li&gt;在URL中輸入第二步中的URL&lt;br /&gt;
&lt;img src=&quot;/assets/images/2019_12_05_01/2019_12_06_001544.jpg&quot; alt=&quot;&quot; /&gt;&lt;/li&gt;
  &lt;li&gt;點擊確定,確認能在畫面中顯示自己的聊天室.&lt;br /&gt;
&lt;img src=&quot;/assets/images/2019_12_05_01/2019_12_06_003559.jpg&quot; alt=&quot;&quot; /&gt;
    &lt;h3 id=&quot;4-設置聊天室樣式&quot;&gt;4. 設置聊天室樣式&lt;/h3&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;在網站&lt;a href=&quot;https://chatv2.septapus.com/&quot;&gt;https://chatv2.septapus.com/&lt;/a&gt;中可以設置聊天室樣式,并在最下面的css框中複製生成出的代碼,將複製出來的代碼粘貼到第三步添加的聊天室輸入源中的自定義CSS中&lt;br /&gt;
&lt;img src=&quot;/assets/images/2019_12_05_01/2019_12_06_003748.jpg&quot; alt=&quot;&quot; /&gt;
點擊確定即可看到最終效果
&lt;img src=&quot;/assets/images/2019_12_05_01/2019_12_06_003846.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;</content><author><name>小學霸</name></author><category term="實況" /><category term="OBS" /><category term="YouTube" /><summary type="html">1. 獲得直播的URL</summary></entry><entry><title type="html">TProxy實現透明代理</title><link href="https://xuebaxi.com/blog/2019-11-23-01" rel="alternate" type="text/html" title="TProxy實現透明代理" /><published>2019-11-23T00:00:00+00:00</published><updated>2019-11-26T00:00:00+00:00</updated><id>https://xuebaxi.com/blog/TProxy%E5%AF%A6%E7%8F%BE%E9%80%8F%E6%98%8E%E4%BB%A3%E7%90%86</id><content type="html" xml:base="https://xuebaxi.com/blog/2019-11-23-01">&lt;p&gt;&lt;a href=&quot;https://xuebaxi.com//blog/transparent_proxy&quot;&gt;上一篇&lt;/a&gt;介紹的透明代理,使用的是REDIRECT(TCP)+TProxy(UDP)的方式,此篇要介紹完全使用TProxy透明代理的方式,注意shadowsocks是不支持TCP使用TProxy的.&lt;/p&gt;
&lt;h3 id=&quot;1-加载tproxy模块&quot;&gt;1. 加载TPROXY模块&lt;/h3&gt;
&lt;p&gt;临时加载TPROXY模块:&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;modprobe xt_TPROXY
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;编辑/etc/modules-load.d/TPROXY.conf 使自动加载TPROXY模块：&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;xt_TPROXY
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;2-v2ray設置&quot;&gt;2. V2Ray設置&lt;/h3&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;inbounds&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;tag&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;transparent&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;port&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12345&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;protocol&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;dokodemo-door&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;settings&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;network&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;tcp,udp&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;followRedirect&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;sniffing&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;enabled&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;destOverride&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;http&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;tls&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;streamSettings&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;sockopt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;tproxy&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;tproxy&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;透明代理使用TProxy方式&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;outbounds&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;tag&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;proxy&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;protocol&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;vmess&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;代理伺服器&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;settings&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;vnext&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;streamSettings&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;sockopt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;mark&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;//這邊建議不要設置為&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;mux&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;enabled&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;3-設置ipset&quot;&gt;3. 設置ipset&lt;/h3&gt;

&lt;p&gt;添加保留地址&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ipset &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; reservedip nethash
ipset add reservedip 224.0.0.0/4
ipset add reservedip 100.64.0.0/10
ipset add reservedip 203.0.113.0/24
ipset add reservedip 192.18.0.0/15
ipset add reservedip 192.88.99.0/24
ipset add reservedip 172.16.0.0/12
ipset add reservedip 0.0.0.0/8
ipset add reservedip 127.0.0.0/8
ipset add reservedip 192.0.2.0/24
ipset add reservedip 192.51.100.0/24
ipset add reservedip 10.0.0.0/8
ipset add reservedip 192.168.0.0/16
ipset add reservedip 255.255.255.255
ipset add reservedip 192.0.0.0/24
ipset add reservedip 240.0.0.0/4
ipset add reservedip 169.254.0.0/16
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;添加自己伺服器的地址(鏈式代理需要,如果不需要可以不用添加)&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ipset &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; myip nethash
ipset add myip 2.2.2.2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;添加不需要代理的地址(如代理伺服器的地址),1.1.1.1只是例子)&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ipset &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; noproxy nethash
ipset add noproxy 1.1.1.1 &lt;span class=&quot;c&quot;&gt;#(1.1.1.1只是例子)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;4-iptables設置&quot;&gt;4. iptables設置&lt;/h3&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ip rule add fwmark 0x01/0x01 table 100
ip route add &lt;span class=&quot;nb&quot;&gt;local &lt;/span&gt;0.0.0.0/0 dev lo table 100
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; V2RAY
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY      &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; udp &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; myip dst        &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; TPROXY &lt;span class=&quot;nt&quot;&gt;--on-port&lt;/span&gt;  12346 &lt;span class=&quot;nt&quot;&gt;--tproxy-mark&lt;/span&gt; 0x01/0x01 &lt;span class=&quot;nt&quot;&gt;--on-ip&lt;/span&gt; 0.0.0.0 
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY      &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; tcp &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; myip dst        &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; TPROXY &lt;span class=&quot;nt&quot;&gt;--on-port&lt;/span&gt;  12346 &lt;span class=&quot;nt&quot;&gt;--tproxy-mark&lt;/span&gt; 0x01/0x01 &lt;span class=&quot;nt&quot;&gt;--on-ip&lt;/span&gt; 0.0.0.0
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY                                                &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; mark &lt;span class=&quot;nt&quot;&gt;--mark&lt;/span&gt; 2
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY             &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; reservedip dst  &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY             &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; noproxy dst    &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY      &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; udp                                    &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; TPROXY &lt;span class=&quot;nt&quot;&gt;--on-port&lt;/span&gt; 12345 &lt;span class=&quot;nt&quot;&gt;--tproxy-mark&lt;/span&gt; 0x01/0x01 &lt;span class=&quot;nt&quot;&gt;--on-ip&lt;/span&gt; 0.0.0.0
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY      &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; tcp                                    &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; TPROXY &lt;span class=&quot;nt&quot;&gt;--on-port&lt;/span&gt; 12345 &lt;span class=&quot;nt&quot;&gt;--tproxy-mark&lt;/span&gt; 0x01/0x01 &lt;span class=&quot;nt&quot;&gt;--on-ip&lt;/span&gt; 0.0.0.0
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; V2RAY_MARK
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK        &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; reservedip dst &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK        &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; noproxy dst    &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK        &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; mark &lt;span class=&quot;nt&quot;&gt;--mark&lt;/span&gt; 2                   &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN 
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; udp                                    &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; MARK &lt;span class=&quot;nt&quot;&gt;--set-mark&lt;/span&gt; 1
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; tcp                                    &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; MARK &lt;span class=&quot;nt&quot;&gt;--set-mark&lt;/span&gt; 1
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; PREROUTING                                           &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; V2RAY
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; OUTPUT                                               &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; V2RAY_MARK
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;5-開啓nat&quot;&gt;5. 開啓NAT&lt;/h3&gt;

&lt;p&gt;對於路由器需要開啓NAT,如果不是路由器請略過此條&lt;br /&gt;
其中internet0為鏈接到互聯網的網卡,net0為連接到局域網網卡.&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; POSTROUTING &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; internet0 &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; MASQUERADE
iptables &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; FORWARD &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; conntrack &lt;span class=&quot;nt&quot;&gt;--ctstate&lt;/span&gt; RELATED,ESTABLISHED &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; ACCEPT
iptables &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; FORWARD &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; net0 &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; internet0 &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; ACCEPT
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;6-保持配置&quot;&gt;6. 保持配置&lt;/h3&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ipset save &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; /etc/ipset.conf
iptables-save &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; /etc/iptables/iptables.rules
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;7設置開機啓動&quot;&gt;7.設置開機啓動&lt;/h3&gt;
&lt;p&gt;編輯/etc/systemd/system/tproxy.service文件,内容如下&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[Unit]
Description=Transparent proxy
Before=network-pre.target
Wants=network-pre.target

[Service]
Type=oneshot
ExecStart=/usr/bin/ip rule add fwmark 0x01/0x01 table 100 ; /usr/bin/ip route add local 0.0.0.0/0 dev lo table 100 ; /usr/bin/ipset -f /etc/ipset.conf restore ; /usr/bin/iptables-restore /etc/iptables/iptables.rules
ExecReload=/usr/bin/ipset -f /etc/ipset.conf restore ; /usr/bin/iptables-restore /etc/iptables/iptables.rules
ExecStop=/usr/bin/ip rule del table 100 ; /usr/bin/ip route del local 0.0.0.0/0 dev lo table 100 ; /usr/bin/ipset -f /etc/ipset.conf restore ; /usr/lib/systemd/scripts/iptables-flush
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;編輯/usr/lib/systemd/scripts/iptables-flush文件,内容如下&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#/bin/bash&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;iptables&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;ip&lt;span class=&quot;nv&quot;&gt;$1tables&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$iptables&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &amp;amp;&amp;gt;/dev/null&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then
  &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;error: invalid argument&quot;&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;exit &lt;/span&gt;1
&lt;span class=&quot;k&quot;&gt;fi

while &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;read&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; table&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do
  &lt;/span&gt;tables+&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/usr/share/iptables/empty-&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$table&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.rules&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; &amp;lt;&lt;span class=&quot;s2&quot;&gt;&quot;/proc/net/ip&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1_tables_names&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;((&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${#&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;tables&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[*]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then
  &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;tables&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[@]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; | &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$iptables&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;-restore&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;啓用規則&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;systemctl &lt;span class=&quot;nb&quot;&gt;enable &lt;/span&gt;tproxy
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;blockquote&gt;
  &lt;h3 id=&quot;参见&quot;&gt;参见&lt;/h3&gt;
  &lt;hr /&gt;
  &lt;h5 id=&quot;--archwiki-iptables&quot;&gt;- &lt;a href=&quot;https://wiki.archlinux.org/index.php/iptables&quot;&gt;ArchWiki iptables&lt;/a&gt;&lt;/h5&gt;
  &lt;h5 id=&quot;--archwiki-internet-sharing&quot;&gt;- &lt;a href=&quot;https://wiki.archlinux.org/index.php/Internet_sharing&quot;&gt;ArchWiki Internet sharing&lt;/a&gt;&lt;/h5&gt;
  &lt;h5 id=&quot;--project-v-official&quot;&gt;- &lt;a href=&quot;https://www.v2fly.org/&quot;&gt;Project V Official&lt;/a&gt;&lt;/h5&gt;
&lt;/blockquote&gt;</content><author><name>小學霸</name></author><category term="TProxy" /><category term="透明代理" /><category term="代理" /><summary type="html">上一篇介紹的透明代理,使用的是REDIRECT(TCP)+TProxy(UDP)的方式,此篇要介紹完全使用TProxy透明代理的方式,注意shadowsocks是不支持TCP使用TProxy的. 1. 加载TPROXY模块 临时加载TPROXY模块: sudo modprobe xt_TPROXY 编辑/etc/modules-load.d/TPROXY.conf 使自动加载TPROXY模块： xt_TPROXY</summary></entry><entry><title type="html">MicroPython外部中斷</title><link href="https://xuebaxi.com/blog/2019-11-08-01" rel="alternate" type="text/html" title="MicroPython外部中斷" /><published>2019-11-08T00:00:00+00:00</published><updated>2019-11-08T00:00:00+00:00</updated><id>https://xuebaxi.com/blog/MicroPython%E5%A4%96%E9%83%A8%E4%B8%AD%E6%96%B7</id><content type="html" xml:base="https://xuebaxi.com/blog/2019-11-08-01">&lt;p&gt;首先我們需要一個中斷處理函數,該函數接受 &lt;a href=&quot;http://docs.micropython.org/en/latest/library/machine.Pin.html#machine-pin&quot;&gt;machine.Pin&lt;/a&gt; 類型的參數&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;machine&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;handle_interrupt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;machine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;設置用作中斷的引脚&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;machine&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;gpio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;machine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;machine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;machine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PULL_UP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;gpio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;irq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;handler&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;handler_interrupt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;trigger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;machine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Pin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IRQ_FALLING&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;priority&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;wake&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hard&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;其中 machine.Pin.irq 方法參數為&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;handler (可選,默認值為None) 是在中斷時調用的函數&lt;/li&gt;
  &lt;li&gt;trigger (默認值為(machine.Pin.IRQ_FALLING|machine.Pin.IRQ_RISING))可以產生中斷的事件,可以使用 或 選擇多個情況,可能值為:
    &lt;ul&gt;
      &lt;li&gt;machine.Pin.IRQ_FALLING 在電平下降時中斷&lt;/li&gt;
      &lt;li&gt;machine.Pin.IRQ_RISING  在電平上升時中斷&lt;/li&gt;
      &lt;li&gt;machine.Pin.IRQ_LOW_LEVEL 低電平中斷&lt;/li&gt;
      &lt;li&gt;mcahine.Pin.IRQ_HIGH_LEVEL 高電平中斷&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;priority (默認為1)設置中斷優先級&lt;/li&gt;
  &lt;li&gt;wake (默認為None)選擇可喚醒系統的電源模式,可以使用 或 選擇多個電源模式,可能值為:
    &lt;ul&gt;
      &lt;li&gt;machine.IDLE&lt;/li&gt;
      &lt;li&gt;machine.SLEEP&lt;/li&gt;
      &lt;li&gt;machine.DEEPSLEEP&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;hard (默認False)設置硬中斷&lt;/li&gt;
&lt;/ul&gt;</content><author><name>小學霸</name></author><category term="MicroPython" /><category term="ESP8266" /><summary type="html">首先我們需要一個中斷處理函數,該函數接受 machine.Pin 類型的參數 import machine def handle_interrupt(pin:machine.Pin): print(pin.Value(0)) 設置用作中斷的引脚 import machine gpio = machine.Pin(0,machine.Pin.IN,machine.Pin.PULL_UP) gpio.irq(handler=handler_interrupt,trigger=machine.Pin.IRQ_FALLING,priority=1,wake=None,hard=False) 其中 machine.Pin.irq 方法參數為</summary></entry><entry><title type="html">創建加密raw系統鏡像</title><link href="https://xuebaxi.com/blog/2019-10-16-01" rel="alternate" type="text/html" title="創建加密raw系統鏡像" /><published>2019-10-16T00:00:00+00:00</published><updated>2019-10-17T00:00:00+00:00</updated><id>https://xuebaxi.com/blog/%E5%89%B5%E5%BB%BA%E5%8A%A0%E5%AF%86raw%E7%B3%BB%E7%B5%B1%E9%8F%A1%E5%83%8F</id><content type="html" xml:base="https://xuebaxi.com/blog/2019-10-16-01">&lt;p&gt;通過此方法生成的鏡像應用到伺服器後，可以在開機的時候使用ssh登陸後輸入密碼。&lt;/p&gt;
&lt;h2 id=&quot;創建虛擬塊設備&quot;&gt;創建虛擬塊設備&lt;/h2&gt;
&lt;p&gt;根據您的伺服器硬盤大小創建硬盤大小（一般來說10G即可）&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo dd &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/dev/zero &lt;span class=&quot;nv&quot;&gt;of&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;archlinux.raw &lt;span class=&quot;nv&quot;&gt;bs&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1M &lt;span class=&quot;nv&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;10240 &lt;span class=&quot;nv&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;progress &lt;span class=&quot;c&quot;&gt;#創建10G大小的鏡像&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;創建迴環設備&quot;&gt;創建迴環設備&lt;/h2&gt;
&lt;p&gt;將鏡像虛擬為迴環設備，為了對鏡像分區。&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;losetup &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; archlinux.raw
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h2 id=&quot;查看迴環設備&quot;&gt;查看迴環設備&lt;/h2&gt;
&lt;p&gt;可以得知/dev/loop0即鏡像,以下以/dev/loop0作為例子.&lt;/p&gt;
&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;[xuebaxi@xuebaxi ~]$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;losetup &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;/dev/loop0: [fd00]:26524 (/home/xuebaxi/archlinux.raw)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;對迴環設備分區&quot;&gt;對迴環設備分區&lt;/h2&gt;
&lt;p&gt;像對待普通硬碟使用fdisk將迴環設備分為:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;一個/boot分區&lt;/li&gt;
  &lt;li&gt;一個根分區&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;準備非boot分區&quot;&gt;準備非/boot分區&lt;/h2&gt;
&lt;p&gt;加密分區，創建文件系統並且掛載.&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cryptsetup &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; luksFormat /dev/loop0p2
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cryptsetup open /dev/loop0p2 cryptroot
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mkfs.ext4 /dev/mapper/cryptroot
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mount /dev/mapper/cryptroot /mnt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;準備boot分區&quot;&gt;準備/boot分區&lt;/h2&gt;
&lt;p&gt;創建文件系統並且掛載&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo mkdir&lt;/span&gt; /mut/boot
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mkfs.ext4 /dev/loop0p1
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mount /dev/loop0p1 /mnt/boot
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;生成密鑰&quot;&gt;生成密鑰&lt;/h2&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh-keygen &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; ed25519
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;將公鑰拷貝到鏡像&quot;&gt;將公鑰拷貝到鏡像&lt;/h2&gt;
&lt;p&gt;以密鑰名字為id_ed25519（默認名字）為例子&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mkdir -p /mnt/etc/tinyssh/root_key
cp ~/.ssh/id_ed25519.pub /mnt/etc/tinyssh/root_key
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;安裝archlinux&quot;&gt;安裝archlinux&lt;/h2&gt;
&lt;p&gt;參考&lt;a href=&quot;https://wiki.archlinux.org/index.php/Install_from_existing_Linux&quot;&gt;archlinux官方wiki&lt;/a&gt;,安裝完成後不要退出chroot.&lt;/p&gt;

&lt;h2 id=&quot;安裝遠程輸入密碼需要的包&quot;&gt;安裝遠程輸入密碼需要的包&lt;/h2&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pacman &lt;span class=&quot;nt&quot;&gt;-S&lt;/span&gt;  mkinitcpio-netconf  mkinitcpio-tinyssh mkinitcpio-utils
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;mkinitcpio設置&quot;&gt;mkinitcpio設置&lt;/h2&gt;
&lt;p&gt;編輯/etc/mkinitcpio.conf在MODULES中加入:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;virtio_pci virtio-net virtio-blk virtio_scsi sd_mod ext4
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;在HOOKS中加入&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;keyboard keymap encryptssh netconf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;注意netconf要在filesystems之前&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;重新生成initramfs&quot;&gt;重新生成initramfs&lt;/h2&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mkinitcpio &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; linux
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;注意: 如果遇到錯誤 libgcc_s.so.1 must be installed for pthread_cancel to work, 你需要將 /usr/lib/libgcc_s.so.1 添加到 “BINARIES” 中.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;設置啟動器&quot;&gt;設置啟動器&lt;/h2&gt;
&lt;p&gt;設置以下內涵參數,其中device-UUID 為/dev/loop0p2的UUID&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ip=dhcp cryptdevice=UUID=device-UUID:cryptroot root=/dev/mapper/cryptroot
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;退出chroot-環境&quot;&gt;退出chroot 環境&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;exit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;umount分區&quot;&gt;umount分區&lt;/h2&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;umount &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; /mnt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;卸載迴環設備&quot;&gt;卸載迴環設備&lt;/h2&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;losetup &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; /dev/loop0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>小學霸</name></author><category term="vps" /><category term="archlinux" /><summary type="html">通過此方法生成的鏡像應用到伺服器後，可以在開機的時候使用ssh登陸後輸入密碼。 創建虛擬塊設備 根據您的伺服器硬盤大小創建硬盤大小（一般來說10G即可） sudo dd if=/dev/zero of=archlinux.raw bs=1M count=10240 status=progress #創建10G大小的鏡像</summary></entry><entry><title type="html">透明代理配置</title><link href="https://xuebaxi.com/blog/transparent_proxy" rel="alternate" type="text/html" title="透明代理配置" /><published>2019-10-01T00:00:00+00:00</published><updated>2019-11-23T00:00:00+00:00</updated><id>https://xuebaxi.com/blog/%E9%80%8F%E6%98%8E%E4%BB%A3%E7%90%86%E9%85%8D%E7%BD%AE</id><content type="html" xml:base="https://xuebaxi.com/blog/transparent_proxy">&lt;h1 id=&quot;1-只有單個代理&quot;&gt;1. 只有單個代理&lt;/h1&gt;
&lt;h2 id=&quot;v2ray-配置&quot;&gt;V2ray 配置&lt;/h2&gt;
&lt;p&gt;在&lt;a href=&quot;https://v2ray.com/chapter_02/01_overview.html#inboundobject&quot;&gt;入站连接配置&lt;/a&gt;加入&lt;a href=&quot;https://v2ray.com/chapter_02/protocols/dokodemo.html#dokodemo-door&quot;&gt;任意門(Dokodemo-door)&lt;/a&gt;&lt;/p&gt;
&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;port&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12345&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;//开放的端口号&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;protocol&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;dokodemo-door&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;settings&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;network&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;tcp,udp&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;followRedirect&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;这里要为&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;才能接受来自&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;iptables&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;的流量&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;sniffing&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;enabled&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;destOverride&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;http&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;tls&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;在&lt;a href=&quot;https://v2ray.com/chapter_02/01_overview.html#outboundobject&quot;&gt;出站连接配置&lt;/a&gt;中的&lt;a href=&quot;https://v2ray.com/chapter_02/05_transport.html#%E5%BA%95%E5%B1%82%E4%BC%A0%E8%BE%93%E9%85%8D%E7%BD%AE&quot;&gt;streamSettings&lt;/a&gt;加入&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nl&quot;&gt;&quot;sockopt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;mark&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;在出站连接上标记 SO_MARK。(這邊建議不要用255,在我的環境下使用255會出問題)&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;仅适用于 Linux 系统。&lt;/li&gt;
  &lt;li&gt;需要 CAP_NET_ADMIN 权限。&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;系统设置&quot;&gt;系统设置&lt;/h2&gt;
&lt;h3 id=&quot;1-启用包转发&quot;&gt;1. 启用包转发&lt;/h3&gt;
&lt;p&gt;临时启用包转发：&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;sysctl net.ipv4.ip_forward&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;编辑/etc/sysctl.d/30-ipforward.conf使包转发可以永久地应用于所有接口上：&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;net.ipv4.ip_forward&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1
net.ipv6.conf.default.forwarding&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1
net.ipv6.conf.all.forwarding&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;2-加载tproxy模块&quot;&gt;2. 加载TPROXY模块&lt;/h3&gt;
&lt;p&gt;临时加载TPROXY模块:&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;modprobe xt_TPROXY
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;编辑/etc/modules-load.d/TPROXY.conf 使自动加载TPROXY模块：&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;xt_TPROXY
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;3-ipset-設置&quot;&gt;3. ipset 設置&lt;/h3&gt;

&lt;p&gt;添加保留地址&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ipset &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; reservedip nethash
ipset add reservedip 224.0.0.0/4
ipset add reservedip 100.64.0.0/10
ipset add reservedip 203.0.113.0/24
ipset add reservedip 192.18.0.0/15
ipset add reservedip 192.88.99.0/24
ipset add reservedip 172.16.0.0/12
ipset add reservedip 0.0.0.0/8
ipset add reservedip 127.0.0.0/8
ipset add reservedip 192.0.2.0/24
ipset add reservedip 192.51.100.0/24
ipset add reservedip 10.0.0.0/8
ipset add reservedip 192.168.0.0/16
ipset add reservedip 255.255.255.255
ipset add reservedip 192.0.0.0/24
ipset add reservedip 240.0.0.0/4
ipset add reservedip 169.254.0.0/16
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;添加不需要代理的地址&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ipset &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; noproxy nethash
ipset add noproxy &amp;lt;伺服器地址&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;4-iptables-設置&quot;&gt;4. iptables 設置&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;h4 id=&quot;tcp&quot;&gt;tcp&lt;/h4&gt;
    &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#/bin/bash&lt;/span&gt;
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; SS_SPEC_WAN_FW 
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; SS_SPEC_WAN_FW &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; tcp &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; REDIRECT &lt;span class=&quot;nt&quot;&gt;--to-ports&lt;/span&gt; 12345
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; SS_SPEC_WAN_AC
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; SS_SPEC_WAN_AC &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; tcp &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; mark &lt;span class=&quot;nt&quot;&gt;--mark&lt;/span&gt; 2
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; SS_SPEC_WAN_AC &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; reservedip dst &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; SS_SPEC_WAN_AC &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; noproxy dst &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN	
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; SS_SPEC_WAN_AC &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; SS_SPEC_WAN_FW
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h4 id=&quot;udp&quot;&gt;udp&lt;/h4&gt;
    &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#/bin/sh&lt;/span&gt;
ip rule add fwmark 0x01/0x01 table 100
ip route add &lt;span class=&quot;nb&quot;&gt;local &lt;/span&gt;0.0.0.0/0 dev lo table 100
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; V2RAY
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; V2RAY_MARK
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY  &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; reservedip dst &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY  &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; noproxy dst &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; mark &lt;span class=&quot;nt&quot;&gt;--mark&lt;/span&gt; 2
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; udp &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; TPROXY &lt;span class=&quot;nt&quot;&gt;--on-port&lt;/span&gt; 12345 &lt;span class=&quot;nt&quot;&gt;--tproxy-mark&lt;/span&gt; 0x01/0x01
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; reservedip dst &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; noproxy dst &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; mark &lt;span class=&quot;nt&quot;&gt;--mark&lt;/span&gt; 2
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; udp &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; MARK &lt;span class=&quot;nt&quot;&gt;--set-mark&lt;/span&gt; 1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;h3 id=&quot;5-启用iptables规则&quot;&gt;5. 启用iptables规则&lt;/h3&gt;
    &lt;h4 id=&quot;tcp-1&quot;&gt;tcp&lt;/h4&gt;
    &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt; PREROUTING 1 &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; tcp  &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; SS_SPEC_WAN_AC
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt; OUTPUT 1 &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; tcp &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; SS_SPEC_WAN_AC &lt;span class=&quot;c&quot;&gt;#對本機代理&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;h4 id=&quot;udp-1&quot;&gt;udp&lt;/h4&gt;
    &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; PREROUTING &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; V2RAY
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; OUTPUT &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; V2RAY_MARK
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;6-开机自动应用iptables规则&quot;&gt;6. 开机自动应用iptables规则&lt;/h3&gt;
&lt;p&gt;记录iptables规则：&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;iptables-save &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; /etc/iptables/iptables.rules
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;设置开机自动应用:&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;systemctl &lt;span class=&quot;nb&quot;&gt;enable &lt;/span&gt;iptables
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h1 id=&quot;2-有多個代理需要代理轉發&quot;&gt;2. 有多個代理，需要代理轉發&lt;/h1&gt;
&lt;h2 id=&quot;代理配置&quot;&gt;代理配置&lt;/h2&gt;
&lt;p&gt;此處以兩個代理為例子，使用此方法可以讓除最內層代理外的代理無法參看數據任何內容，起到保護隱私的作用。&lt;/p&gt;
&lt;h4 id=&quot;shadowsocks例子&quot;&gt;shadowsocks（例子）&lt;/h4&gt;
&lt;p&gt;外層代理（比如商業提供的代理）&lt;/p&gt;
&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;1.1.1.1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;server_port&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;108080&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;local_address&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;0.0.0.0&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;local_port&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12346&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;password&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;password&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;timeout&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;method&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;內層代理（這個建議使用自建的代理）&lt;/p&gt;
&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;2.2.2.2&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;server_port&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;108080&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;local_address&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;0.0.0.0&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;local_port&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12345&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;password&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;password&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;timeout&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;method&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h4 id=&quot;v2ray例子&quot;&gt;V2Ray(例子)&lt;/h4&gt;
&lt;p&gt;應該自己會寫吧（咕咕）&lt;/p&gt;
&lt;h2 id=&quot;系统设置-1&quot;&gt;系统设置&lt;/h2&gt;
&lt;h3 id=&quot;1-启用包转发-1&quot;&gt;1. 启用包转发&lt;/h3&gt;
&lt;p&gt;临时启用包转发：&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;sysctl net.ipv4.ip_forward&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;编辑/etc/sysctl.d/30-ipforward.conf使包转发可以永久地应用于所有接口上：&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;net.ipv4.ip_forward&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1
net.ipv6.conf.default.forwarding&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1
net.ipv6.conf.all.forwarding&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;2-加载tproxy模块-1&quot;&gt;2. 加载TPROXY模块&lt;/h3&gt;
&lt;p&gt;临时加载TPROXY模块:&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;modprobe xt_TPROXY
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;编辑/etc/modules-load.d/TPROXY.conf 使自动加载TPROXY模块：&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;xt_TPROXY
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;3-設置ipset&quot;&gt;3. 設置ipset&lt;/h3&gt;
&lt;p&gt;添加保留地址&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ipset &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; reservedip nethash
ipset add reservedip 224.0.0.0/4
ipset add reservedip 100.64.0.0/10
ipset add reservedip 203.0.113.0/24
ipset add reservedip 192.18.0.0/15
ipset add reservedip 192.88.99.0/24
ipset add reservedip 172.16.0.0/12
ipset add reservedip 0.0.0.0/8
ipset add reservedip 127.0.0.0/8
ipset add reservedip 192.0.2.0/24
ipset add reservedip 192.51.100.0/24
ipset add reservedip 10.0.0.0/8
ipset add reservedip 192.168.0.0/16
ipset add reservedip 255.255.255.255
ipset add reservedip 192.0.0.0/24
ipset add reservedip 240.0.0.0/4
ipset add reservedip 169.254.0.0/16
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;添加自己伺服器的地址&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ipset &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; myip nethash
ipset add myip 2.2.2.2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;添加不需要代理的地址&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ipset &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; noproxy
ipset add noproxy 1.1.1.1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;4-iptables-設置-1&quot;&gt;4. iptables 設置&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;h4 id=&quot;tcp-2&quot;&gt;tcp&lt;/h4&gt;
    &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#/bin/bash&lt;/span&gt;
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; SS_SPEC_WAN_FW
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; SS_SPEC_WAN_FW &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; myip dst &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; tcp &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; REDIRECT &lt;span class=&quot;nt&quot;&gt;--to-ports&lt;/span&gt; 12346 
&lt;span class=&quot;c&quot;&gt;#此處的2.2.2.2是上面例子中設置的內層服務器地址,12346是上面例子中外層服務器地址&lt;/span&gt;
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; SS_SPEC_WAN_FW &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; noproxy dst &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN &lt;span class=&quot;c&quot;&gt;#此1.1.1.1為最外層代理的ip&lt;/span&gt;
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; SS_SPEC_WAN_FW &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; tcp &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; REDIRECT &lt;span class=&quot;nt&quot;&gt;--to-ports&lt;/span&gt; 12345 &lt;span class=&quot;c&quot;&gt;#對其餘流量轉發到最內層代理&lt;/span&gt;
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; SS_SPEC_WAN_AC
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; SS_SPEC_WAN_AC &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; tcp &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; mark &lt;span class=&quot;nt&quot;&gt;--mark&lt;/span&gt; 2
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; SS_SPEC_WAN_AC &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; reservedip dst &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; SS_SPEC_WAN_AC &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; SS_SPEC_WAN_FW
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h4 id=&quot;udp-2&quot;&gt;udp&lt;/h4&gt;
    &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#/bin/sh&lt;/span&gt;
ip rule add fwmark 0x01/0x01 table 100
ip route add &lt;span class=&quot;nb&quot;&gt;local &lt;/span&gt;0.0.0.0/0 dev lo table 100
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-N&lt;/span&gt; V2RAY
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY      &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; udp &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; myip dst        &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; TPROXY &lt;span class=&quot;nt&quot;&gt;--on-port&lt;/span&gt;  12346 &lt;span class=&quot;nt&quot;&gt;--tproxy-mark&lt;/span&gt; 0x01/0x01 &lt;span class=&quot;nt&quot;&gt;--on-ip&lt;/span&gt; 0.0.0.0
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY                                                &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; mark &lt;span class=&quot;nt&quot;&gt;--mark&lt;/span&gt; 2
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY             &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; reservedip dst  &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY             &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; noproxy dst    &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY      &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; udp                                    &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; TPROXY &lt;span class=&quot;nt&quot;&gt;--on-port&lt;/span&gt; 12345 &lt;span class=&quot;nt&quot;&gt;--tproxy-mark&lt;/span&gt; 0x01/0x01 &lt;span class=&quot;nt&quot;&gt;--on-ip&lt;/span&gt; 0.0.0.0
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK        &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; reservedip dst &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK        &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;--match-set&lt;/span&gt; noproxy dst    &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK        &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; mark &lt;span class=&quot;nt&quot;&gt;--mark&lt;/span&gt; 2                   &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; RETURN 
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; V2RAY_MARK &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; udp                                    &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; MARK &lt;span class=&quot;nt&quot;&gt;--set-mark&lt;/span&gt; 1
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; PREROUTING                                           &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; V2RAY
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; OUTPUT                                               &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; V2RAY_MARK
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;h3 id=&quot;4-启用iptables规则&quot;&gt;4. 启用iptables规则&lt;/h3&gt;
    &lt;h4 id=&quot;tcp-3&quot;&gt;tcp&lt;/h4&gt;
    &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt; PREROUTING 1 &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; tcp  &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; SS_SPEC_WAN_AC
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nat &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt; OUTPUT 1 &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; tcp &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; SS_SPEC_WAN_AC &lt;span class=&quot;c&quot;&gt;#對本機代理&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;h4 id=&quot;udp-3&quot;&gt;udp&lt;/h4&gt;
    &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; PREROUTING &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; V2RAY
iptables &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; mangle &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; OUTPUT &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; V2RAY_MARK
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;5开机自动应用iptables规则&quot;&gt;5.开机自动应用iptables规则&lt;/h3&gt;
&lt;p&gt;记录iptables规则：&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;iptables-save &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; /etc/iptables/iptables.rules
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;设置开机自动应用:&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;systemctl &lt;span class=&quot;nb&quot;&gt;enable &lt;/span&gt;iptables
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;blockquote&gt;
  &lt;h3 id=&quot;参见&quot;&gt;参见&lt;/h3&gt;
  &lt;hr /&gt;
  &lt;h5 id=&quot;--ss-nat&quot;&gt;- &lt;a href=&quot;https://github.com/shadowsocks/shadowsocks-libev/blob/master/src/ss-nat&quot;&gt;ss-nat&lt;/a&gt;&lt;/h5&gt;
  &lt;h5 id=&quot;--archwiki-iptables&quot;&gt;- &lt;a href=&quot;https://wiki.archlinux.org/index.php/iptables&quot;&gt;ArchWiki iptables&lt;/a&gt;&lt;/h5&gt;
  &lt;h5 id=&quot;--project-v-official&quot;&gt;- &lt;a href=&quot;https://www.v2fly.org/&quot;&gt;Project V Official&lt;/a&gt;&lt;/h5&gt;
&lt;/blockquote&gt;</content><author><name>小學霸</name></author><category term="透明代理" /><category term="代理" /><summary type="html">1. 只有單個代理 V2ray 配置 在入站连接配置加入任意門(Dokodemo-door) { &quot;port&quot;: 12345, //开放的端口号 &quot;protocol&quot;: &quot;dokodemo-door&quot;, &quot;settings&quot;: { &quot;network&quot;: &quot;tcp,udp&quot;, &quot;followRedirect&quot;: true // 这里要为 true 才能接受来自 iptables 的流量 }, &quot;sniffing&quot;: { &quot;enabled&quot;: true, &quot;destOverride&quot;: [&quot;http&quot;, &quot;tls&quot;] } } 在出站连接配置中的streamSettings加入</summary></entry></feed>