Google 是一个强大的搜索引擎,本文主要介绍访问 Google 的方法。
TODOS 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 一些服务器的搭建 https://www.kejiwanjia.com/jiaocheng/zheteng/notes/77125.html https://www.wxlog.cn/assort/ IP地址查询 https://ip.skk.moe/ 定向流量免流 得有服务器,SSR/v2ray节点,节点得符合条件,端口80/443,然后改混淆 混淆HOST https://www.fbbi.pw/15.html https://github.com/FreeMLV2Ray/V2Ray_ml/wiki/V2Ray免流手册 https://jacobsblog.xyz/%E5%85%8D%E6%B5%81%E6%B7%B7%E6%B7%86%E5%8F%82%E6%95%B0%E4%BB%85%E4%BE%9B%E5%8F%82%E8%80%83/ https://blog.mo0.top/archives/55/ 免流机场 https://www.somersaultcloud.xyz/auth/login http://www.xiaoyunml.com 免流教程 免流一般都得是Vmess https://www.xgiu.com/yidong_mianliu_jiaocheng https://www.duangks.com/archives/85/ https://tstrs.me/1492.html https://www.flyzy2005.com/tech/ssr-free-traffic/ http://www.itog.top/index.php/archives/20/wiz https://102345.xyz/jishu/v2ray-free-traffic/ https://www.cxyzjd.com/article/qq_41975868/114700256 https://www.wanuse.com/2021/12/blog-post_30.html 免费机场 https://www.mattkaydiary.com/search/label/vpn https://bulink.xyz 资料 https://guide.v2fly.org/ https://www.v2fly.org/ https://docs.cfw.lbyczf.com/
相关知识 原生 / 广播 IP 原生 IP 指由当地 ISP 运营商提供的本地 IP,广播 IP 是 IP 分配机构指派在某个地区使用的 IP。可通过以下网站查看 IP 地址的归属地,归属地与服务器所在地一致的为原生 IP。
DNS DNS 服务器可分为 DNS over HTTPS(DoH)和 DNS over TLS(DoT)。
DoH 为以 https://
开头的 DNS 服务器,拥有更好的伪装性,且几乎不可能被运营商或网络管理封锁,但查询效率和安全性可能略低。
DoT 为以 tls://
开头的 DNS 服务器,拥有更高的安全性和查询效率,但端口有可能被管制或封锁。
运行模式 Clash/Surge 可开启接管互联网功能,管理连接到同一局域网中的设备,该模式被称为网关模式。
通过软路由安装翻墙插件的方式,可使部分无法安装翻墙工具的设备实现翻墙,该代理方法被称为透明代理。
类型
说明
全局直连
所有的流量会被直接转发,不会经过任何处理
自动分流
通过设定的规则动态控制相关的请求后续如何处理
全局代理
所有的流量都会经过代理转发
访问方法 访问网络通过数据包的传递
完成。网站实际上是一个服务器,用户向服务器发送数据包,服务器返回相应的数据包,就完成了访问网站的流程。
每台服务器都有一个 IP地址
,比如百度的 IP 地址是 14.215.177.39,Google 的 IP 地址经常变动。为了便于记忆,用域名把每个 IP 地址一一对应,这种对应则需要 DNS
。向 DNS 提供域名,DNS 返回正确的 IP 地址,即可访问到正确的网站。高墙则建在用户和网站之间。可通过以下方式完成与外网的连接。
SSH 隧道 SSH 原本用于 UNIX 类系统的远程登录和管理。由于 SSH 可以通过客户端软件,在本地做一个 SOCKS 代理进行加密转发,因此也被用于网络代理。配合浏览器插件和自动列表,可实现对不同网址有选择性地代理。
有一台支持 SSH 的墙外服务器后,在客户端执行如下命令即可打通隧道。
1 ssh -D 7001 username@remote-host
上述命令中 - D 表示动态绑定,7001 表示本地 SOCKS 代理的侦听端口,username@remote-host 为登录远程服务器的用户名和主机。
VPN VPN 通过建立虚拟网卡的方式接管流量,无限接近最底层。
现 VPN 基本无法用于翻墙。比较常见的 VPN 隧道协议有 PPTP VPN、L2TP VPN、OpenVPN、SSH 代理等。
PPTP VPN PPTP 协议是点对点隧道协议,其将 TCP 控制包与数据包分开,适合在没有墙限制的网络中使用。
L2TP VPN L2TP 能以隧道方式使 PPP 包通过各种网络协议,但没有任何加密措施,更多是和 IPSec 协议结合使用提供隧道验证。支持 PPTP 的设备基本都支持 L2TP,需要选择 L2TP/IPSec PSK 方式且设置预共享密钥 PSK
L2TP 使用 UDP 协议,一般可穿透防火墙,适合在有防火墙限制的局域网用户,如公司、网吧、学校场合等使用。PPTP 和 L2TP 二个连接类型在性能上差别不大。
OpenVPN OpenVPN 是一个基于 SSL 加密的纯应用层 VPN 协议,是 SSL VPN 的一种,支持 UDP 与 TCP 两种方式。通常 UDP 的效率会比较高,速度也相对较快。其运行在纯应用层,避免了 PPTP 和 L2TP 在某些 NAT 设备后面不被支持的情况,并且可以绕过一些网络的封锁。基本上能上网的地方就能用 OpenVPN。
OpenVPN 客户端软件可以很方便地配合路由表,实现不同线路(如国内和国外)的路由选择,实现一部分 IP 走 VPN,另一部分 IP 走原网络。
OpenVPN 目前已被墙用流量特征识别等技术手段侦测并受到严重封杀。
协议比较 1 2 3 4 5 6 7 8 9 10 11 12 13 14 // 易用性 PPTP>L2TP>OpenVPN // 速度 PPTP>OpenVPN UDP>L2TP>OpenVPN TCP // 安全性 OpenVPN>L2TP>PPTP // 稳定性 OpenVPN>L2TP>PPTP // 网络适用性 OpenVPN>PPTP>L2TP
代理 正向代理 正向代理一般都是 C/S 架构的,它通过客户端,将你要访问某站的请求打包,然后发给代理服务器,而代理服务器负责将你的请求发送给目标站。类型分为 HTTP 代理、FTP 代理、SSL 代理、Socks 代理等。正向代理又会根据高度匿名与否,分为高度匿名代理、普通匿名代理、透明代理等。
Socks 代理 Socks 代理通过 TCP 连接把目标主机和客户端连接在一起,并转发所有的流量,而不关心协议。该代理能在 Session 层之上的任何端口或协议下运行。Socks4 只支持 TCP 连接,而 Socks5 在其基础上增加了安全认证以及对 UDP 协议的支持,即 Socks5 支持密码认证以及转发 UDP 流量。
Socks 代理在任何情况下都不会中断 server 与 client 之间的数据,当墙不允许访问外网时,可以通过 Socks 代理来上网。
Socks 协议非明文,但在 Socks 代理服务器上可以还原出 TCP 和 UDP 的原始流量。
大多数的浏览器都支持 Socks 代理。浏览器上网的时候需要与目标主机建立 TCP 连接,这个时候浏览器就会告诉 Socks 代理,它想与目标主机进行通讯,然后 Socks 代理就会转发浏览器的数据,并向目标主机发出请求,再把返回的数据转发回来。
HTTP 代理 HTTP 代理跟 Socks 的原理类似,用处也基本相同,都是让处于防火墙下的主机与外界建立连接。
与 Socks 代理不同的是,HTTP 代理可以中断连接(即在中间截断数据流),因为 HTTP 代理是以 HTTP 请求为基础的,而这些请求大多以明文形式存在,所以 HTTP 代理可以在客户端和下游服务器中间窃听,修改数据。且 HTTP 不支持转发 UDP。
由于 HTTP 代理只能处理 HTTP 请求,所以 HTTP 代理服务器就可以根据你提交的数据来把资源缓存下来,提升访问的速度。很多 ISP 采用 HTTP 代理,因为用户都需要访问 80 端口,而 80 端口可由 ISP 进行控制。
HTTP 协议属于应用层,而 SOCKS 协议属于传输层。传输层在网络层之下,这使得 Socks 代理的作用更为广泛。
反向代理 假设大型网站服务器有一台,而后端负责计算的服务器有 N 台。真正的服务器在这 N 台服务器,它们通过某些机制同步内容。前端的服务器只负责收发数据,在前端接收到请求之后,就会根据后台某服务器的空闲资源完成请求的反向代理,从而达到了负载均衡的目的。
透明代理 此处的透明并不是正向代理的分支,而是路由器上的各种代理,这种代理相对电脑来说是透明的。在路由器上使用透明代理,一般是使用 Socks5 代理或 VPN。
专门协议 包括 V2Ray、shadowsocks(SS)、shadowsocksR(SSR)、wireguard、brook、outline 等,这些协议隐蔽性相对较高,加密方式相对完善。现 SSR 遭封禁严重,V2Ray 和 SS 是主流协议。
这些协议都是通过连接到一台墙未封禁的国外服务器,让该服务器访问被墙封锁的网站后返回相应数据,从而达到翻墙的目的,向国外服务器传输数据的过程是加密的、不具有明显特征的。这些服务器一般称为 VPS,VPS(Virtual Private Server,虚拟专用服务器)可以理解为安装到电脑上的虚拟机,这些虚拟机相互独立。
Shadowsocks Shadowsocks 有服务端和客户端。客户端监听 1080 端口,并将数据转发到 Socks 服务器上。这种转发在会话层,是加密的,所以墙过滤的难度很大。服务端收到数据后将数据发送到目标请求,收到反馈后再传给本地客户端的 1080 端口,完成 TCP 连接。
Shadowsocks (R) 的历史可查看以下链接。
1 https://github.com/KeiKinn/ShadowsocksBio
obfs 混淆 obfs 混淆最大的作用是对 Shadowsocks 流量进行伪装。添加 obfs http 模式之后,通过运营商的流量会被识别为设定好的网址的流量。
tls 模式安全性高于 http 模式。
自建 VPS 自己购买 VPS 并搭建协议。
机场 机场
指提供节点服务的供应商。节点
可以理解为服务器,机场会通过 Subscribe
提供等级不同的节点,形式是一个 URL
。
可通过以下链接查看各机场测速结果。
1 https://www.duyaoss.com/
部分机场可查看以下链接。
1 https://github.com/cadencando/SSSSRV2RayTrojanClash
线路 CN2 线路 CN2 即 CNCN,相比普通的 163 骨干网更好。注意区分单向 CN2 和双向 CN2。
BGP 线路 BGP 即边界网关协议,可识别运营商并自动选择最优线路。
PCCW 线路 香港线路。
IPLC/IEPL 专线 直接用网线连接中国大陆与其它地区,无需过墙,如深港 IPLC 专线。
安全须知 不要使用 360 系和百度系的产品,其会自动上报 IP 地址,很容易使所用服务器遭到封禁。不要用国内浏览器,推荐用 Google Chrome
或 Microsoft Edge
。浏览器可打开不跟踪
请求,且可将系统语言改为服务器所在地语言会进一步提升安全性。同时尽量减少让国内网站走代理的情况出现,会增加被墙几率。
浏览网页时可通过以下插件,强制使用 HTTPS。
1 https://www.eff.org/https-everywhere
墙封锁技术 网站封锁列表 1 https://github.com/gfwlist/gfwlist
发帖与回溯流程
情况
浏览流程
回溯流程
暴露概率
不用代理
发帖人 - ISP - 服务器托管商 - 服务器
网监 - 服务器 IP - 发帖人 IP - 发帖人 ISP - 档案
100%
一层私有 VPN
发帖人 - ISP-VPN - 服务器托管商 - 服务器
网监 - 服务器 IP-VPN 的 IP - 路由日志 - 链接者 IP - 链接者 ISP - 办网档案
100%
一层共用 VPN
发帖人 - ISP-VPN - 服务器托管商 - 服务器
网监 - 服务器 IP-VPN 的 IP - 入侵 VPN 服务器 - 日志 - 链接者 IP - 链接者 ISP - 办网档案
80%
两层私有 VPN
发帖人 - ISP-VPN1-VPN2 - 服务器托管商 - 服务器
网监 - 服务器 IP-VPN2 的 IP - 入侵 VPN2 服务器 - 日志查 VPN1 - 路由日志 - 链接者 IP - 链接者 ISP - 办网档案
40%
两层共用 VPN
发帖人 - ISP-VPN1-VPN2 - 服务器托管商 - 服务器
网监 - 服务器 IP-VPN2 的 IP - 入侵 VPN2 服务器 - 日志查 VPN1 - 日志 - 链接者 IP - 链接者 ISP - 办网档案
25%
N 层私有 / 公用 VPN,发帖人有 QQ
发帖人 - ISP-VPN1-VPN2-VPN3-VPN*n 服务器托管商 - 服务器
网监 - 服务器 IP - 访问网站 - 发帖人常用用户名 - 谷歌(百度)一下 - 查到 QQ - 找腾讯查近期登录 IP
100%
N 层私有 / 公用 VPN,发帖人无 QQ
发帖人 - ISP-VPN1-VPN2-VPN3-VPN*n 服务器托管商 - 服务器
网监 - 服务器 IP - 访问网站 - 发帖人常用用户名 - 谷歌(百度)一下 - 查到其他论坛注册的 ID - 找管理员查注册(登录)IP
100%
N 层私有 / 公用 VPN,发帖人无其它信息
发帖人 - ISP-VPN1-VPN2-VPN3-VPN*n 服务器托管商 - 服务器
网监 - 服务器 IP - 访问网站 - 无常用用户名 - 根据发帖内容(如北京市海淀区 XX 小区)- 监控整个小区宽带 - 分析 - 找到 IP
80%
IP 封锁 原理 墙通过将 IP 拉入黑名单以完成封锁。Goagent、XX-NET、Hosts 方式通过 IP 访问谷歌或者其他被屏蔽的网站。现在大量谷歌 IP 被拉黑,而这些方法依然在扫描隐藏的谷歌 IP,待 IP 消耗完毕后,这些方法则会失效。
2018 年初开始,墙的封锁方式从全部协议封锁改为了 TCP 封锁(阻断),主要特征为 Ping IP 正常连通(ICMP 协议),而 TCPing IP 连接超时无回应(TCP 协议)。因此可通过 Ping IP 和 TCPing IP 确定服务器 IP 是否被墙。
服务器 IP 被 TCP 封锁(阻断)后,依然可以正常的向服务器发送数据,但服务器返回数据时,墙发现 IP 在黑名单中,于是就会阻断、拦截,SSR 上表现为超时或空连。
目前的代理软件基本都在使用 TCP 协议进行传输。TCP 协议要传输数据先要进行握手,而当墙对海外代理服务器回程 TCP 阻断的时候,就会导致代理客户端与服务端无法完成握手,自然也无法使用代理。
墙通过分析流量特征判断该链接为代理的可能性,当可能性达到不同的程度时,墙做出不同的处理。其逻辑举例如下(10%/50%/80% 等仅用作举例),
检测到一个链接是代理的可能性低于 10%,那么就无视;高于 10%,则将 IP 的相关信息(及收集的证据、特征等)记录到数据库中,当下次再发现这个链接时,继续去收集证据判断是否为代理,若代理几率降低则无视,否则进一步关注;高于 50%,可能单独封一个端口(代理端口),若换个端口后继续做代理,则进一步关注,到了 80%,所有端口都被封禁。
解决方法 转换协议可以复活被墙的 IP。转换为 ICMP 速度太慢,故转换为 UDP 较好,但国内运营商往往会对 UDP QOS 限速。能把 TCP 转为 UDP 的软件有 KCPTun、Dragonite、V2ray(自带 KCP 协议)、Goflyway(自带 KCP 协议)。
也可使用 CDN 中转代理,而该方式需要 WebSocket,故可用 Goflyway 的 WS+CDN 模式或 V2ray 的 WS+CDN 模式。同时需要通过伪装以保证 CDN IP 的安全性,在使用 Goflyway 时往往搭配 HTTP 伪装,而使用 V2ray 时往往搭配 HTTP/HTTPS 伪装。HTTP/HTTPS 伪装有真正的网页,即浏览器打开域名会看到正常的网页,而代理客户端访问建立代理链接。
也可等待墙解封 IP。墙考虑到海外大量的 IDC 和国内购买海外服务器正常使用者 的体验和情绪,会定期解封 IP。每个做代理被墙的海外服务器 IP,墙都会根据不同情况设定一个解封时间, 如果解封时间内该海外服务器 IP 没有向国内发送数据或者尝试建立代理连接,那么墙就会解封该 IP。被解封的海外服务器 IP,短时间内再用于代理用途,往往很快就又会封禁。
因此可以关闭或删除服务器上面的代理软件,然后闲置该服务器,不要 Ping/TCPing 这个服务器,一段时间后应当会解封。墙还可能定期对被墙 IP 的服务器主动探测,看看代理软件是否还在运行,所以必须要关闭代理软件。
封锁几率 在日本、美国被墙几率高。
使用 SSR 代理时可搭配服务端的 redirect 参数做真实网站,或就用原版混淆插件(plain)。ShadowsocksR 服务端伪装成正常网站流量的教程如下。
1 https://doubibackup.com/hi10k-7p-5.html
DNS 污染 原理 DNS 污染是指一些刻意制造或无意中制造出来的域名服务器分组,把域名指往不正确的 IP 地址。
一般来说,网站在互联网上一般都有可信赖的域名服务器,但为减免网络上的交通,一般的域名都会把外间的域名服务器数据暂存起来,待下次有其他机器要求解析域名时,可以立即提供服务。一旦有相关网域的局域域名服务器的缓存受到污染,就会把网域内的电脑导引往错误的服务器或服务器的网址。
假设 A 为用户端,B 为 DNS 服务器,C 为 A 到 B 链路中一个节点的网络设备(路由器、交换机、网关等)。现 A 需访问 Google,故 A 向 B 通过 UDP 方式发送查询请求。这个数据在前往 B 时要经过 C。DNS 端口为 53,C 对此进行特定端口监视扫描,对 UDP 明文传输的 DNS 查询请求进行特征和关键词匹配分析,从而立刻返回一个错误的解析结果。作为链路上的一个节点,C 必定比 B 更快的返回结果到 A,而目前的 DNS 解析机制策略是只认第一,因此 C 所返回的查询结果就被 A 当作了最终结果,由此获得了错误的 IP。
干扰也可以通过网络服务提供商提供的 DNS 服务器进行 DNS 欺骗,当使用此 DNS 服务器的网络用户访问此特定网站时,DNS 服务便给出虚假的 IP 地址,导致访问网站失败,甚至返回 ISP 运营商提供的出错页面和广告页面。
可通过 nslookup
命令查看域名被解析出的 IP 地址。如果 IP 与域名服务器明显不同,如 8.7.198.45
,则可证明受到了 DNS 污染。
全球一共有 13 组根域名服务器,目前中国大陆有 F、I 这 2 个根域 DNS 镜像,但现在均已因为多次 DNS 污染外国网络,而被断开与国际互联网的连接。
解决方法 对于站长,换域名或者 IP 即可。
对于用户,可使用翻墙软件。也可在 hosts 添加受到污染的 DNS 地址,或使用 DNSCrypt 软件。
若使用 Firefox,则可打开远程 DNS 解析功能。在地址栏中输入 about:config
, 找到 network.proxy.socks_remote_dns
,改成 true 即可。
SSL 连接阻断 墙会阻断特定网站的 SSL 加密连接,方法是通过伪装成对方向连接两端的计算机发送 RST 包(RESET)干扰两者间正常的 TCP 连接,进而打断与特定 IP 地址之间的 SSL(HTTPS,443 端口)握手(如 Gmail、Google 文件、Google 网上论坛等的 SSL 加密连接),从而导致 SSL 连接失败。
HTTP 劫持 原理 HTTP 传输协议是明文的,若网站服务器在海外,访问网站时就要通过国际宽带出口。在通过时,若被墙扫描到违规关键词,墙则会阻断 TCP 连接,主要错误为链接已重置、该网站已永久移动到其他地址等。
解决方法 HTTP 劫持可通过加 SSL 证书解决,网站全部内容都会被加密。但由于 HTTPS 在建立加密连接的时候需要一次握手,而这次握手是明文的,所以如果域名被重点关注,即使加上了 SSL 证书,也会在首次握手的时候由于关键词匹配而阻断 TCP 连接。
另一解决方法为域名备案并使用国内服务器,则不会通过墙。
封锁方式的选择 采用 IP 封锁时,所有的骨干路由器和国际出口的路由器都添加上和 Google 服务有关的 IP 黑名单,带有相关 IP 地址的数据包直接在半路就被丢包,这会给路由器带来很大负担且成本非常高。这种方法针对的多为非常重要的网站,对于普通网站,采用 DNS 污染即可。
对于 Google 的特殊操作 墙对 Google 部分服务器的 IP 地址实施某些端口的自动封锁,按时段对 www.google.com
和 mail.google.com
的几十个 IP 地址的 443 端口实施自动封锁,具体是每 10 或 15 分钟可以连通,接着断开,10 或 15 分钟后再连通,再断开,如此循环,令中国大陆用户和 Google 主机之间的连接出现间歇性中断,使其各项服务出现问题,由此显得问题出在 Google 自身。
网络层级 以下层级由高到低。
层级
在本层运行的工具
应用层
浏览器
表示层
会话层
SS/V2Ray/Trojan
传输层
游戏
网络层
ICMP(ping/trace)
数据链路层
VPN(PPTP/L2TP/OpenVPN)/IEPL
物理层
IPLC
TCP 与 UDP TCP 为两者点对点连接,UDP 为广播连接。
网页 论坛 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 https://limbopro.xyz/ https://fanqiangdang.com/ https://www.ssrshare.com/ https://fangeqiang.com/ https://www.flyzy2005.com/ https://iyideng.cloud/ https://52bp.org/index.html https://vpncn.blogspot.com/ https://doubibackup.com/ https://www.vpsdawanjia.com/ https://program-think.blogspot.com/ https://program-think.medium.com/ // 已遍历至2020-10-29【2020年双11活动集中分享!看这里就够了!】 https://51.ruyo.net/
免费 VPS 1 2 https://freeserver.us/ https://www.youneed.win/
现成工具 云浏览器 1 2 3 4 https://hyperbeam.com/app/register https://neverinstall.com/ https://docs.microsoft.com/en-us/learn/modules/extend-elements-finance-operations/4-exercise https://docs.microsoft.com/en-us/learn/modules/implement-common-integration-features-finance-ops/10-exercise-1
加速器 1 2 3 4 5 6 7 8 9 10 https://tuntu.gy-idc.com/views/home https://www.nn.com/ https://www.chiyanjiasu.com/ http://ifengyun.com/ https://www.zhifool.com/ https://zzjiasuqi.com/ https://akspeedy.com/ https://www.ccspeed.cn/ https://www.biubiu001.com/ http://xunyou.mobi/#/
电脑端软件 翻墙 Chrome 浏览器 1 2 3 4 5 // 适用于XP以上系统 https://github.com/Alvin9999/new-pac/wiki/%E9%AB%98%E5%86%85%E6%A0%B8%E7%89%88 // 适用于XP https://github.com/Alvin9999/new-pac/wiki/%E4%BD%8E%E5%86%85%E6%A0%B8%E7%89%88
翻墙 Firefox 浏览器 1 https://github.com/Alvin9999/new-pac/wiki/%E7%81%AB%E7%8B%90%E7%BF%BB%E5%A2%99%E6%B5%8F%E8%A7%88%E5%99%A8
无界浏览 1 2 3 4 5 // Windows https://www.lanzous.com/i4eyu4b // Mac https://www.lanzous.com/i4eyt1c
Hotspot Shield 可在美区的 Mac App Store 找到。
windscribe 1 https://chn.windscribe.com/download
ProtonVPN 1 https://protonvpn.com/download
Psiphon
IPUnblock
tuxler
Privatix
WireGuard 打开以下链接以下载客户端。
1 https://www.wireguard.com/install/
打开 WireGuard,选择 add empty tunnel,复制 public key。打开以下链接并将刚才的内容复制到 your wireguard public key,点击 Add key 继续。
1 https://cryptostorm.is/wireguard
将生成的配置文件复制到 WireGuard 的 public key 下方配置信息框内,并删除以下字段。点击 active 激活即可。
1 2 [Interface] PrivateKey = YOUR_PRIVATE_KEY
OpenVPN 下载以下客户端。
1 https://openvpn.net/download-open-vpn/
也可下载以下第三方客户端。
1 https://www.sparklabs.com/viscosity/
可通过以下网站获取 OpenVPN 的配置文件。下载配置文件后导入到客户端即可。
1 2 https://www.vpnbook.com/freevpn https://www.vpngate.net/en/
手机端软件 Betternet/VPN 360 可在美区的 App Store 找到。
VPN Plus iOS 版可在美区的 App Store 找到。安卓版下载地址如下。
1 (Android)https://www.lanzous.com/i4ez8wd
老王 VPN 可在 Google Play 下载。若能连接到 Google Play,可找到非常多类似的软件。
1 https://www.lanzous.com/i4ezbla
蚂蚁加速器 1 https://b.lausera.com/c-1/a-agWjQ/
谷歌镜像 基本知识 分类 镜像网站有如下类别。
种类
含义
F1
通过服务器(如 Nginx)反向代理,服务器在海外或为 IPV6
F2
通过爬虫程序实时爬取并展示 Google 搜索的结果页
F3
通过定时全量数据同步,进行镜像分身,达到持久化的镜像,例如 composer 镜像或 npm 镜像,谷歌镜像不能使用这种方法
和代理的区别 代理是设置代理服务器,代理服务器转发下载请求,从而实现类似谷歌镜像的需求。
镜像是镜像站点已经提前镜像(下载)了资源,访问时直接从它的服务器上获取资源。
网站 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 https://www.gosearchresults.com/ https://www.lovec.ltd/ https://www.sanzhima.com/ http://g.histsci.org/ http://google.seek68.cn/ https://x.glgoo.top/scholar/ https://ac.scmor.com/ https://v2ray.party/ http://scholar.hedasudi.com/ https://ac.scmor.com/ https://google2.jiongjun.cc/ https://siguso.com/google/ https://ac.scmor.com/ https://coderschool.cn/1853.html # 三个问题的答案分别为 # 心灵之约 # 水朝夕 # csxy@123 http://g.luciaz.me/
Chrome 插件 谷歌访问助手破解版 1 https://www.lanzous.com/ial9x8b
Ghelper 1 http://googlehelper.net/
Chrome 商店访问助手
SetupVPN 1 https://setupvpn.com/download/
Tunhello
代理 该方法适合所有的系统,包括 Linux 和较旧的 Windows 系统,如 XP。
寻找代理节点 通过网站 在 Google 搜索免费代理节点
即可。
1 2 3 4 5 6 7 8 9 http://free-proxy.cz/ http://www.gatherproxy.com/zh/sockslist https://www.vpngate.net/en/ http://www.proxylists.net/ http://www.freeproxylists.net/zh/ https://free-proxy-list.net/ https://www.my-proxy.com/free-proxy-list.html https://sockslist.net/ https://premproxy.com/list/
通过工具 下载 ProxyScrape
,打开后选择 Check proxies
,填写所要求的代理服务器的 ping值
,ping 值越大,表明延迟越大。一般来说,公用的服务器 ping 值都会在 100ms 以上,因此可取 400-500。填写检查代理服务器的数量
,选择代理服务器的协议类型
,选择 Check from ProxyScrape.com
,工具就会开始筛选代理,并把可用的代理用绿色表示出来。
1 https://proxyscrape.com/proxy-checker
配置网络代理 设置软件代理 以网易云音乐为例,点击设置 - 工具,在代理选项卡下有三个选项,若选择使用 IE 代理设置,则需要提前设置好 IE 的代理。如果选择自定义代理,则在下拉菜单中选择代理类型,并输入服务器与端口(比如说所得结果为 1.2.3.4:5
,则服务器地址为 1.2.3.4,端口为 5),保存即可。
设置 IE 代理 打开 IE,点击右上方设置 - Internet 选项,选择连接 - 局域网设置,勾选为LAN使用代理服务器
,填好地址和端口,并勾选对于本机地址不使用代理服务器
,保存并退出。
设置全局代理 打开系统的设置 - 网络和 Internet - 代理,选择使用代理服务器
,填好地址和端口,并保存。
设置浏览器代理 以 Chrome 为例,打开 Chrome 网上应用店,搜索 SwitchyOmega
并安装(需要外网环境)。
下载完成后点击插件的选项,进入配置页面。点击情景模式的 proxy
,填写代理协议、代理服务器和端口。点击 auto switch
,切换规则只留 proxy
,默认情景模式设为直接连接
,在导入在线规则列表下,点击添加规则列表
并填入下面网址,点击立即更新情景模式
,保存后退出。此时可以禁用系统设置中的网络代理。
点击插件,选择 auto switch 或 proxy,即可访问外网。其中 proxy 相当于全局模式,auto switch 相当于 PAC 模式。
1 https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt
机场及公用节点 友明互联 0.01 元 / 天。
1 http://idc.ymhlw.cn/index.php/buy/index/
乐云 2 元 / 月。
1 https://www.renzhijia.com/buy/index/7/
Goflyway 免费账号 1 https://github.com/Alvin9999/new-pac/wiki/Goflyway%E5%85%8D%E8%B4%B9%E8%B4%A6%E5%8F%B7
公用节点 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 https://freevpn4you.net/ru/free-proxy.php https://github.com/hugetiny/awesome-vpn/blob/master/READMECN.md https://free-ss.site/ https://yzzz.ml/freessr/ https://www.liesauer.net/yogurt/subscribe?ACCESS_TOKEN=DAYxR3mMaZAsaqUb https://prom-php.herokuapp.com/cloudfra_ssr.txt https://view.freev2ray.org/ https://node.umelabs.dev/ https://www.youneed.win/free-ssr https://www.youneed.win/free-ss https://lncn.org/ https://www.nutgeek.com/ssshadowsocks/ https://usky.ml/tool/free_ssr https://trial.ssbit.win/ https://www.go2free.xyz/ https://gdmi.weebly.com/3118523398online.html https://free.yitianjianss.com/ https://ssrtool.us/tool/free_ssr https://github.com/Alvin9999/new-pac/wiki/ss%E5%85%8D%E8%B4%B9%E8%B4%A6%E5%8F%B7 https://github.com/Alvin9999/new-pac/wiki/v2ray%E5%85%8D%E8%B4%B9%E8%B4%A6%E5%8F%B7 http://ss.pythonic.life/ https://www.vpngate.net/cn/
SSH 隧道 使用 打开以下链接以创建账号。
1 https://www.speedssh.com/
下载以下客户端并输入从上述网站获取的 SSH 信息,22 为 SSH 默认端口。登录后进入 Services,勾选 SOCKS/HTTP proxy forwarding
,然后按照设置代理的方式进行设置即可。
1 https://www.bitvise.com/ssh-client-download
也可通过以下网站获取 SSH 账号。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 https://skyssh.com/ https://www.mytunneling.com/ https://bestvpnssh.com/ https://fullssh.com/ https://www.sshagan.net/ https://www.portssh.com/ https://www.jetssh.com/ http://free-ssh.xyz/ https://sshkit.com/ https://www.monthlyssh.com/ssh https://speedssh.com/ https://sshdropbear.net/ https://fastssh.com/ https://createssh.com/ https://cloudssh.us/
获取工具的方式 搜索引擎 使用 github/qwant/telegram 搜索相关翻墙软件的关键词,可使用 similarsitesearch 查询相似站点。
邮件 有些提供翻墙工具的公司 / 组织会开设一个邮箱,用于自动回复科学上网工具以及页面镜像地址,如发送标题 help
到 get@psiphon3.com
。
P2P 下载 连上某个 eMule 服务器后即可搜索 Tor 等相关工具。
1 https://www.emule-project.net/home/perl/general.cgi?l=42
其它特殊方法 可通过 QQ 邮箱或网易邮箱大师 APP,添加 Gmail 账户即可跳转到 Google 登录页面。点击下面的帮助
,在搜索框随便输入内容,然后点击在Google上搜索
即可。
自建服务器 通过国外服务器上搭建专门的翻墙协议,实现翻墙效果。
申请 在 Google 搜索 GCP 即可进入 Google Cloud Platform 的官网。GCP 是谷歌提供的服务器,新用户注册可免费获取 300 美元的赠金,在 12 个月内使用。
注册 GCP 的关键是通过银行卡认证。注册完成后点击左上角的菜单,选择结算
,可以看到剩余赠金和剩余试用日期。信用卡验证相关操作可查看附录。
搭建 创建防火墙规则 点击菜单中的 VPC 网络 - 防火墙规则,进入防火墙规则页面后,点击创建防火墙规则
,进入防火墙规则创建界面,配置如下。完成配置后点击创建即可。
项目
值
名称
entrance
优先级
1
流量方向
入站
对匹配项执行的操作
允许
目标
网络中的所有实例
来源 IP 地址范围
0.0.0.0/0
协议和端口
全部允许
同理,再创建一个防火墙实例,名称改为 exit
,流量方向为出站
,其余与上面的一致,保存。
创建 VM 实例 点击菜单中的 Compute Engine-VM 实例,点击创建,进入 VM 实例创建页面,配置如下。
项目
值
区域
建议 asia-east2(香港)或 asia-east1(台湾)
机器类型
建议微型
防火墙
勾选允许 HTTP 流量、允许 HTTPS 流量
网络
网络标记
刚才创建好的防火墙规则(enterance、exit)
创建完成后会有一个内部 IP 和一个外部 IP,打开命令提示符,输入 ping [外部IP]
查看 ping 值。如果 ping 值过大,则再创建一个新的实例,直到得到一台 ping 值小的服务器,注意不要把原来的实例删除,不然会分配到同一台服务器。正常服务器 ping 值在 100ms 以内。
搭建 V2Ray 协议 运行一键脚本 点击 VM 实例上的 SSH
按钮,等待命令行窗口出现。在命令行中输入以下命令以获取管理员权限,并执行 V2Ray 一键安装脚本。
1 2 sudo -i bash <(curl -s -L https://git.io/v2ray.sh)
协议配置 TCP 协议 在一键脚本配置协议时选择默认的 TCP
协议即可。TCP 协议速度快,但有被封端口的风险。
WS+TLS 协议 该协议安全性高,但需要域名且速度不及 TCP 协议。
进入以下网站并注册一个 cloudflare 账号,然后把注册好的域名加进去,添加时选择免费套餐。
1 https://www.cloudflare.com/zh-cn/
向域名的 DNS
添加一个 A 记录,Name 为二级域名,比如 hk.nionguan.ga
,Value 为服务器的 IP 地址,注册时 Proxy status
点成 DNS Only
。
然后到购买域名网页的后台,更改域名的 Nameserver 为 cloudflare 中指定的网址。更改完成后返回 cloudflare,点击 Done, Check...
并等待生效。
完成网站配置后,在脚本配置协议时选择 WS+TLS 协议即可。
多用户配置 请在完成 TCP 协议和 WS+TLS 协议的配置后进行以下操作。
在服务器输入以下命令以编辑 V2Ray 的配置文件。
1 vim /etc/v2ray/config.json
找到 inbound 段的代码并进行如下修改,注意每个用户的 UUID 应当一致。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 "inbounds": [{ "port": 8089, // WS+TLS "protocol": "vmess", "settings": { "clients": [{ "id": "71880ee2-4d15-47da-87b2-xxxxxxxxxx", "alterId": 64 }] }, "streamSettings": { "network": "ws", "wsSettings": { "path": "/nidebeibei" } } }, { "port": 8288, // TCP "protocol": "vmess", "settings": { "clients": [{ "id": "71880ee2-4d15-47da-87b2-xxxxxxxxxx", "alterId": 64 }] } }]
修改完成后重启 V2Ray 服务即可生效。
1 sudo systemctl restart v2ray
配置分享 得到 V2Ray 配置信息后复制,并输入 v2ray ssqr
生成二维码,以得到客户端配置。客户端配置方法可查看客户端配置一节。
功能 文件传输 在浏览器中点击 SSH 按钮并弹出窗口后,可点击窗口右上角,选择文件传输功能以从服务器下载内容,或上传内容到服务器。
快照 GCP 提供的快照功能能够备份磁盘内容,当内容丢失后可以用于恢复。新建 VM 实例时也可通过快照建立。
点击 Compute Engine 下的快照,建立即可。建立完成后,直接点击快照详情,即可用该快照建立实例,其磁盘内容完全一致。
镜像 GCP 可通过 Docker Hub 上的镜像部署 VM 实例。在部署示例时勾选将镜像应用到该实例
,并复制该实例的完整地址即可,如 hub.docker.com/_/wordpress
。
Nodejs 部署 在搜索框输入 node.js,点击 Node.js Certified by Bitnami
,按照操作即可。
GoormIDE GoormIDE 可以永久免费使用一个含 1GB 内存、10GB 存储空间的 VPS,但不能保持常开。
申请 打开以下链接并完成注册即可。
搭建 进入控制台后点击 New Container
。地区最好选择韩国,类型选择 Private,选择新建。新建完成后点击 Run,然后点击 Terminal 进行连接。
Socks5 连接协议 输入以下命令安装。
1 bash <(curl -s -L https://raw.githubusercontent.com/guleonseon/goorm-auto/master/install.sh)
回到 VPS 设置页,在 Port Forwarding 处填写 1080
并点击完成。客户端配置如下。
1 2 3 类型 / socks5 地址 / VPS的IP地址 端口 / 原端口(不是1080)
vmess 连接协议 输入以下命令以通过一键脚本安装,安装完成后记下配置,不要关闭窗口。
1 bash <(curl -s -L https://git.io/v2ray.sh)
回到 VPS 设置页,在 Port Forwarding 处填写刚才记下的端口号并点击完成,然后记下后面系统分配的新的端口号。在添加连接时,需要用新端口号替换旧的端口号,其余配置与脚本提供的一致。
返回终端页,运行以下命令以保持 V2Ray 运行。使用过程中需一直停留在该标签页上,每次重新开启服务器时,需查看配置是否被改变。
1 /usr/bin/v2ray/v2ray -config /etc/v2ray/config.json
Heroku 申请 打开以下链接并注册,注意需要翻墙环境。
1 https://dashboard.heroku.com/
搭建 V2Ray 打开以下链接部署 V2Ray,注意数据中心即为翻墙服务器地址。
1 https://github.com/bclswl0827/v2ray-heroku
完成部署后在后台查看刚才新建的项目,点击 Reveal Config Vars
并复制 UUID,在 Domains
下复制域名。打开客户端并进行配置,其中地址为刚才的域名,端口为 443,用户 ID 为刚才的 UUID,alterID 为 64,传输协议为 ws,打开 TLS 并允许不安全连接即可。
Shadowsocks 步骤基本同上,仓库如下。
1 https://github.com/onplus/shadowsocks-heroku
客户端配置中,地址为 app 域名,端口为 80,混淆为 websocket,路径为 /
。
Heroku CLI Heroku CLI 可用于在本地通过命令部署应用,下载链接如下。
1 https://devcenter.heroku.com/articles/heroku-cli#download-and-install
EUserv 申请 打开以下链接以注册。注意注册时地址选择中国,地址尽量真实,不需要翻墙环境。审核需要 24-48 小时,会核对注册时所用的 IP 地址和选择的地区是否匹配。若注册不通过则会被删除账号。
1 https://www.euserv.com/en/virtual-private-server/root-vserver/v2/vs2-free.php
搭建 重装系统 在后台点击 VSERVER
,看到服务器申请状态成功,即可点击 Select
进入服务器详情。进行系统安装时系统选择 CentOS 7
,然后点击左侧的 Serverdata
查看服务器信息,若 Default-Password 出现,则系统安装成功。
SSH 连接 由于该服务器只提供 IPV6 地址,而普通路由器不具备解析 IPV6 地址的能力,因此需要通过其它方式进行连接。
通过手机热点 手机热点自带 IPV6 地址。将电脑连接手机热点后,输入以下命令以确认服务器是否能够连接。
1 2 3 4 5 // Windows ping -6 [IPV6地址] // Mac ping6 [IPV6地址]
然后通过正常的 SSH 连接即可。
也可在手机端直接完成。安装 1.1.1.1
这一 APP 并连接,然后通过 SSH 软件连接即可。
通过网站 打开以下网站并注册,然后依次新建组织、项目、资产。
1 https://console.heyterm.com/
其中新建资产时相关配置如下。
1 2 3 4 IP地址 / IPV6地址或服务器域名 用户名 / root 密码 / Default-Password的内容 服务器节点 / 荷兰或德国
新建完成后点击终端按钮即可完成连接。
IPV4 配置 输入以下命令以更改 DNS 解析,使其可访问 IPV4 网络。
1 echo -e "nameserver 2001:67c:2b0::4\nnameserver 2001:67c:2b0::6" > /etc/resolv.conf
可通过以下命令查看是否设置成功。
然后通过以下命令修改文件,将 enable=1
改为 enable=0
后按照 vim 的方法保存(按 ESC 后输入:wq 并回车)。
1 vi /etc/yum/pluginconf.d/fastestmirror.conf
然后执行以下命令以进行升级并安装带有 IPV6 的宝塔。
1 2 yum update curl -sSO http://download.bt.cn/install/new_install.sh && bash new_install.sh
安装完成后输入 bt
进入管理界面,执行 8 修改端口为 8080,执行 5 和 6 修改用户名和密码。退出管理脚本后执行以下命令以取消登录面板安全保护。
1 rm -f /www/server/panel/data/admin_path.pl
为访问宝塔面板,需要进行域名解析。进入 Cloudflare 的后台,在 DNS
页选择一个域名后添加一条记录,内容如下。
1 2 3 4 5 6 7 8 9 10 类型 / AAAA 名称 / 二级域名,可任意 内容 / IPV6地址 代理状态 / 已代理 // 若上一条记录无法生效,则使用以下配置 类型 / CNAME 名称 / 二级域名,可任意 内容 / 域名,即Server name 代理状态 / 已代理
然后在 SSL/TLS
页修改模式为 Full (Strict)
,在 Firewall
页将 Security Level
改为 Essentially Off
。
宝塔配置 完成添加后通过以下链接访问宝塔面板,输入改好的用户名和密码即可登录。
登录后安装推荐的 LNMP,安装完成后点击左侧的软件商店
,分类选择一键部署
,选择博客
类型下的 WordPress
。域名填写登录宝塔面板的域名,注意不包括端口号,然后提交。
复制弹出窗口中的数据库账号资料,然后点击访问站点下的链接进行部署,其中相关信息需要填写刚才复制下来的内容。点击安装并等待完成即可。
部署完成后回到宝塔面板,点击左侧的网站
,可以看到刚才部署的 WordPress 博客。点击设置
,在 SSL
下选择 Let's Encrypt
,勾选域名并安装 SSL 证书。完成后可访问博客,查看能否正常运行。
安装 V2Ray 在完成网站搭建后即可开始安装 V2Ray。通过以下命令使用一键脚本安装即可。
1 bash <(curl -s -L https://git.io/v2ray.sh)
安装完成后利用宝塔面板的文件功能打开 etc/v2ray/config.json,用以下配置替换。其中 clients-id 为自己生成的 UUID。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 { "inbounds": [ { "port": 10000, // 可任意 "listen":"127.0.0.1", "protocol": "vmess", "settings": { "clients": [ { "id": "8195adc7-221d-4390-a9b2-d7642e44e46d", // 见下面说明 "level": 1, "alterId": 64 } ] }, "streamSettings": { "network": "ws", "wsSettings": { "path": "/hello" // 可任意 } } } ], "outbounds": [ { "protocol": "freedom", "settings": {} } ] }
完成后回到宝塔面板,点击网站
- 设置
- 配置文件
,在最后一个}
前加入以下代码。
1 2 3 4 5 6 7 8 9 10 11 location /hello { // 与上述配置文件中path下的目录一致 proxy_redirect off; proxy_pass http://127.0.0.1:10000; // 端口与上述配置文件中的port一致 proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; # Show realip in v2ray access.log proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
然后输入以下命令使 V2Ray 和 nginx 开机自启,并重启 V2Ray 使配置生效。
1 2 systemctl enable v2ray nginx systemctl restart v2ray
然后需要在宝塔打开端口。点击安全
,添加上述所使用的端口为放行端口,此处为 10000。添加完成后服务端配置即完成,客户端配置如下。
1 2 3 4 5 6 7 地址 / 访问WordPress的地址 端口 / 443 用户ID / 配置文件的clients-id 额外ID / 64 传输协议 / ws 路径 / 配置文件的streamSettings-path TLS / 打开,允许不安全
注意,安装完成后千万不要运行 bbrplus 加速脚本,否则将导致服务器无法连接。
Okteto现 Okteto 政策已不允许将云用于搭建代理。
失效教程
打开以下网页并用 Github 登录。
1 https://cloud.okteto.com
需在本机安装 Okteto 工具以完成部署。对于 MacOS,在终端运行以下命令。
对于 Windows,下载以下两个文件并放到 C:\Windows\System32
。
1 2 https://downloads.okteto.com/cli/okteto.exe https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/windows/amd64/kubectl.exe
其它平台可查看以下链接。
1 2 https://okteto.com/docs/getting-started/index.html https://kubernetes.io/docs/tasks/tools/install-kubectl
macOS 下进入终端,Windows 下管理员身份运行 cmd,执行以下命令。如果无法登录,则更换系统环境。
1 2 okteto login okteto namespace
新建文本文件,名称为 v2ray.yml
,内容如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 apiVersion: apps/v1 kind: Deployment metadata: name: v2-app spec: replicas: 1 selector: matchLabels: app: v2-app template: metadata: labels: app: v2-app spec: containers: - image: gingko/v2ray-nginx-websocket name: v2-app --- apiVersion: v1 kind: Service metadata: name: v2-app annotations: dev.okteto.com/auto-ingress: "true" spec: type: ClusterIP ports: - name: "http-port-tcp" port: 8080 selector: app: v2-app
保存后执行以下命令以部署。
1 kubectl apply -f [yml文件路径]
在客户端添加以下配置即可。
1 2 3 4 5 6 7 地址 / Endpoints的地址 端口 / 443 用户ID / f3c9cb27-746f-4e41-acf2-820bd3002676 传输协议 / ws 路径 / /fuckgfw_letscrossgfw TLS / 打开,允许不安全 额外ID / 100
失效教程(旧版)
打开以下仓库并 fork 到自己的 Github 上。
1 https://github.com/byxiaopeng/okteto-reboot
在自己 Fork 的项目下点击 Settings
-Secrets
,建立以下 Secret。
1 2 3 4 5 名称 / APITOKEN 内容 / 在Okteto控制台点击Settings,复制API Token到此 名称 / NAMESPACE 内容 / 控制台左上角的标注
回到控制台,点击 Deploy
,选择 Deploy from Git Repository
,仓库地址为刚才 Fork 的仓库,进行部署。
部署完成后,在客户端进行以下配置即可。
1 2 3 4 5 6 地址 / Endpoints的地址 端口 / 443 用户ID / ad806487-2d26-4636-98b6-ab85cc8521f7 传输协议 / ws 路径 / /ws TLS / 打开,允许不安全
Kubesail现在需要自行提供服务器。
失效教程
打开以下链接并完成注册。
打开以下链接,Fork 一份到自己的 Github。然后在 Kubesail 后台点击 Repos
,确认已经连接到自己的 Github 账号。
1 https://github.com/bclswl0827/v2ray-openshift
打开以下链接,Fork 一份后点击左侧的 Templates
,进入刚才 fork 的项目,点击 Settings
,将 Container Image
的路径更改为 [Github用户名]/v2ray-openshift
。点击 Launch Template
开始部署。点击 Status
,看到 V2Ray 在运行时则部署成功。
若部署失败,则点击左侧的 Resources
,将 Apps
下项目的 Settings
-Container Image
更改回 bclswl0827/v2ray-openshift
,保存。
1 https://kubesail.com/template/bclswl0827/v2ray
部署成功后需要将项目暴露在域名下。点击 Domains
,添加一个已经在 CloudFlare 部署好的网址,注意不要保留二级域名和其它路径。系统将会要求添加一个 TXT 记录完成验证,在 CloudFlare 后台添加即可,名称填 @
或者 root
。完成验证后按照提示添加一个 CNAME 记录,名称填 @
或者 root
,内容填系统所给出的网址,类型选择 DNS Only
,保存。
完成网址部署后返回刚才的项目,点击 Network
-Ingress
,Domain
选择刚才新建的域名,subdomain
留空,保存。
至此已将项目暴露到网页上,在客户端添加相关配置即可,具体如下。
1 2 3 4 5 6 7 地址 / 绑定的域名,注意没有二级域名和其它路径 端口 / 443 用户ID / 在项目中点击Edit YAML,在clients-id下 AlterID / 64 传输方式 / ws 路径 / /ws TLS / 打开,且允许不安全
IBM Cloud免费 30 天,免费期后会自动注销账号。
失效教程
打开以下链接进行注册即可。
进入后台并点击创建资源
,创建一个 Cloud Foundray 下的公共应用程序。区域选择达拉斯,套餐选择 256MB,配置资源选择 Go,名称填 ibmyes,完成创建。
创建完成后进入项目并点击右上角的终端符号以进入终端,注意切换地区为 Dallas。然后运行以下脚本进行安装即可。安装完成后用分享链接即可导入配置到客户端。
1 wget --no-check-certificate -O install.sh https://raw.githubusercontent.com/CCChieh/IBMYes/master/install.sh && chmod +x install.sh && ./install.sh
由于 IBM Cloud 十天不操作就会关机,所以需要十天重启一次。在 IBM Cloud 终端输入以下命令以获取相关参数。
1 2 ibmcloud login ibmcloud resource groups
其中 Region 中显示的地区需转换为区域编号,即 REGION_NUM
,对应关系如下。而第二个命令执行后 ID 一栏为资源组 id,即 RESOURSE_ID
。
1 2 3 4 5 6 7 8 1 / au-syd 2 / in-che 3 / jp-tok 4 / kr-seo 5 / eu-de 6 / eu-gb 7 / us-south 8 / us-east
登录 Github 并 Fork 以下项目。
1 https://github.com/CCChieh/IBMYes
在自己 Fork 的项目下点击 Settings
-Secrets
,建立以下四个 Secret。
1 2 3 4 5 6 7 8 9 10 11 名称 / IBM_ACCOUNT 内容 / 第一行账号,第二行密码 名称 / IBM_APP_NAME 内容 / ibmyes 名称 / REGION_NUM 内容 / 前面记下的区域编号 名称 / RESOURSE_ID 内容 / 前面记下的资源组id
保存后点击上方 Actions,应当看到 IBM Cloud Auto Restart 在执行。如果没有此 Action,到自己仓库的 /.github/workflows/ibm.yml,随便编辑后点击 Start commit
即可看到。
客户端配置 连接到服务器 V2Ray Windows XP 以上 V2RayN 下载 V2RayN-Core.zip,解压并打开 v2rayN.exe
。点击服务器,选择扫描屏幕上的二维码,客户端会自动扫描刚才生成的二维码并添加配置信息。如果无法生成二维码,则点击添加 Vmess 服务器,手动输入刚才保存的配置信息。
右键点击新增的服务器,选择设为活动服务器。然后在 V2RayN 的托盘图标点击右键,勾选启用 http 代理,并在 http 代理模式中选择 PAC 模式即可。
1 https://github.com/2dust/v2rayN/releases/
Windows XP 安装 从以下链接下载 Alvin9999 包含 V2Ray 作为翻墙工具的 Chrome 翻墙浏览器包,此处为 AllNew 全新版。
1 https://github.com/Alvin9999/new-pac/wiki/%E4%BD%8E%E5%86%85%E6%A0%B8%E7%89%88
该包中 V2Ray 和 goflyway 均可用。对于 goflyway,双击打开后可见本地代理,在浏览器中填写相应地址即可。
此处以 V2Ray 包进行说明。提取压缩包中的 V2Ray 文件夹,并修改里面的 config.json 为如下内容。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 { "log": { "access": "", "error": "", "loglevel": "warning" }, "inbound": { "port": 1080, "listen": "127.0.0.1", // procotol为V2Ray所映射代理的协议,默认为socks(socks5),由于XP原生不支持socks5,故改为http "protocol": "http", "domainOverride": [ "tls", "http" ], "settings": { "auth": "noauth", "udp": true, "ip": "127.0.0.1", "clients": null }, "streamSettings": null }, "outbound": { "tag": "agentout", "protocol": "vmess", "settings": { "vnext": [ { // 服务器地址及端口,需修改为自己的服务器IP或域名 "address": "server", "port": 10086, // 此处配置应与服务器配置的信息一致 "users": [ { "id": "b831381d-6324-4d53-ad4f-8cda48b30811", "alterId": 0, "email": "t@t.tt", "security": "aes-128-gcm" } ] } ], "servers": null }, "streamSettings": { "network": "tcp", "security": "", "tlsSettings": null, "tcpSettings": null, "kcpSettings": null, "wsSettings": null, "httpSettings": null }, "mux": { "enabled": true } }, "inboundDetour": null, "outboundDetour": [ { "protocol": "freedom", "settings": { "response": null }, "tag": "direct" }, { "protocol": "blackhole", "settings": { "response": { "type": "http" } }, "tag": "blockout" } ], "dns": { "servers": [ "8.8.8.8", "8.8.4.4", "localhost" ] }, "routing": { "strategy": "rules", "settings": { "domainStrategy": "IPIfNonMatch", "rules": [ { "type": "field", "port": null, "outboundTag": "direct", "ip": [ "0.0.0.0/8", "10.0.0.0/8", "100.64.0.0/10", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24", "192.0.2.0/24", "192.168.0.0/16", "198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "::1/128", "fc00::/7", "fe80::/10" ], "domain": null } ] } } }
精简文件夹,只保留以下文件。双击 v2ray.exe 即跳出 V2Ray 窗口,示意 V2Ray 已经运行。若运行 wv2ray.exe,则不显示窗口,在后台静默运行。
1 2 3 4 5 6 7 8 9 10 11 12 ├── doc │ └── ... ├── config.json ├── geoip.dat ├── geosite.dat ├── vpoint_socks_vmess.json ├── vpoint_vmess_freedom.json ├── v2ctl.exe ├── v2ctl.exe.sig ├── v2ray.exe ├── w2vray.exe └── w2ray.exe.sig
设置代理 软件代理 同理,这时 V2Ray 已经把服务器映射到本地代理 127.0.0.1:1080,注意类型为 http。XP 中可以配置 IE 代理,也可在 Chrome 浏览器中使用 SwitchOmega 配置,配置如下。
1 2 3 类型 / http 服务器地址 / 127.0.0.1 端口 / 1080
全局代理 若需要实现全局翻墙,则需要用到翻墙工具 Proxifier。
安装并打开软件,点击 Profile
菜单下的 Proxy Servers
,添加代理,配置同上。然后点击 Proxification Rules
修改翻墙规则,其中 v2ray.exe、wv2ray.exe 和翻墙服务器的地址(34.xx.xx.xx)需要使用 direct 模式,否则将会出现循环代理的情况。配置完成后点击 Name Resolution
,勾选 Resolve hostnames through proxy
以防止 DNS 污染,保存即可。使用时打开 v2ray.exe 或 wv2ray.exe,并打开 Proxifier 的开关即可。
为启动方便,可通过以下 bat 程序一键打开和关闭全局翻墙。打开记事本,复制代码并保存为相应文件后执行即可。
1 2 3 4 5 6 7 // 保存为startglobal.bat start wv2ray.exe stop Proxifier.exe // 保存为stopglobal.bat taskkill /f /im Proxifier.exe taskkill /f /im wv2ray.exe
由于 Proxifier 支持 socks5 协议,而 SwitchOmega 在 XP 下并不支持,因此若 V2Ray 选用 socks5 协议,只能实现全局翻墙而不能实现单一浏览器翻墙。
Mac V2RayX 与 Windows 客户端的配置类似。打开 APP 后点击菜单中的 Configure,输入刚才保存的服务器配置信息。然后在 Servers 中选择刚才新建的服务器,确保 V2Ray code 处于 load 状态,并勾选 PAC Mode,配置完成。
1 https://github.com/insisttech/v2rayX-copy/releases
V2RayU 与 V2RayX 类似,但提供订阅功能。
1 https://github.com/yanue/V2rayU/releases/
Android V2RayNG 下载 app-universal-release.apk,安装到手机并打开。点击上方 + 号并选择从二维码导入配置,扫描从服务端获取的二维码即可。也可点击手动输入进行导入。
然后点击左上角的菜单,选择设置,在路由模式中选择绕过中国大陆
。回到主页面,点击右下角的启动按钮,允许连接。
1 https://github.com/2dust/v2rayNG/releases
Linux Linux 没有图形客户端,故须按照以下配置。
下载 v2ray-linux-64.zip
,解压后放于 /tmp/v2ray
,并改名为 v2ray.zip
。
1 https://github.com/v2ray/v2ray-core/releases
打开终端并输入命令,下载好的脚本会放于终端工作路径。若无法下载,可使用文末附有的代码。
1 wget https://install.direct/go.sh
用文本编辑器打开下载好的 go.sh,找到 downloadV2Ray()
函数,删除函数内所有代码并 return 0
,如下所示。
1 2 3 downloadV2Ray(){ return 0 }
修改完成后在终端输入命令,等待 V2Ray 安装完成。
安装完成后输入以下命令以打开文件管理器。
转到 /etc/v2ray/config.json
,打开并将内容用下面的代码覆盖。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 { "log": { "access": "", "error": "", "loglevel": "warning" }, "inbound": { "port": 1080, "listen": "127.0.0.1", // SOCKS 地址及代理端口,在浏览器中需配置代理并指向这个端口,此处使用127.0.0.1:1080 "protocol": "socks", "domainOverride": [ "tls", "http" ], "settings": { "auth": "noauth", "udp": true, "ip": "127.0.0.1", "clients": null }, "streamSettings": null }, "outbound": { "tag": "agentout", "protocol": "vmess", "settings": { "vnext": [ { // 服务器地址及端口,需修改为自己的服务器 IP 或域名 "address": "server", "port": 10086, // 此处配置应与服务器配置的信息一致 "users": [ { "id": "b831381d-6324-4d53-ad4f-8cda48b30811", "alterId": 0, "email": "t@t.tt", "security": "aes-128-gcm" } ] } ], "servers": null }, "streamSettings": { "network": "tcp", "security": "", "tlsSettings": null, "tcpSettings": null, "kcpSettings": null, "wsSettings": null, "httpSettings": null }, "mux": { "enabled": true } }, "inboundDetour": null, "outboundDetour": [ { "protocol": "freedom", "settings": { "response": null }, "tag": "direct" }, { "protocol": "blackhole", "settings": { "response": { "type": "http" } }, "tag": "blockout" } ], "dns": { "servers": [ "8.8.8.8", "8.8.4.4", "localhost" ] }, "routing": { "strategy": "rules", "settings": { "domainStrategy": "IPIfNonMatch", "rules": [ { "type": "field", "port": null, "outboundTag": "direct", "ip": [ "0.0.0.0/8", "10.0.0.0/8", "100.64.0.0/10", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24", "192.0.2.0/24", "192.168.0.0/16", "198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "::1/128", "fc00::/7", "fe80::/10" ], "domain": null } ] } } }
保存后在终端 Ctrl+C
并输入下面的命令,使 V2Ray 开机自启,并启动 V2Ray 查看状态。如果显示绿色,证明 V2Ray 已成功运行。
1 2 3 sudo systemctl enable v2ray sudo systemctl start v2ray sudo systemctl status v2ray
这时 V2Ray 已经把服务器映射到本地代理 127.0.0.1:1080,按照配置代理的方式即可。
1 2 3 类型 / Socks5 服务器地址 / 127.0.0.1 端口 / 1080
Shadowsocks Windows shadowsocks-windows 1 https://github.com/shadowsocks/shadowsocks-windows/releases/
obfs 插件下载链接如下。
1 https://github.com/shadowsocks/simple-obfs/releases
将插件 obfs-local 与 Shadowsocks.exe 放于同一路径下即可。obfs 可以直接在 Shadowsocks 的服务器编辑页面修改参数,示例如下。
1 obfs=http;obfs-host=www.bing.com
Mac ShadowsocksX-NG 内置 obfs 混淆。
1 https://github.com/shadowsocks/ShadowsocksX-NG/releases/
Android 可在 Google Play 上下载 Shadowsocks 应用,同时下载 obfs 插件 Simple Obfuscation。
也可到以下链接下载。
shadowsocks-android 1 https://github.com/shadowsocks/shadowsocks-android/releases/
iOS Shadowsocks 越狱设备可安装 Shadowsocks 插件。自带 Bigboss 源有该插件。
Linux 1 https://github.com/shadowsocks/shadowsocks-qt5/
Trojan Windows V2RayN 与 V2Ray 的 Windows 客户端相同。
Android igniter 1 https://github.com/trojan-gfw/igniter/releases/
WireGuard 可使用 TunSafe。注意该软件为全局代理软件。
打开以下链接并下载 Standalone TunSafe-TAP Installer 9.21.2
和 TunSafe 1.4 Standalone Zip for 64-bit systems
。
1 https://tunsafe.com/download
下载完成后需要获取配置文件。打开软件,选择 File-Browse in Explorer,打开配置文件并选择对应节点即可。
iOS 端说明 未越狱 iOS 端没有各协议的官方客户端。常用的第三方客户端有 Shadowrocket、Quantumult 和 Kitsunebi 等,均需在美区 App Store 下载。
Kitsunebi 支持 V2Ray(WS/TCP)、Shadowsocks。
打开 Kitsunebi,选择服务器,点击右上方 + 号并选择扫二维码。然后把操作模式改到 Rule
,传出代理选择刚才添加的服务器。完成设置后,在状态页开启 VPN 开关即可。
Shadowrocket 支持 V2Ray(WS/TCP)、Shadowsocks、Trojan。支持 http 和 tls 两种模式的 obfs 混淆。
Quantumult 支持 V2Ray(WS/TCP)、Shadowsocks。
全平台程序 Clash Clash 是翻墙内核,可用于多个平台。各平台之间的配置文件通用。注意 Clash 不支持 SSID Suspend。
下载与启动 Mac 可用 ClashX 和 ClashX Pro。ClashX Pro 相比 ClashX 增加了增强模式,可通过以下链接下载。
1 2 3 4 5 // ClashX https://github.com/yichengchen/clashX/releases/ // ClashX Pro https://install.appcenter.ms/users/clashx/apps/clashx-pro/distribution_groups/public
Android 可用 Clash for Android。
1 https://github.com/Kr328/ClashForAndroid
Windows/Linux 可用 Clash for Windows。
1 https://github.com/Fndroid/clash_for_windows_pkg/
Linux 需要下载带 linux 后缀的包。然后打开终端,切换到下载路径,运行以下命令。
1 2 3 4 5 6 7 sudo tar -zx [包名] -C /opt cd /opt sudo mv '[解压所得文件夹名]' clash cd clash # 该命令运行Clash ./cfw
配置 以下以 Mac 端的 ClashX 为例。
ClashX 通过配置文件配置订阅、策略组和分流。打开后点击配置 - 托管配置 - 管理,添加远程配置文件,即可远程下载。
将配置文件保存为 yaml 后,打开 ClashX 的配置 - 打开本地配置文件夹,复制配置文件到此目录,然后在 ClashX 的配置中选择文件。
完成配置导入后,将出站模式选为规则判断,并勾选设置为系统代理
即可使用。
配置文件中的通配符含义如下。可用' '
包住整个通配符语句,以避免语法冲突。
通配符
含义
示例
*
仅匹配第一层
*.ipv6.microsoft.com 可匹配 win1901.ipv6.microsoft.com,不可匹配 foo.win1901.ipv6.microsoft.com 和 ipv6.microsoft.com
.
匹配多层(不包括零)
.ipv6.microsoft.com 可匹配 win1901.ipv6.microsoft.com 和 foo.win1901.ipv6.microsoft.com,不可匹配 ipv6.microsoft.com
+
匹配多层(包括零)
+.ipv6.microsoft.com 可匹配 win1901.ipv6.microsoft.com,和 foo.win1901.ipv6.microsoft.com,以及 ipv6.microsoft.com
端口 1 2 3 4 5 6 7 8 9 10 11 12 13 14 # HTTP(S)代理端口 port: 7890 # SOCKS5代理端口 socks-port: 7891 # Linux和macOS的redir代理端口 # redir-port: 7892 # Linux的redir代理端口 # tproxy-port: 7893 # HTTP(S)与SOCKS5混合代理端口 # mixed-port: 7890
模式 可为 Rule(规则)、Global(全局代理)、Direct(全局直连)。
日志输出级别 默认级别 silent,即不输出任何内容。可选择 silent/info/warning/error/debug,共五个级别,级别越高表示日志输出量越大。
外部控制 通过 RESTful API 实现外部网站控制 Clash。
1 2 3 4 5 6 7 8 9 # clash的RESTful API external-controller: 127.0.0.1:9090 # 将静态网页资源(如clash-dashboard)放置在一个目录中,clash将会服务于${API}/ui # 参数应填写配置目录的相对路径或绝对路径 # external-ui: folder # RESTful API的口令 # secret: ""
接口
实验性功能 1 2 experimental: ignore-resolve-fail: true # 忽略 DNS 解析失败,默认值为 true
DNS 当访问一个域名时,nameserver 与 fallback 列表内的所有服务器并发请求,得到域名对应的 IP 地址。若解析结果中 IP 地址属于国外,则 Clash 将选择 fallback 列表内解析最快的结果,否则将选取 nameserver 列表内解析最快的结果。
注意,nameserver 应尽量选择中国大陆的 DNS,fallback 应尽量选择无污染的国外 DNS,且数量不应超过四个。
增强模式 enhanced-mode 可为 redir-host 或 fake-ip。在 redir-host 模式下,当客户端发起 DNS 请求时,Clash 将需要解析的域名发送到每一个上游 DNS 服务器,返回最快的一个结果。在 fake-ip 模式下,当客户端发起 DNS 请求时,Clash 直接返回一个虚假的 IP。
示例如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 dns: enable: true ipv6: false # listen: 0.0.0.0:53 # enhanced-mode: redir-host # fake-ip-range: 198.18.0.1/16 # fake-ip白名单列表 # fake-ip-filter: # - '*.lan' # - localhost.ptlogin2.qq.com nameserver: - 1.2.4.8 - 114.114.114.114 - 223.5.5.5 - tls://13800000000.rubyfish.cn:853 # - https://13800000000.rubyfish.cn/ fallback: - tls://13800000000.rubyfish.cn:853 - tls://1.0.0.1:853 - tls://dns.google:853 # - https://13800000000.rubyfish.cn/ # - https://cloudflare-dns.com/dns-query # - https://dns.google/dns-query fallback-filter: geoip: true ipcidr: # 在这个网段内的IP地址会被考虑为被污染的IP - 240.0.0.0/4
Host 指定 Hosts 条目,支持通配符,注意静态域名比通配域名具有更高的优先级。Hosts 在 fake-ip 模式下不生效。
1 2 3 hosts: '*.clash.dev': 127.0.0.1 'alpha.clash.dev': '::1'
添加节点 订阅节点在配置文件中的 proxies 部分定义,格式如下。注意 IPV6 地址需要用 []
框住。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 proxies: # Shadowsocks # 支持的加密方式如下 # aes-128-gcm aes-192-gcm aes-256-gcm # aes-128-cfb aes-192-cfb aes-256-cfb # aes-128-ctr aes-192-ctr aes-256-ctr # rc4-md5 chacha20-ietf xchacha20 # chacha20-ietf-poly1305 xchacha20-ietf-poly1305 - name: "ss1" type: ss server: server port: 443 cipher: chacha20-ietf-poly1305 password: "password" # udp: true - name: "ss2" type: ss server: server port: 443 cipher: chacha20-ietf-poly1305 password: "password" plugin: obfs plugin-opts: mode: tls # or http # host: bing.com - name: "ss3" type: ss server: server port: 443 cipher: chacha20-ietf-poly1305 password: "password" plugin: v2ray-plugin plugin-opts: mode: websocket # no QUIC now # tls: true # wss # skip-cert-verify: true # host: bing.com # path: "/" # mux: true # headers: # custom: value # Vmess # 支持的加密方式如下 # auto aes-128-gcm chacha20-poly1305 none - name: "vmess" type: vmess server: server port: 443 uuid: uuid alterId: 32 cipher: auto # udp: true # tls: true # skip-cert-verify: true # servername: example.com # priority over wss host # network: ws # ws-path: /path # ws-headers: # Host: v2ray.com - name: "vmess-h2" type: vmess server: server port: 443 uuid: uuid alterId: 32 cipher: auto network: h2 tls: true h2-opts: host: - http.example.com - http-alt.example.com path: / - name: "vmess-http" type: vmess server: server port: 443 uuid: uuid alterId: 32 cipher: auto # udp: true # network: http # http-opts: # # method: "GET" # # path: # # - '/' # # - '/video' # # headers: # # Connection: # # - keep-alive # Socks5 - name: "socks" type: socks5 server: server port: 443 # username: username # password: password # tls: true # skip-cert-verify: true # udp: true # Http - name: "http" type: http server: server port: 443 # username: username # password: password # tls: true # https # skip-cert-verify: true # sni: custom.com # Snell - name: "snell" type: snell server: server port: 44046 psk: yourpsk # version: 2 # obfs-opts: # mode: http # or tls # host: bing.com # Trojan - name: "trojan" type: trojan server: server port: 443 password: yourpsk # udp: true # sni: example.com # aka server name # alpn: # - h2 # - http/1.1 # skip-cert-verify: true # ShadowsocksR # 支持的加密方式与Shadowsocks完全一致 # 支持的obfs混淆如下 # plain http_simple http_post # random_head tls1.2_ticket_auth tls1.2_ticket_fastauth # 支持的加密协议如下 # origin auth_sha1_v4 auth_aes128_md5 # auth_aes128_sha1 auth_chain_a auth_chain_b - name: "ssr" type: ssr server: server port: 443 cipher: chacha20-ietf password: "password" obfs: tls1.2_ticket_auth protocol: auth_sha1_v4 # obfs-param: domain.tld # protocol-param: "#" # udp: true
也可通过订阅链接转换的方式获取,具体见翻墙进阶部分。
订阅节点 订阅节点在配置文件中的 proxy-provider 部分定义,参数如下。其中 url 对应的文件内容即为配置文件中的 proxies 部分,与上面一致。path 为该文件下载到本地后的存放位置。
参数
说明
type
http/file,分别为远程链接和本地文件
path
文件保存路径,可以为绝对路径,./ 相当于 Clash 配置文件所在文件夹
url
类型为 http 时,填写的 URL 链接
interval
类型为 http 时,订阅自动更新周期
health-check
健康检查选项
示例如下。
1 2 3 4 5 6 7 8 9 10 11 proxy-providers: provider: type: http url: https://example.com/example.yaml interval: 3600 path: ./proxyset/provider.yaml health-check: enable: true interval: 600 # lazy: true url: http://www.gstatic.com/generate_204
策略组 策略组在配置文件中的 proxy-groups 部分定义。
若需要将订阅节点写到策略组中,则将订阅名称写到 use 一栏下。若需要将单个节点写到策略组中,则将节点名称写到 proxies 一栏下。
策略组类型如下。
名称
类型
select
手动选择
url-test
延迟测试
fallback
健康检查
load-balance
负载均衡
relay
代理链
Clash 内置的策略组为 DIRECT 和 REJECT,但不包含 PROXY。示例如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 proxy-groups: - name: 手动选择 type: select use: - provider proxies: - AUTO - DIRECT - example-proxy - name: 延迟测试 type: url-test url: http://www.gstatic.com/generate_204 interval: 300 use: - provider - name: 健康检测 type: fallback url: http://www.gstatic.com/generate_204 interval: 300 use: - provider - name: 负载均衡 type: load-balance url: http://www.gstatic.com/generate_204 interval: 300 use: - provider # 流量流向为clash<->http<->vmess<->ss1<->ss2<->Internet - name: "relay" type: relay proxies: - select - vmess1 - ss1 - ss2
规则集 规则集在配置文件中的 rule-providers 部分定义,示例如下,参数与订阅节点一致。
1 2 3 4 5 6 7 rule-providers: Advertising: type: http behavior: classical path: ./RuleSet/Guard/Advertising.yaml url: https://cdn.jsdelivr.net/gh/DivineEngine/Profiles@master/Clash/RuleSet/Guard/Advertising.yaml interval: 86400
规则 规则在配置文件中的 rules 部分定义,类型如下。
匹配类型
匹配名称
DOMAIN-SUFFIX
域名后缀匹配
DOMAIN
域名匹配
DOMAIN-KEYWORD
域名关键字匹配
IP-CIDR
IPv4 段匹配
IP-CIDR
IPv6 段匹配
SRC-IP-CIDR
源 IP 段匹配
GEOIP
GEOIP 数据库(国家代码)匹配
DST-PORT
目标端口匹配
SRC-PORT
源端口匹配
MATCH
兜底匹配
RULE-SET
规则集匹配
示例如下,注意 no-resolve 选项表示跳过具有域请求的规则。应当在该部分指定规则集与策略组的关系,即该规则集使用哪个策略组。
1 2 3 4 5 6 7 8 9 10 11 12 13 rules: - DOMAIN-SUFFIX,google.com,auto - DOMAIN-KEYWORD,google,auto - DOMAIN,ad.com,REJECT - SRC-IP-CIDR,192.168.1.201/32,DIRECT - IP-CIDR,127.0.0.0/8,DIRECT - IP-CIDR,32.0.0.0/8,DIRECT,no-resolve - IP-CIDR6,2620:0:2d0:200::7/32,auto - GEOIP,CN,DIRECT - DST-PORT,80,DIRECT - SRC-PORT,7777,DIRECT - RULE-SET,providername,proxy - MATCH,auto
绕过系统代理 绕过系统代理在配置文件中的 cfw-bypass 部分定义,支持通配符,示例如下。最后一行对应系统中请勿将代理服务器用于本地(Intranet)地址
选项,请确保此项在最底部。
1 2 3 4 cfw-bypass: ... # 原有字段不用删除 - 'music.163.com' # 网易云域名1 - '*.music.126.net' # 网易云域名2
脚本 通过脚本编写配置文件,可实现代码控制的功能。注意需要将 mode 修改为 Script,示例如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 mode: Script script: # test规则集使用DIRECT策略组 code: | def main(ctx, metadata): if ctx.rule_providers["test"].match(metadata): return "DIRECT" # test和test2规则集使用DIRECT策略组 code: | def main(ctx, metadata): list = ['test', 'test2'] for name in list: if ctx.rule_providers[name].match(metadata): ctx.log('[Script] matched %s' % name) return "DIRECT" # GEOIP数据库匹配 code: | def main(ctx, metadata): code = ctx.geo_ip(ip) if code == 'CN' or code == 'LAN': return "DIRECT" # DNS解析错误时使用DIRECT策略组 code: | def main(ctx, metadata): ip = ctx.resolve_ip(metadata["host"]) if ip == "": return "DIRECT" # 源端口为3000-4000 code: | def main(ctx, metadata): srcport = metadata["src_port"] if (3000 < srcport and srcport < 4000): return "DIRECT" # 关键词匹配 code: | def main(ctx, metadata): rejectkeywordlist = ["adservice"] for rejectkeyword in rejectkeywordlist: if rejectkeyword in metadata["host"]: ctx.log('[Script] matched keyword %s use reject' % rejectkeyword) return "REJECT" # 时间参数 code: | def main(ctx, metadata): now = time.now() if metadata["src_ip"] == "ip" and now.hour => 18 and now.hour <= 22: return "REJECT" return "DIRECT"
ctx 可用方法如下。
函数名
参数类型
返回值类型
作用
resolve_ip(host)
string
string
DNS 解析匹配
resolve_process_name(metadata)
Metadata
string
进程名匹配
geoip(ip)
string
string
GEOIP 匹配
log(log)
string
void
日志
proxy_providers[name].match(metadata)
string
boolean
策略组匹配
rule_providers[name].match(metadata)
string
boolean
规则集匹配
metadata 可用参数如下。
函数名
作用
type
连接方法类型
network
网络类型
host
主机名
src_ip
请求的客户端 IP
src_port
请求的客户端端口
dst_ip
请求的目标 IP
dst_port
请求的目标端口
功能 局域网共享 勾选配置 - 允许局域网连接,即可开启局域网共享。在控制台可查看端口,一般为 8090。查看本机 IP 地址并记录,然后对连接到同一局域网即同一 Wi-Fi 下的设备设置代理 [IP地址]:8090
,即可使用本机的翻墙代理。
也可通过配置文件设置,示例如下。注意 bind-address 仅在 allow-lan 设置为 true 时生效,支持以下参数类型。
参数
含义
“*”
绑定所有 IP 地址
192.168.122.11
绑定一个 IPv4 地址
“[aaaa::a8aa:ff:fe09:57d8]”
绑定一个 IPv6 地址
1 2 3 4 5 6 7 8 allow-lan: false # bind-address: "*" # 本地SOCKS5/HTTP(S)服务认证 # authentication: # - "user1:pass1" # - "user2:pass2"
模式 TProxy 实现透明代理。
确保配置文件中没有 tun 字段。在 Linux 中需在终端输入以下命令,然后启动 Clash 即可。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 # 以下几种模式选择一种即可 ## Redir-Host iptables -t nat -N clash iptables -t nat -A clash -d 0.0.0.0/8 -j RETURN iptables -t nat -A clash -d 10.0.0.0/8 -j RETURN iptables -t nat -A clash -d 127.0.0.0/8 -j RETURN iptables -t nat -A clash -d 169.254.0.0/16 -j RETURN iptables -t nat -A clash -d 172.16.0.0/12 -j RETURN iptables -t nat -A clash -d 192.168.0.0/16 -j RETURN iptables -t nat -A clash -d 224.0.0.0/4 -j RETURN iptables -t nat -A clash -d 240.0.0.0/4 -j RETURN iptables -t nat -A clash -d "$local_ipv4" -j RETURN iptables -t nat -A clash -p tcp -j REDIRECT --to-port "$proxy_port" iptables -t nat -I PREROUTING -p tcp -d 8.8.8.8 -j REDIRECT --to-port "$proxy_port" iptables -t nat -I PREROUTING -p tcp -d 8.8.4.4 -j REDIRECT --to-port "$proxy_port" iptables -t nat -A PREROUTING -p tcp -j clash iptables -t nat -N CLASH_DNS iptables -t nat -F CLASH_DNS iptables -t nat -A CLASH_DNS -p udp -j REDIRECT --to-port 1053 iptables -t nat -I OUTPUT -p udp --dport 53 -j CLASH_DNS iptables -t nat -I PREROUTING -p udp --dport 53 -j REDIRECT --to 1053 ## Fake-IP iptables -t nat -N clash iptables -t nat -A clash -d 0.0.0.0/8 -j RETURN iptables -t nat -A clash -d 10.0.0.0/8 -j RETURN iptables -t nat -A clash -d 127.0.0.0/8 -j RETURN iptables -t nat -A clash -d 169.254.0.0/16 -j RETURN iptables -t nat -A clash -d 172.16.0.0/12 -j RETURN iptables -t nat -A clash -d 192.168.0.0/16 -j RETURN iptables -t nat -A clash -d 224.0.0.0/4 -j RETURN iptables -t nat -A clash -d 240.0.0.0/4 -j RETURN iptables -t nat -A clash -d "$local_ipv4" -j RETURN iptables -t nat -A clash -p tcp -j REDIRECT --to-port "$proxy_port" iptables -t nat -I PREROUTING -p tcp -d 8.8.8.8 -j REDIRECT --to-port "$proxy_port" iptables -t nat -I PREROUTING -p tcp -d 8.8.4.4 -j REDIRECT --to-port "$proxy_port" iptables -t nat -A PREROUTING -p tcp -j clash iptables -t nat -A OUTPUT -p tcp -d 198.18.0.0/16 -j REDIRECT --to-port "$proxy_port" iptables -t nat -N CLASH_DNS iptables -t nat -F CLASH_DNS iptables -t nat -A CLASH_DNS -p udp -j REDIRECT --to-port 1053 iptables -t nat -I OUTPUT -p udp --dport 53 -j CLASH_DNS iptables -t nat -I PREROUTING -p udp --dport 53 -j REDIRECT --to 1053 ## 带有UDP的Redir-Host # tcp iptables -t nat -N clash iptables -t nat -A clash -d 0.0.0.0/8 -j RETURN iptables -t nat -A clash -d 10.0.0.0/8 -j RETURN iptables -t nat -A clash -d 127.0.0.0/8 -j RETURN iptables -t nat -A clash -d 169.254.0.0/16 -j RETURN iptables -t nat -A clash -d 172.16.0.0/12 -j RETURN iptables -t nat -A clash -d 192.168.0.0/16 -j RETURN iptables -t nat -A clash -d 224.0.0.0/4 -j RETURN iptables -t nat -A clash -d 240.0.0.0/4 -j RETURN iptables -t nat -A clash -d "$local_ipv4" -j RETURN iptables -t nat -A clash -p tcp -j REDIRECT --to-port "$proxy_port" iptables -t nat -I PREROUTING -p tcp -d 8.8.8.8 -j REDIRECT --to-port "$proxy_port" iptables -t nat -I PREROUTING -p tcp -d 8.8.4.4 -j REDIRECT --to-port "$proxy_port" iptables -t nat -A PREROUTING -p tcp -j clash # udp ip rule add fwmark 1 table 100 ip route add local default dev lo table 100 iptables -t mangle -N clash iptables -t mangle -A clash -d 0.0.0.0/8 -j RETURN iptables -t mangle -A clash -d 10.0.0.0/8 -j RETURN iptables -t mangle -A clash -d 127.0.0.0/8 -j RETURN iptables -t mangle -A clash -d 169.254.0.0/16 -j RETURN iptables -t mangle -A clash -d 172.16.0.0/12 -j RETURN iptables -t mangle -A clash -d 192.168.0.0/16 -j RETURN iptables -t mangle -A clash -d 224.0.0.0/4 -j RETURN iptables -t mangle -A clash -d 240.0.0.0/4 -j RETURN iptables -t mangle -A clash -d "$local_ipv4" -j RETURN iptables -t mangle -A clash -p udp -j TPROXY --on-port "$proxy_port" --tproxy-mark 1 iptables -t mangle -A PREROUTING -p udp -j clash iptables -t nat -N CLASH_DNS iptables -t nat -F CLASH_DNS iptables -t nat -A CLASH_DNS -p udp -j REDIRECT --to-port 1053 iptables -t nat -I OUTPUT -p udp --dport 53 -j CLASH_DNS iptables -t nat -I PREROUTING -p udp --dport 53 -j REDIRECT --to 1053 ## 带有UDP的Fake-IP #tcp iptables -t nat -N clash iptables -t nat -A clash -d 0.0.0.0/8 -j RETURN iptables -t nat -A clash -d 10.0.0.0/8 -j RETURN iptables -t nat -A clash -d 127.0.0.0/8 -j RETURN iptables -t nat -A clash -d 169.254.0.0/16 -j RETURN iptables -t nat -A clash -d 172.16.0.0/12 -j RETURN iptables -t nat -A clash -d 192.168.0.0/16 -j RETURN iptables -t nat -A clash -d 224.0.0.0/4 -j RETURN iptables -t nat -A clash -d 240.0.0.0/4 -j RETURN iptables -t nat -A clash -d "$local_ipv4" -j RETURN iptables -t nat -A clash -p tcp -j REDIRECT --to-port "$proxy_port" iptables -t nat -I PREROUTING -p tcp -d 8.8.8.8 -j REDIRECT --to-port "$proxy_port" iptables -t nat -I PREROUTING -p tcp -d 8.8.4.4 -j REDIRECT --to-port "$proxy_port" iptables -t nat -A PREROUTING -p tcp -j clash iptables -t nat -A OUTPUT -p tcp -d 198.18.0.0/16 -j REDIRECT --to-port "$proxy_port" #udp ip rule add fwmark 1 table 100 ip route add local default dev lo table 100 iptables -t mangle -N clash iptables -t mangle -A clash -d 0.0.0.0/8 -j RETURN iptables -t mangle -A clash -d 10.0.0.0/8 -j RETURN iptables -t mangle -A clash -d 127.0.0.0/8 -j RETURN iptables -t mangle -A clash -d 169.254.0.0/16 -j RETURN iptables -t mangle -A clash -d 172.16.0.0/12 -j RETURN iptables -t mangle -A clash -d 192.168.0.0/16 -j RETURN iptables -t mangle -A clash -d 224.0.0.0/4 -j RETURN iptables -t mangle -A clash -d 240.0.0.0/4 -j RETURN iptables -t mangle -A clash -d "$local_ipv4" -j RETURN iptables -t mangle -A clash -p udp -j TPROXY --on-port "$proxy_port" --tproxy-mark 1 iptables -t mangle -A OUTPUT -p udp -d 198.18.0.0/16 -j MARK --set-mark 1 iptables -t mangle -A PREROUTING -p udp -j clash iptables -t nat -N CLASH_DNS iptables -t nat -F CLASH_DNS iptables -t nat -A CLASH_DNS -p udp -j REDIRECT --to-port 1053 iptables -t nat -I OUTPUT -p udp --dport 53 -j CLASH_DNS iptables -t nat -I PREROUTING -p udp --dport 53 -j REDIRECT --to 1053
TUN 使 Clash 接管所有程序,包括在普通情况下不遵守系统代理设置的程序。
对于 Mac/Linux/OpenWRT/nftables,使用以下配置。stack 可选择 system 或 gvisor,以确定使用哪一个堆栈。dns-hijack 用于 DNS 劫持,以在 fake-ip 模式下返回假 IP。
1 2 3 4 5 6 7 tun: enable: true stack: system macOS-auto-route: true macOS-auto-detect-interface: true dns-hijack: - tcp://8.8.8.8:53
然后在终端输入以下命令。Mac 如下。
1 2 3 4 5 6 7 8 sudo route -n add -net 1 198.18.0.1 sudo route -n add -net 2/7 198.18.0.1 sudo route -n add -net 4/6 198.18.0.1 sudo route -n add -net 8/5 198.18.0.1 sudo route -n add -net 16/4 198.18.0.1 sudo route -n add -net 32/3 198.18.0.1 sudo route -n add -net 64/2 198.18.0.1 sudo route -n add -net 128.0/1 198.18.0.1
Linux/OpenWRT 如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 # Based on https://github.com/Kr328/kr328-clash-setup-scripts/blob/master/setup-clash-tun.sh ipset create localnetwork hash:net ipset add localnetwork 127.0.0.0/8 ipset add localnetwork 10.0.0.0/8 ipset add localnetwork 169.254.0.0/16 ipset add localnetwork 192.168.0.0/16 ipset add localnetwork 224.0.0.0/4 ipset add localnetwork 240.0.0.0/4 ipset add localnetwork 172.16.0.0/12 ip tuntap add user root mode tun utun0 ip link set utun0 up ip route replace default dev utun0 table 0x162 ip rule add fwmark 0x162 lookup 0x162 iptables -t mangle -N CLASH iptables -t mangle -F CLASH iptables -t mangle -A CLASH -p tcp --dport 53 -j MARK --set-mark 0x162 iptables -t mangle -A CLASH -p udp --dport 53 -j MARK --set-mark 0x162 iptables -t mangle -A CLASH -m addrtype --dst-type BROADCAST -j RETURN iptables -t mangle -A CLASH -m set --match-set localnetwork dst -j RETURN iptables -t mangle -A CLASH -d 198.18.0.0/16 -j MARK --set-mark 0x162 iptables -t mangle -A CLASH -j MARK --set-mark 0x162 iptables -t mangle -I OUTPUT -j CLASH iptables -t mangle -I PREROUTING -m set ! --match-set localnetwork dst -j MARK --set-mark 0x162 sysctl -w net/ipv4/ip_forward=1 sysctl -w net.ipv4.conf.utun0.rp_filter=0
nftables 如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 # Based on https://github.com/Kr328/kr328-clash-setup-scripts/blob/master/setup-clash-tun.sh # Make sure your clash DNS listen at 1053, otherwise you should modify some part ip route replace default dev utun table 114 ip rule del fwmark 114514 lookup 114 ip rule add fwmark 114514 lookup 114 nft -f - << EOF define LOCAL_SUBNET = {127.0.0.0/8, 224.0.0.0/4, 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 169.254.0.0/16, 240.0.0.0/4} define TUN_DEVICE = utun define FORWARD_DNS_REDIRECT = {127.0.0.1:1053} table inet clash flush table inet clash table inet clash { chain local { type route hook output priority 0; policy accept; ip protocol != { tcp, udp } accept ip daddr \$LOCAL_SUBNET accept ct state new ct mark set 114514 ct mark 114514 mark set 114514 } chain forward { type filter hook prerouting priority 0; policy accept; ip protocol != { tcp, udp } accept iif utun accept ip daddr \$LOCAL_SUBNET accept mark set 114514 } chain local-dns-redirect { type nat hook output priority 0; policy accept; ip protocol != { tcp, udp } accept udp dport 53 dnat ip to $FORWARD_DNS_REDIRECT tcp dport 53 dnat ip to $FORWARD_DNS_REDIRECT } chain forward-dns-redirect { type nat hook prerouting priority 0; policy accept; ip protocol != { tcp, udp } accept udp dport 53 dnat ip to $FORWARD_DNS_REDIRECT tcp dport 53 dnat ip to $FORWARD_DNS_REDIRECT } } EOF sysctl -w net/ipv4/ip_forward=1
对于 Windows,需要使用以下配置。
1 2 3 4 5 6 7 tun: enable: true stack: gvisor # only gvisor dns-hijack: - 198.18.0.2:53 macOS-auto-route: true macOS-auto-detect-interface: true
还需要下载以下程序,将 wintun.dll 复制到 Clash 目录。
Surge 下载 Mac 1 https://www.nssurge.com/
将以下内容保存为 surge.sh,放置位置与 Surge 应用程序同级,用终端运行 bash [surge.sh路径]
即可。注意,对于最新版 Surge,破解后过一段时间会闪退,因为该脚本的原理是修改时间,最新版的 Surge 会自动检测时间。断网后可保持 Surge 不闪退,但这也就无法正常使用。
1 2 3 4 5 6 7 8 9 10 11 #!/usr/bin/env bash cd $(dirname "$0") read -sp "Password: " pwd echo rm -rf ~/Library/Application Support/com.nssurge.surge-* echo "${pwd}" | sudo -S date 010110002018 nohup ./Surge.app/Contents/MacOS/Surge & sleep 20 echo "${pwd}" | sudo -S sntp -sS time.apple.com.
基本配置 开启系统代理,出站模式为规则判断。
配置文件 可以直接套用 iOS 的 surge 配置文件。
模块 若导入 iOS 端 Surge 的模块到 Mac 端时报错,则检查模块是否有以下语句,有则删除即可。
远程控制 iOS 的 Surge 可控制 Mac 的 Surge。在 Mac 修改 Surge 的配置文件,添加以下行,其中 password 可以修改为其它内容。
1 external-controller-access = password@0.0.0.0:6155
打开 iOS 端的 Surge,添加远程控制器,IP 填写 Mac 端的 IP,端口为 6155,密码为 password 部分的内容,配置完成即可。
第三方工具 常用的第三方工具有 YASD 和 xurge。以 YASD 为例说明其使用方法。
打开以下网站,点击添加新主机,参数为 Surge 配置文件的 [general] 模块下的 http-api,一般为 0.0.0.0 或 127.0.0.1,保存即可使用。
1 http://yasd.nerdynerd.org/home
软路由 通过代理 Surge 开启时,会自动开启 http 和 socks5 代理,实现局域网共享。在启动日志中可看到 SOCKS5 代理服务已启动,监听在 127.0.0.1,端口号 6153
和 HTTP 代理服务已启动,监听在 127.0.0.1,端口号 6152
的记录。
对于同一网络下的设备,若该设备需要翻墙,则在该设备上手动设置代理即可,其中服务器 IP 为安装有 Surge 的电脑 IP,端口在记录中可查询到。
通过增强模式 即网关模式、协议转换器,可以实现网络间的相互连接。
点击系统偏好设置 - 网络,选择当前使用的网络,点击高级 - TCP/IP,在配置 IPV4 下选择手动,然后即可开启 Surge 的增强模式。
对于同一网络下的设备,若该设备需要翻墙,则在该设备上手动设置代理,其中服务器 IP 填写同网段内任意一个设备的 IP,子网掩码保持不变(255.255.255.0),路由器地址 / 网关地址为 Mac 的 IP,DNS 为 Mac 中网络偏好设置 - DNS 服务器下的记录,该 DNS 由 surge 创建,一般为 198.18.0.2。
通过 DHCP 服务器模式 该方法不需要配置代理设备,只需在 Mac 端配置即可。但配置出错会导致连接该网络的所有设备瘫痪。
要启用该功能,需要关闭现有的 DHCP,因为 DHCP 将由 Surge 接管。DHCP 通常由路由器提供,需要参考路由器的配置页面。
在 Surge 的配置中,需手动配置至少一个有效的 DNS 服务器,即 Surge DNS 不能全部指向内网。
本设备不应断电或断网,否则将影响其余所有设备,因此 Surge 会强制禁止电脑休眠。本设备应使用有线连接网络,无线网络可能导致严重的性能问题。
完成如上配置后,即可在 Surge 中点击设置 - DHCP 服务器,开启后记录详细网络参数以防配置错误。回到设备页,可以看到所有连接到该网络的设备。对于要设置翻墙的设备,右键点击使用 surge 作为网关即可。
常见问题 与 AdGuard 冲突 关闭 surge 系统代理。保证 http 和 socks5 代理打开的情况下,打开增强模式。在 adguard 的高级设置中,将 adguard 的上游代理(upstream.proxy)设置为 surge 的代理端(socks5://locaalhost:6153),不要打开 udp 即可。
也可通过另一种方式。进入 Adguard 高级设置并点击恢复默认,首选项关闭自动过滤应用程序流量,打开 http 代理。进入系统网络偏好设置,点击高级 - 代理 - 网页代理(HTTP),填入 adguard 的 http 代理内容,然后正常启动 Surge 即可。
Trojan-Qt5 1 https://github.com/charlieethan/Trojan-Qt5/releases
QV2Ray 打开以下网站下载 QV2Ray 软件以及 SSR/Trojan 插件。
1 2 https://github.com/Qv2ray/Qv2ray/releases https://qv2ray.github.io/
打开 QV2Ray,点击插件
,选择打开本地插件目录
,将下载的插件复制到此目录,重启应用即可加载插件。然后打开以下网站,下载 V2Ray 核心。在 QV2Ray 的安装目录下新建一个空文件夹,名称可以任意取,然后将解压后的 V2Ray 核心文件拖入其中。
1 https://github.com/v2ray/v2ray-core/releases
打开 QV2Ray,点击首选项 - 内核设置,将核心可执行文件路径
设置刚才所新建的文件夹下的 v2ray.exe 目录(Mac 为 v2ray 文件),V2ray资源目录
设置为刚才所新建的文件夹下的目录,然后点击核心验证
确认配置完成。
Surfboard 适用于 Android,兼容 Surge 配置文件。
1 https://manual.getsurfboard.com/
二级代理 二级代理即为在数据从服务端传回客户端时并不直接传回,而是通过另一个服务器中转。
Shadowsocks 准备好客户端及其副本。打开客户端并连接中转节点,然后打开另一个客户端,将会提示端口被占用,因为默认端口均为 1080。因此修改本客户端的本地端口为 1081 或其它值,然后设置该客户端连接服务器节点,代理模式选择全局模式即可。
翻墙进阶 可用性检查 IP 连通性 可通过以下网站测试 IP 的连通性。
1 2 3 4 5 6 7 https://www.vps234.com/ipchecker/ http://ping.pe/ https://torch.njs.app/ https://www.ipaddress.com/ https://www.ip-adress.com/ https://whoer.net/zh https://tuna.moe/help/dns/
如果 IP 不通,则需要更换 IP。如果 IP 全通,但翻墙连不上,则一般为端口被封,更换端口即可。
订阅链接 格式 去掉前缀并经 base64 解码后,可得到不同协议的节点配置格式。
Shadowsocks 1 ss://method:password@server:port
ShadowsocksR 1 2 3 4 ssr://ip:port:protocol:method:blending:password/?remarks=othertext // 其余形式如下,其中obfsparam、protoparam、group、remarks可选 ssr://159.65.1.189:5252:auth_sha1_v4:rc4-md5:http_simple:NTJzc3IubmV0/?obfsparam=&protoparam=&group=d3d3LnNzcnNoYXJlLmNvbQ&remarks=RE1fTm9kZQ
V2Ray 1 2 3 4 5 6 7 8 9 10 11 { "ps": "别名", "add": "ip地址", "port": "端口", "id": "uuid", "aid": "alterid", "net": "传输协议", "type": "伪装类型", "host": " http header参数", "tls": "底层传输安全" }
转换 边缘转换 网址如下。
以生成适用于 Quantumult 的订阅为例,订阅链接
填写 vmess://
开头的链接或机场订阅,远程配置选择 No-Urltest
,并勾选输出为Node List
,得到链接。
可直接将得到的链接作为订阅 URL,也可在浏览器打开该链接下载文件得到文件内容。
QuantumultX-Surge-API 网页版地址如下。
1 https://dove.589669.xyz/web
仓库如下。
1 https://github.com/KOP-XIAO/QuantumultX-Surge-API
Surgio 1 2 https://surgio.js.org/ https://github.com/surgioproject/surgio
ConfigConverters 1 https://github.com/ImSingee/ConfigConverter
subconverter 1 https://github.com/tindy2013/subconverter
制作 为防止服务器配置更改导致节点失效,可通过制作订阅的方式。更新订阅即可更新服务器配置,无需逐个修改。
通用方法 在 Github 上新建仓库,以用于存放配置文件。
以 V2Ray 节点为例,由于大部分 V2Ray 客户端的分享链接采用 V2RayN 标准,因此需先在 V2RayN 上完成各服务器的配置。选中所有需要配置成订阅的服务器,右键选择批量导出分享URL至剪贴板
,复制到记事本。
如果希望添加剩余流量和到期时间提醒,可在开头处添加以下内容。完成后复制内容。
1 2 STATUS=剩余流量:23.06GB.♥.过期时间:3162-01-10 REMARKS=备注
然后打开以下网站,将刚才复制的内容编码成 BASE64。
1 https://emn178.github.io/online-tools/base64_decode.html
编码完成后回到 Github 并新建文件,文件名任意,后缀为 txt。将编码后的内容复制到文本区域,保存后点击 Commit changes
,成功后点击 Raw
,复制得到的网址,即为所得订阅链接。本链接可用于大部分客户端。
特殊处理 Quantumult Quantumult 无法使用以上链接,可通过订阅链接转换中的方式完成转换。需要注意,通过一键生成配置网站所生成的文件已经过处理,但每一个订阅都使用同一个 group 名称,从而会导致多个订阅链接更新时服务器的覆盖。因此需要手动 base64 解码,解码一次后得到服务器列表,去掉 vmess://
前缀后再次解码得到服务器信息,更改 group 后重新编码,即得到可用链接。
也可手动完成本操作。在已经配置好服务器的 Quantumult 上获取服务器的分享链接,删除 vmess://
前缀后放到上述 BASE64 网站进行解码,解码内容应如下所示。
1 [名称] = vmess, [地址], [端口], [加密方式], [UUID], [选项]
对于 Vmess 节点,在后面加上 , group=[名称]
,例子如下所示。注意,对于 vmess 节点,每一个订阅需要有唯一的 group 名称,否则在订阅更新时会被覆盖。若为 Shadowsocks 节点,则无需进行操作。
1 example = vmess, 1.2.3.4, 1234, aes-128-cfb, "12345678-8765-4321-1234-123456789abc", over-tls=false, certificate=1, group=TCP
重新编码为 BASE64 并添加 vmess://
前缀,得到一个可用的链接。其余服务器同理,从而得到一系列可用的链接,将这些链接进行一次 BASE64 编码即可。
如果手动编辑后的连接不可用,则尝试在后面加一个空格,再编码为 BASE64 并添加 vmess://
前缀。
对于 Shadowsocks 节点,则按照以下格式编写 ss 可用链接,将所有可用链接进行一次 BASE64 编码即可。
1 ss://[base64编码后的method:password]@[地址]:[端口]&group=[组名]#[名称]
Surge Surge 订阅格式如下所示,注意不能进行 base64 解码。
1 2 3 4 5 // Vmess [名称] = vmess, [地址], [端口], username=[用户名], ws=true/false, (ws-path=[路径], ws-headers=[Host:地址],) tls=true/false // Shadowsocks [名称] = ss, [地址], [端口]&group=[组名], encrypt-method=[加密方式], password=[密码], tfo=true/false, udp-relay=true/false
链接发布 放到 Github 上 登录 Github 并新建一个 Repository,类型为 Public,需勾选 Initialize this repository with a README
,完成创建。删除 README 以减少被搜索出来的几率。
在仓库内新建一个文本文档并编辑,将上面制作好的订阅内容复制进去后保存。然后点击 Raw
,跳转到的链接即为订阅地址。
放到自有服务器上 用 SSH 连接到服务器,新建一个 php 文档,内容如下。
1 2 3 <?php $str = file_get_contents("./res.txt", "r") or die("Unable to open file!"); echo base64_encode($str); ?>
新建名称为 res.txt
的文本文件,将上面制作好的订阅内容复制进去即可。php 文档的地址即为订阅地址。
反代网站 反代通过访问本网站,而本网站再访问其它网站的方式实现翻墙。
现成网站 1 2 3 4 https://search.snopyta.org/ http://webproxy.to/ https://weboas.is/ https://www.croxyproxy.com/
自行搭建 jsproxy 仓库如下。
1 https://github.com/EtherDream/jsproxy
搭建到 Cloudflare Worker 打开第一个网页,完成注册后登录。然后打开第二个网页并点击 Start building
,子域名可以任意填写,计划选择免费,并创建 worker。
1 2 https://dash.cloudflare.com/ https://workers.cloudflare.com/
进入 worker 页面,更改三级域名,删除原始脚本。然后打开以下网页,复制代码到 worker 的脚本处,点击下方保存并部署
,然后进行预览。使用时直接输入域名对应的网址即可。
1 https://github.com/EtherDream/jsproxy/blob/master/cf-worker/index.js
siteproxy 部署方法与 jsproxy 基本一致。仓库如下。
1 https://github.com/netptop/siteproxy
zmirror 需要 VPS,通过以下脚本一键部署。仓库如下。
1 2 https://github.com/aploium/zmirror https://github.com/aploium/zmirror-onekey
Ubuntu 支持 Ubuntu 14.04、15.04 (不支持 HTTP2)、15.10、16.04 + 和 Debian 8 (不支持 HTTP/2)。推荐 Ubuntu 16.04 x86_64。
1 https://github.com/yumin9822/zmirror-docker/blob/master/zmirror-ubuntu.sh
Debian 1 https://github.com/yumin9822/zmirror-docker/blob/master/zmirror-debian.sh
CentOS 6 1 https://github.com/yumin9822/zmirror-docker/blob/master/zmirror-centos6.sh
jenssegers/proxy 可通过 composer 安装。
1 composer require jenssegers/proxy
仓库如下。
1 https://github.com/jenssegers/php-proxy
服务器加速 BBR 一键安装脚本 逗比版。
1 wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/bbr.sh && chmod +x bbr.sh && bash bbr.sh
全类型 一键安装脚本 在服务器输入以下命令以安装脚本。以安装 BBR Plus 为例,需要先安装 BBR Plus 内核,安装过程中弹框需选择 NO
。
1 wget --no-check-certificate -O tcp.sh https://github.com/cx9208/Linux-NetSpeed/raw/master/tcp.sh && chmod +x tcp.sh && ./tcp.sh
安装完成后再运行一次脚本,安装 BBR Plus 服务即可。
CDN 加速 登录 CloudFlare,新建一个 worker。用下面代码覆盖原有代码,把 url.hostname 替换成想要加速的 V2Ray 节点域名(不要添加前面的 http 和后面的路径)。
1 2 3 4 5 6 7 8 9 10 addEventListener( "fetch",event => { let url=new URL(event.request.url); url.hostname="xxxx-elecv2.cloud.okteto.net"; let request=new Request(url,event.request); event. respondWith( fetch(request) ) } )
点击保存
后,在客户端配置中复制一份原来的配置,把域名换成 workers 服务器的域名即可。原来的配置仍然可用。
处理 DNS 污染 可通过 Accesser。以 Mac 为例,打开第一个链接并下载源码,解压后打开第二个链接下载 dnscrypt-proxy,放到解压好的文件夹的 dnscrypt 目录下。
1 2 https://github.com/URenko/Accesser https://github.com/jedisct1/dnscrypt-proxy/releases
打开终端并运行以下命令。
1 2 3 4 brew install openssl pip3 install tld dnspython tornado env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography pip3 install pyopenssl
打开网络偏好设置,选择当前连接的网络并点击高级
,选择代理 - 自动代理配置,填写以下 URL 后保存。
1 http://127.0.0.1:7654/pac/
终端切换到源码目录并运行以下命令,在弹出的窗口点击导入证书,下载后双击安装。在弹出的钥匙串访问
对话框中双击刚才安装的证书,在信任
下选择始终信任。保持网页打开,即可访问受到 DNS 污染的网站。
Vmware 虚拟机使用代理 虚拟机使用宿主机代理,不用设置额外 VMware 的转发,只需添加代理的地址与端口。手机也能使用虚拟机所配置的本机代理服务器,不需要同宿主机设置专属的 VMware 转发。
除默认配置的仅主机模式外,宿主机使用 VPN 会影响全局网络,虚拟机可以直接访问互联网。在 NAT 模式中,虚拟机通过宿主机器所在的公网网络来访问互联网(目前在墙内),Vmware 使用代理软件转发端口监听任意地址,主机在代理中配置同一公网内的局域网 IP 与端口,完成网络之间的互联共享。在 NAT 模式中不考虑使用 VPN 或代理的情况下,IP 地址是完全一致的。
虚拟机采用的是非全局性的独立网络,也因此在虚拟机使用 VPN 并不能使宿主机也能够访问互联网,但能够进行相关配置。
在 Vmware 中开启翻墙软件。下载 Privoxy,该软件可将 sock 协议转换为 http/https 协议。
1 https://www.privoxy.org/
安装后配置相关参数为 0.0.0.0:8118
,将所有 HTTP 流量再转发至本机代理,然后在系统设置的代理中设置以上参数。打开命令行并通过 ipconfig
查看虚拟机的 IP 地址。在 Vmware 软件中设置端口映射,然后在主机的系统设置的代理中填入 Vmware 的 IP 地址和端口即可。
流媒体解锁 国外流媒体对 IP 有不同程度的要求。
IP 限制 Netflix 对于 Netflix,原生 IP 可以解锁所有剧集,非原生 IP 有所区分。
对于谷歌云,35 开头的 IP 可以观看带 Netflix 标志的电影,34 开头的 IP 可以观看大多数片源。
对于亚马逊云,其 IP 可以观看大多数片源。Heroku 的主机为亚马逊云,故使用 Heroku 的服务器为解锁所有 Netflix 影片最简单的方式。
解锁方法 DNS 解锁服务器 该方法适用于当前没有服务器可解锁流媒体。
在服务器上安装 V2Ray 和宝塔面板,其中宝塔面板的安装命令如下。
1 2 3 4 5 6 7 8 9 10 11 // CentOS yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh // Ubuntu/Deepin wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && sudo bash install.sh // Debian wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && bash install.sh // Fedora wget -O install.sh http://download.bt.cn/install/install_6.0.sh && bash install.sh
安装完成后进入宝塔界面,安装 LNMP。在服务器输入以下命令,查看占用 80 端口的服务,一般为 nginx。
在宝塔界面点击软件商店 - Nginx - 设置 - 配置修改,在配置的最底部可以看到默认配置的路径位置,此处为 /www/server/panel/vhost/nginx。利用宝塔界面的文件功能定位到该文件,将该文件的 listen 由 80 改为其它端口如 801 即可。
打开以下链接以购买流媒体解锁服务。
购买后在本机通过翻墙软件连接到刚才搭建的服务器,并设为全局模式。在流媒体解锁服务后台点击授权 IP 以绑定公网 IP。
在服务器输入以下命令安装 SNI proxy 反向代理。
1 wget –no-check-certificate -O dnsmasq_sniproxy.sh https://raw.githubusercontent.com/myxuchangbin/dnsmasq_sniproxy_install/master/dnsmasq_sniproxy.sh && bash dnsmasq_sniproxy.sh -i
通过宝塔的文件功能编辑 /etc/resolv.conf,将 IP 地址修改为流媒体解锁服务中的地址,保存退出即可。
SNI proxy 仓库与相关错误排除链接如下。
1 https://github.com/myxuchangbin/dnsmasq_sniproxy_install
流量转发 若已有一台可以解锁流媒体的服务器,可通过流量转发实现让其它服务器解锁流媒体。具体可查看翻墙协议的 V2Ray 配置部分。
翻墙协议 Shadowsocks 安装 一键安装脚本 doubi 命令如下。
1 wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubiBackup/doubi/master/ss-go.sh && chmod +x ss-go.sh && bash ss-go.sh
秋水逸冰 仓库如下。
1 https://github.com/teddysun/shadowsocks_install/tree/master
命令如下。配置文件地址为 /etc/shadowsocks-libev/config.json
。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 // 安装 wget --no-check-certificate -O shadowsocks-all.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-all.sh chmod +x shadowsocks-all.sh ./shadowsocks-all.sh 2>&1 | tee shadowsocks-all.log // 卸载 ./shadowsocks-all.sh uninstall // 启动 /etc/init.d/shadowsocks-libev start // 停止 /etc/init.d/shadowsocks-libev stop // 重启 /etc/init.d/shadowsocks-libev restart // 查看状态 /etc/init.d/shadowsocks-libev status
原版 1 https://github.com/shadowsocks/shadowsocks/tree/master
go-shadowsocks2 以 Go 语言编写的 Shadowsocks 实现。
1 https://github.com/shadowsocks/go-shadowsocks2
shadowsocks-libev Shadowsocks 的轻量化实现。
1 https://github.com/shadowsocks/shadowsocks-libev
可使用一键脚本安装,仓库如下。
1 https://github.com/lrinQVQ/script
ShadowsocksR 安装 一键安装脚本 脚本一 1 wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/ssr.sh && chmod +x ssr.sh && bash ssr.sh
脚本二 1 https://github.com/the0demiurge/CharlesScripts/blob/master/charles/bin/ssr
脚本三 逗比版,支持单端口 / 多端口切换和管理。
1 wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/ssr.sh && chmod +x ssr.sh && bash ssr.sh
原版 安装完成后,输入 ssr help 可以查看详细的命令列表。
方法一 1 2 3 4 5 6 7 8 9 10 11 12 sudo apt install aptitude && sudo aptitude full-upgrade && sudo reboot sudo aptitude install git sudo aptitude install python-pip sudo aptitude install curl libcurl3 libcurl3-dev php5-curl curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo aptitude full-upgrade && sudo apt-get install yarn sudo yarn global add ssr-helper sudo aptitude full-upgrade cd ~ sudo git clone -b manyuser https://github.com/shadowsocksr-backup/shadowsocksr.git ssr config ~/shadowsocksr
方法二 1 2 3 4 5 6 7 8 9 sudo apt install aptitude && sudo aptitude full-upgrade && sudo reboot sudo aptitude install git sudo aptitude install npm sudo aptitude install python-pip sudo npm install -g ssr-helper sudo aptitude full-upgrade cd ~ sudo git clone -b manyuser https://github.com/shadowsocksr-backup/shadowsocksr.git ssr config ~/shadowsocksr
V2Ray 安装 官方安装 连接到 VPS 后,通过以下命令查看 / 修改时间。V2Ray 要求时间准确,但时区会自动调整。
1 2 3 4 5 6 # 查看时间 # 输出示例Sun, 22 Jan 2017 10:10:36 -0500,其中-0500为西五区 date -R # 修改时间 sudo date --set="2017-01-22 16:16:23"
输入 su
切换到 root 用户后,输入以下命令以安装 curl。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 # Debian/Ubuntu apt update apt install curl # CentOS/RedHat yum makecache yum install curl # Fedora dnf makecache dnf install curl # openSUSE/SUSE zypper refresh zypper install curl
然后输入以下命令进行安装。
1 2 curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh bash install-release.sh
安装完成后输入以下命令设置开机自启,并现在启动 V2Ray。
1 2 systemctl enable v2ray systemctl start v2ray
重新执行以下命令即可更新 V2Ray。
可通过以下命令查看脚本使用方法。
1 bash install-release.sh -h
一键安装脚本 脚本一 1 2 3 4 5 6 7 8 # 安装 source <(curl -sL https://multi.netlify.app/v2ray.sh) --zh # 升级 source <(curl -sL https://multi.netlify.app/v2ray.sh) -k # 卸载 source <(curl -sL https://multi.netlify.app/v2ray.sh) --remove
脚本二 一键部署 WebSocket+Tls+Nginx+Web。
1 wget -N --no-check-certificate -q -O install.sh "https://raw.githubusercontent.com/wulabing/V2Ray_ws-tls_bash_onekey/master/install.sh" && chmod +x install.sh && bash install.sh
V2ray.Fun V2ray 控制脚本。
1 2 https://github.com/v2ray-fun/v2ray.fun https://github.com/FunctionClub/V2ray.Fun
配置 V2Ray 通过 config.json 配置设置。可通过以下命令检查配置文件是否正确。
1 /usr/bin/v2ray/v2ray -test -config /etc/v2ray/config.json
协议 仅列出重要的部分。
VMess 客户端配置如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 "outbounds": [ { "protocol": "vmess", // 出口协议 "settings": { "vnext": [ { "address": "serveraddr.com", // 服务器地址,请修改为你自己的服务器 IP 或域名 "port": 16823, // 服务器端口 "users": [ { "id": "b831381d-6324-4d53-ad4f-8cda48b30811", // 用户 ID,必须与服务器端配置相同 "alterId": 64 // 此处的值也应当与服务器相同 } ] } ] } } ]
服务端配置如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 "inbounds": [ { "port": 16823, // 服务器监听端口 "protocol": "vmess", // 主传入协议 "settings": { "clients": [ { "id": "b831381d-6324-4d53-ad4f-8cda48b30811", // 用户 ID,客户端与服务器必须相同 "alterId": 64 } ] } } ]
Shadowsocks 客户端配置如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 "outbounds": [ { "protocol": "shadowsocks", "settings": { "servers": [ { "address": "serveraddr.com", // Shadowsocks 的服务器地址 "method": "aes-128-gcm", // Shadowsocks 的加密方式 "ota": true, // 是否开启 OTA,true 为开启 "password": "sspasswd", // Shadowsocks 的密码 "port": 1024 } ] } } ]
服务端配置如下。
1 2 3 4 5 6 7 8 9 10 11 "inbounds": [ { "port": 1024, // 监听端口 "protocol": "shadowsocks", "settings": { "method": "aes-128-gcm", "ota": true, // 是否开启 OTA "password": "sspasswd" } } ]
HTTP 客户端配置如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 "outbounds": [ { "protocol": "http", "settings": { "servers": [ { "address": "192.168.108.1",//服务器IP "port": 1024,//服务器端口 "users": [ { "Username": "my-username",//将my-username改为你的用户名. "Password": "my-password" //将my-password改为你的密码 } ] } ] }, "streamSettings": { "security": "none", //如果是HTTPS代理,需要將none改為tls "tlsSettings": { "allowInsecure": false //检测证书有效性 } } } ]
服务端配置如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 "inbounds": [ { "port": 1024, // 监听端口 "protocol": "http", "settings": { "timeout:":0, "accounts":[ { "user":"my-username", "pass":"my-password" } ], "allowTransparent":false, "userLevel":0 } } ]
Mux 多路复用,仅需配置客户端。
1 2 3 4 5 "outbounds": [ { "mux": {"enabled": true} } ]
mKCP 再高丢包率网络下可开启该功能。注意会造成更多流量消耗。
服务端配置如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 "inbounds": [ { ... "streamSettings": { "network": "mkcp", //此处的 mkcp 也可写成 kcp,两种写法是起同样的效果 "kcpSettings": { "uplinkCapacity": 5, // 上行链路容量(单位MB) "downlinkCapacity": 100, // 下行链路容量(单位MB) "congestion": true, "header": { "type": "none" // 数据包伪装(客户端与服务器要一致) } } } } ]
客户端配置如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 "outbounds": [ { ... "streamSettings": { "network": "mkcp", "kcpSettings": { "uplinkCapacity": 5, "downlinkCapacity": 100, "congestion": true, "header": { "type": "none" } } } } ]
动态端口 仅适用于 vmess。
服务端配置如下。客户端不用额外设定,客户端会先与服务器的主端口通信协商下一个使用的端口号。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 "inbounds":[ { //主端口配置 "port": 37192, "protocol": "vmess", "settings": { "clients": [ { "id": "d17a1af7-efa5-42ca-b7e9-6a35282d737f", "alterId": 64 } ], "detour": { //绕行配置,即指示客户端使用 dynamicPort 的配置通信 "to": "dynamicPort" } } }, { "protocol": "vmess", "port": "10000-20000", // 端口范围 "tag": "dynamicPort", // 与上面的 detour to 相同 "settings": { "default": { "alterId": 64 } }, "allocate": { // 分配模式 "strategy": "random", // 随机开启 "concurrency": 2, // 同时开放两个端口,这个值最大不能超过端口范围的 1/3 "refresh": 3 // 每三分钟刷新一次 } } ]
日志 服务端与客户端配置一致。
1 2 3 4 5 "log": { "loglevel": "warning", "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log" }
loglevel 为日志级别,由详细到简略分别为 debug、info、warning、error、none。若不填写 access 和 error,则日志会输出到命令行中。
路由 基本逻辑 路由主要是配置 protocol。
以客户端 outbounds 的 protocol 为例,若为 vmess 则走翻墙,若为 freedom 则走直连,若为 blackhole 则阻止。示例如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 "outbounds": [ { "protocol": "vmess", // 出口协议 "settings": { "vnext": [ { "address": "serveraddr.com", // 服务器 IP 地址 "port": 16823, // 服务器端口 "users": [ { "id": "b831381d-6324-4d53-ad4f-8cda48b30811", // 用户 ID,须与服务器端配置相同 "alterId": 64 } ] } ] } }, { "protocol": "freedom", "settings": {} }, { "protocol": "blackhole", "settings": {} } ]
在包含多个出口协议的情况下,只会以 outbounds 中的第一个出口作为默认的出口。
域名文件 V2Ray 内置有 geosite.dat,该文件中包含常用的网站域名。
指定国内网站走直连的写法如下。
1 2 3 4 5 6 7 { "type": "field", "outboundTag": "direct", "domain": [ "geosite:cn" ] }
也可使用外置域名文件。可下载 h2y.dat 到 V2Ray 客户端运行目录,链接如下。
1 https://github.com/ToutyRater/V2Ray-SiteDAT/tree/master/geofiles
写法如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 "rules":[ { "type": "field", "outboundTag": "block", //拦截广告相关域名 "domain": [ "ext:h2y.dat:ad" ] }, { "type": "field", "outboundTag": "proxy", //被 gfw 屏蔽的域名走代理 "domain": [ "ext:h2y.dat:gfw" ] }, { "type": "field", "network":"tcp,udp", "outboundTag": "direct" // 默认直连 } ]
禁用 BT 服务端配置如下。此配置阻断被转发到服务器的 BitTorrent 连接。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 "inbounds": [ { "sniffing": { "enabled": true, "destOverride": [ "http", "tls" ] }, ... } ], "outbounds": [ { "protocol": "freedom", "settings": {} }, { "protocol": "blackhole", "settings": {}, "tag": "block" } ], "routing": { "domainStrategy": "AsIs", "rules": [ { "type": "field", "outboundTag": "block", "protocol": [ "bittorrent" ] } ] }
客户端配置如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 "outbounds": [ ... { "protocol": "freedom", "settings": {}, "tag": "direct" } ], "routing": { "domainStrategy": "AsIs", "rules": [ { "type": "field", "outboundTag": "direct", "protocol": [ "bittorrent" ] } ] }
中转 V2Ray 的中转功能可以将特定流量转发到另一台服务器上。假设在服务器 1 上配置了至服务器 2 的中转,则流量走向如下。
本功能可用于解锁 Netflix。若已有一台可观看 Netflix 的服务器 1,希望使服务器 2 也能观看 Netflix,则可以在服务器 2 上进行配置,主要是指定普通流量直接走服务器 1 本身,而 Netflix 流量走服务器 2。
在服务器 2 安装好 V2Ray 后,从服务器 2 下载 /etc/v2ray/config.json 到本地,打开并进行如下修改。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 { ... "inbounds":[ ... "sniffing": { "enabled": true, // 一定要开启sniffing,V2Ray才能识别Netflix的流量 "destOverride": ["http", "tls"] }, ... ], "outbounds": [ ... { ... }, ... { "tag": "VPS1", // 填写可观看Netflix的VPS信息,可通过V2RayN的导出服务器配置得到,示例如下 "protocol": "vmess", "settings": { "vnext": [ { "address": "example.com", "port": 443, "users": [ { "id": "abcd1234-1234-1234-1234-abcd12345678", "alterId": 0, "email": "t@t.tt", "security": "auto" } ] } ], "servers": null, "response": null }, "streamSettings": { "network": "ws", "security": "tls", "tlsSettings": { "allowInsecure": true, "serverName": null }, "tcpSettings": null, "kcpSettings": null, "wsSettings": { "connectionReuse": true, "path": "/", "headers": null }, "httpSettings": null, "quicSettings": null }, "mux": { "enabled": true, "concurrency": 8 } } //include_out_config // ], "routing": { "domainStrategy": "IPOnDemand", "rules": [ { "type": "field", "outboundTag": "VPS1", "domain": [ "geosite:netflix" ] }, { ... }, ... //include_ban_ad //include_rules // ] }, ... }
修改完成后将新文件上传到服务器 2 以覆盖原配置文件,并重启 V2Ray 即可。
代理转发 代理转发的作用与中转基本一致,主要适用于服务器 1 和服务器 2 都无法修改配置的情况。通过直接修改客户端的配置,可以让客户端以服务器 2 为跳板,将 Netflix 的流量转发至服务器 1。
注意,代理转发会使 streamSettings 失效。客户端配置文件示例如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 { "inbounds": [ { "port": 1080, "protocol": "socks", "sniffing": { "enabled": true, // 一定要开启sniffing,V2Ray才能识别Netflix的流量 "destOverride": ["http", "tls"] }, "settings": { "auth": "noauth" } } ], "outbounds": [ { // 服务器1的配置,可通过V2RayN的导出服务器配置得到,示例如下 "tag": "VPS1" "protocol": "vmess", "settings": { "vnext": [{ "address": "1.2.3.4", "port": 10086, "users": [{ "id": "23ad6b10-8d1a-40f7-8ad0-e3e35cd38297", "security": "auto", "alterId": 64 }] }] }, "proxySettings": { "tag": "VPS2" // 表示VPS1的流量由VPS2转发 } }, { // 服务器2的配置,可通过V2RayN的导出服务器配置得到,示例如下 "tag": "VPS2" "protocol": "vmess", "settings": { "vnext": [{ "address": "2.2.3.5", "port": 16823, "users": [{ "id": "b831381d-6324-4d53-ad4f-8cda48b30811", "security": "auto", "alterId": 64 }] }] } }, { "tag": "direct", "protocol": "freedom", "settings": {} } ], "routing": { "rules": [ { "type": "field", "outboundTag": "direct", "domain": ["geosite:cn"] // 国内直连(本机-互联网) }, { "type": "field", "outboundTag": "VPS1", "domain": ["geosite:netflix"] // Netflix走VPS1(本机-VPS2-VPS1-互联网) }, { "type": "field", "outboundTag": "VPS2", "network": "udp,tcp" // 其余走VPS2(本机-VPS2-互联网) } ] } }
代理转发可以配置为链式,示例如下。转发路径为 PC-AliHK-AliSG-DOSG-DOUS - 目标网站。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 { "outbounds": [ { ... "tag": "AliHK" }, { ... "tag": "AliSG", "proxySettings": { "tag": "AliHK" } }, { ... "tag": "DOSG", "proxySettings": { "tag": "AliSG" } }, { ... "tag": "DOUS", "proxySettings": { "tag": "DOSG" } }, ] }
HTTP 伪装 将 V2Ray 的流量伪装成正常的 HTTP 协议。
服务器配置如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 "inbounds": [ { ... "streamSettings": { "network": "tcp", "tcpSettings": { "header": { // header 这一项是关于数据包伪装的设置,可自定义合理的内容,但要确保服务器与客户端一致 "type": "http", "response": { "version": "1.1", "status": "200", "reason": "OK", "headers": { "Content-Type": ["application/octet-stream", "application/x-msdownload", "text/html", "application/x-shockwave-flash"], "Transfer-Encoding": ["chunked"], "Connection": ["keep-alive"], "Pragma": "no-cache" } } } } } } ]
客户端配置如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 "outbounds": [ { ... "streamSettings": { "network": "tcp", "tcpSettings": { "header": { //这里的 header 要与服务器保持一致 "type": "http", "request": { "version": "1.1", "method": "GET", "path": ["/"], "headers": { "Host": ["www.cloudflare.com", "www.amazon.com"], "User-Agent": [ "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36", "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46" ], "Accept-Encoding": ["gzip, deflate"], "Connection": ["keep-alive"], "Pragma": "no-cache" } } } } } }, { "protocol": "freedom", "settings": {}, "tag": "direct" } ],
负载均衡 客户端配置如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 { "inbounds": [ ... ], "outbounds": [ { "tag": "us1", ... }, { "tag": "jp1", ... }, { "tag": "jp2", ... }, { "tag": "hk1", ... }, { "tag": "direct", ... } ], "routing": { "domainStrategy": "IPOnDemand", "balancers": [ { "tag": "b1", "selector": [ "jp1", "jp2" ] }, { "tag": "b2", "selector": [ "us1", "hk1" ] } ], "rules": [ { "type": "field", "outboundTag": "direct", "ip": [ "geoip:private", "geoip:cn" ] }, { "type": "field", "outboundTag": "direct", "domain": [ "geosite:cn" ] }, { "type": "field", "network": "tcp,udp", "balancerTag": "b1" } ] } }
原理 架构 客户端与服务端的配置文件都有入站协议 inbounds 和出站协议 outbounds。其中 inbounds 是关于如何与上一个节点连接的配置,outbounds 是关于如何与下一个节点连接的配置。
对于客户端,inbounds 与浏览器连接,进行代理相关配置,outbounds 为节点列表。
inbounds 中的相关选项作用如下。
选项
说明
“sniffing”
从网络流量中识别出域名,以解决 DNS 污染、识别 BT 协议,对于 IP 流量可以应用域名路由规则
对于服务端,inbounds 为服务器相关设置,outbounds 为可以转发的域名,一般为 freedom,即所有流量都从本服务器发出。
inbounds 中的相关选项作用如下。
选项
说明
alterId
加强防探测能力(理论上越大越好,但越大会约占内存,建议设为 30-100)
数据包流向如下。
1 {浏览器}<--(socks)-->{V2Ray客户端inbound<->V2Ray客户端 outbound}<--(VMess)-->{V2Ray服务器inbound<->V2Ray服务器outbound}<--(Freedom)-->{目标网站}
WS+TLS 在 V2Ray 的配置文件 config.json 中,采用 WS+TLS 的写法示例如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 { ... "inbounds":[ ... { "port": 8089, "protocol": "vmess", "settings": { "clients": [{ "id": "71880ee2-4d15-47da-87b2-xxxxxxxxxx", "alterId": 64 }] }, "streamSettings": { "network": "ws" }, "sniffing": { "enabled": true, "destOverride": ["http", "tls"] }, }, ... ], ... }
其中 port 所指定的端口用于将流量转发到指定域名。caddy 实现该转发功能,通过以下命令可打开其配置文件。
1 vim /etc/caddy/Caddyfile
指定地址为 127.0.0.1:8089 即可,其中 8089 为上面的 port。
Brook 安装 一键安装脚本 脚本一 1 wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/brook.sh && chmod +x brook.sh && bash brook.sh
脚本二 1 2 3 4 curl -L https://github.com/txthinking/brook/releases/download/v20200909/brook_linux_amd64 -o /usr/bin/brook chmod +x /usr/bin/brook // 启动brook并增加守护进程,端口设置为9999,密码设置为password setsid ./brook server -l :9999 -p password
Trojan 安装 一键安装脚本 1 bash -c "$(curl -fsSL https://raw.githubusercontent.com/atrandys/trojan/master/trojan_mult.sh)"
WireGuard WireGuard 使用 UDP。
安装 一键安装脚本 1 curl -O https://raw.githubusercontent.com/atrandys/wireguard/master/wg_mult.sh && chmod +x wg_mult.sh && ./wg_mult.sh
安装完成后需要下载 /etc/wireguard/client.conf 到本地。可通过以下命令直接打开该文件,然后复制文本内容至本地。
1 cat /etc/wireguard/client.conf
也可通过以下命令下载文件。
1 2 yum -y install lrzsz sz /etc/wireguard/client.conf
使用客户端时配置文件选择刚才下载的 conf 即可。
ZeroTier 通过 ZeroTier,可将服务器 IP 与客户端 IP 置于同一个内网,从而达到翻墙的目的。
服务器需要提前安装好 Ubuntu。以非 root 身份登录服务器,并输入以下命令以安装 Zerotier。脚本完成后记录输出中方括号内的 ZeroTier 地址。
1 curl -s 'https://pgp.mit.edu/pks/lookup?op=get&search=0x1657198823E52A61' | gpg --import && if z=$(curl -s 'https://install.zerotier.com/' | gpg); then echo "$z" | sudo bash; fi
然后输入以下命令判断是否已经启用 Linux 内核数据转发,输出 net.ipv4.ip_forward = 0
为未启用,输出 net.ipv4.ip_forward = 1
为已启用。
1 sudo sysctl net.ipv4.ip_forward
若未启用,则输入以下命令。
1 sudo vi /etc/sysctl.conf
在文件底部增加以下行,然后按 Esc 后输入:wq
退出。
输入以下命令以触发新的内核配置即可。
输入以下命令以显示网络接口的名称。
示例如下。
1 2 3 4 5 6 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 72:2d:7e:6f:5e:08 brd ff:ff:ff:ff:ff:ff 3: zt0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 2800 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 1000 link/ether be:82:8f:f3:b4:cd brd ff:ff:ff:ff:ff:ff
输入以下命令以添加规则,并允许服务器的网卡 eth0 转发所有 ZeroTier 虚拟网卡 zt0 的流量。
1 2 3 sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE sudo iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i zt0 -o eth0 -j ACCEPT
因为 iptables 规则会在服务器重启后丢失,因此需要输入以下命令安装 iptables-persistent 并保存添加的规则。
1 2 sudo apt install iptables-persistent sudo netfilter-persistent save
运行时会有提示,分别保存 IPv4 和 IPv6 的规则。需根据服务器是否提供该类地址而选择是否保存,若只有 IPV4 地址,则只保存 IPV4 规则即可,无需保存 IPV6 规则。
通过以下命令查看已保存的规则。
输出的规则内容如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 # Generated by iptables-save v1.6.1 on Thu May 24 08:39:37 2018 *nat :PREROUTING ACCEPT [256:29654] :INPUT ACCEPT [230:28276] :OUTPUT ACCEPT [2812:383290] :POSTROUTING ACCEPT [2220:333986] -A POSTROUTING -o eth0 -j MASQUERADE -A POSTROUTING -o eth0 -j MASQUERADE COMMIT # Completed on Thu May 24 08:39:37 2018 # Generated by iptables-save v1.6.1 on Thu May 24 08:39:37 2018 *filter :INPUT ACCEPT [39673:10536131] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [41822:10787996] :sshguard - [0:0] -A INPUT -j sshguard -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT -A FORWARD -i zt0 -o eth0 -j ACCEPT COMMIT # Completed on Thu May 24 08:39:37 2018
上述内容表示已保存转发规则,可以转发来自客户端的流量。
打开以下链接并注册,进入后台后点击 Networks-Create,记录 Network ID。保证 Access Control 为 Certificate (Private Network),IPv4 Auto-Assign 需要勾选 Auto-Assign from Range,下面的地址可以任意选择。
1 https://www.zerotier.com/
在服务器上输入以下命令以连接到网络,其中 Network ID 需要修改为刚才记下的值。
1 sudo zerotier-cli join [NetworkID]
在客户端下载 Zerotier 客户端,链接如下。打开客户端并输入刚才记下的 Network ID 以连接。
1 https://www.zerotier.com/download/
返回 Zerotier 后台,在 Members 下可看到服务端和客户端,勾选它们前面的 Auth?
选项,等待一段时间后分别在服务端和客户端输入以下命令以查看自己的 IP 地址。
1 ip addr sh zt0 | grep 'inet'
在服务端和客户端分别 ping 对方的地址,查看是否已经联通。回到 Zerotier 后台,在 Managed Routes 一栏下分别填写 0.0.0.0/0 和服务器的 IP 地址,表示由该服务器处理所有客户端的流量。
在客户端勾选 Route all traffic through ZeroTier 和 allow global IP,即可使客户端的流量通过服务器。
全平台快速搭建 Streisand 在 VPS 上运行多个不同的翻墙工具。
1 https://github.com/StreisandEffect/streisand/blob/master/README-chs.md
ProxySU 适用于 Windows。打开以下链接以下载 ProxySU。
1 https://github.com/proxysu/ProxySU
完成后在本地打开,按照流程进行即可。
相关命令 关闭防火墙 适用于 CentOS。
1 2 3 4 5 6 7 8 // 查看防火墙状态 firewall-cmd --state // 停止防火墙 systemctl stop firewalld.service // 禁止防火墙开机启动 systemctl disable firewalld.service
修改中国时区 1 \cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
利用 NTP 同步时间协议 1 2 3 4 5 6 7 8 // CentOS yum install ntp ntpdate -y // Ubuntu/Debian apt-get install ntp ntpdate -y service ntpd stop ntpdate us.pool.ntp.org service ntpd start
提示 curl: command not found 未安装 curl 导致。通过以下命令安装。
1 2 3 4 5 // ubuntu/debian系统 apt-get update -y && apt-get install curl -y // centOS系统 yum update -y && yum install curl -y
提示 wget: command not found 未安装 wget 导致。通过以下命令安装。
1 2 3 4 5 // ubuntu/debian系统 apt-get update -y && apt-get install -y wget // centOS系统 yum update -y && yum install -y wget
服务器进阶 SSH 连接 SSH 可用于连接到服务器。
连接方法 浏览器连接 GCP 默认方式。点击服务器的 SSH
按钮即自动建立与服务器的 SSH 连接。
命令行连接 在终端输入以下命令即可。
1 ssh -p 22 root@localhost
手机 APP 连接 推荐使用 HyperApp。
文件传输 可通过 scp 命令向连接到的服务器传输文件,命令格式如下。
1 2 3 4 // 上传文件到服务器 scp [本地文件路径] remote_username@remote_ip:[服务器文件路径] // 上传文件夹到服务器 scp -r [本地文件夹路径] remote_username@remote_ip:[服务器文件夹路径]
下载文件或文件夹,则将后面参数对调即可。
服务器配置 一般服务器会提供 SSH 连接的入口,包括地址、密码等,端口默认为 22。但有部分服务器需要手动配置。
通过浏览器进入服务器后台,输入以下命令以切换到 root 并编辑 SSH 配置文件。
1 2 sudo -i vi /etc/ssh/sshd_config
在配置文件中修改 PermitRootLogin 和 PasswordAuthentication 为 yes,如下。
1 2 3 4 5 # Authentication: PermitRootLogin yes //默认为no,需要开启root用户访问改为yes # Change to no to disable tunnelled clear text passwords PasswordAuthentication yes //默认为no,改为yes开启密码登陆
保存后输入以下命令以给 root 用户设置密码。
设置完成后输入以下命令重启 SSH 服务即可。
运行代码 配置服务器运行环境 以运行 Python 代码为例。连接到服务器并取得 root 权限,运行以下命令以安装 Python 3.7 和 pip。
1 2 apt-get install python3.7 apt-get install pip
通过 pip 安装代码运行所需要的库,如下。
进入到用户目录并新建文件夹,作为代码存放的位置。
1 2 cd /home/[用户名] mkdir [文件夹名]
配置本地运行环境 打开 Pycharm Professional,新建工程后选择 File-Settings,进入 project interpreter,点击 add,选择 SSH interpreter。输入服务器信息后进行连接,连接完成后配置编译器路径为 /usr/bin/python3
。
保存后选择 Tool-Deployment-Configuration,点击刚才新建的服务器,在 Mappings 标签页选择路径为在服务器端新建好的文件夹。保存后选择 Upload 即可。
运行代码 通过 Pycharm 运行前选择服务器端的编译器,运行即可。
通过服务器自身 在需要运行的 Python 代码最前面加入以下代码。
进入服务器命令行,切换到代码目录后通过以下命令使代码后台运行并将输出存到文件。此时可以关闭该 SSH 连接。
1 nohup python3 -u [test.py] > [test.log] 2>&1 &
需要结束运行时,执行以下代码即可。
1 2 ps -aux | grep python3 kill [PID]
也可通过 pm2 的方式。安装 pm2 管理器后运行以下命令即可。
1 2 3 pm2 start [test.py] --name [name] pm2 save pm2 startup
结束运行的命令与上面一致。
网盘文件下载 Google Drive 通过 wget 从 Google Drive 分享文件后获取其链接,示例如下。其中 1dt4SEYtvK_7LcFNaxKsldGCDd1SMbBlAFILEID
即为 FILEID
。
1 https://drive.google.com/file/d/1dt4SEYtvK_7LcFNaxKsldGCDd1SMbBlA/view?usp=sharing
对于小文件采用以下命令,其中 FILENAME
自己命名即可。
1 wget --no-check-certificate ‘https://docs.google.com/uc?export=download&id=FILEID’ -O FILENAME
对于大文件采用以下命令。
1 wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=FILEID" -O FILENAME && rm -rf /tmp/cookies.txt
通过 gdown 在终端输入以下命令即可。
1 2 pip install gdown gdown https://drive.google.com/uc?id=[文件ID]
通过 gdown 脚本 下载以下脚本。
1 https://raw.githubusercontent.com/circulosmeos/gdown.pl/with-resume/gdown.pl
在终端切换到脚本所在目录,运行以下命令即可。
1 ./gdown.pl [文件链接] [重命名的文件名]
创建图形界面系统 在 Google Cloud Shell 中 进入 GCP 并点击右上方的终端按钮,进入 Cloud Shell。输入以下命令以部署并查看状态。
1 2 3 sudo -i docker run -itd -p 6080:6080 -e PASSWORD=1234 chenjr0719/ubuntu-unity-novnc docker ps
点击 Cloud Shell 右上角的预览,更改端口为 6080,更改并预览即可。
在 VM 实例中 新建 VM 实例并通过 SSH 连接,然后输入以下命令。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 sudo -i apt update apt-get install --assume-yes wget wget https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb dpkg --install chrome-remote-desktop_current_amd64.deb apt install --assume-yes --fix-broken DEBIAN_FRONTEND=noninteractive apt install --assume-yes xfce4 desktop-base bash -c 'echo "exec /etc/X11/Xsession /usr/bin/xfce4-session" > /etc/chrome-remote-desktop-session' apt install --assume-yes xscreensaver // (可选)安装全套Linux桌面应用,包括Firefox浏览器、LibreOffice办公应用套件和Evince PDF查看器 apt install --assume-yes task-xfce-desktop systemctl disable lightdm.service // (可选)安装Chrome浏览器 wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb dpkg --install google-chrome-stable_current_amd64.deb apt install --assume-yes --fix-broken usermod -a -G chrome-remote-desktop $USER logout logout
重新连接到实例,然后打开以下链接,一路下一步。
1 https://remotedesktop.google.com/headless
复制含 DISPLAY 的代码到 VM 实例中并运行,然后打开以下链接以访问远程桌面。
1 https://remotedesktop.google.com/access/
安装 matlab 通过以上过程安装图形界面,然后在图形界面中进入官网下载安装包即可。
安装完成后,通过 SSH 连接服务器并运行 matlab
即可调用 matlab。
端口限制上行网速 在命令行输入以下命令,检查 iptables
和 tc
是否被安装,若未安装则通过 apt 等软件包管理器安装。
通过以下命令查看网卡。需要找到外网网卡,可通过 IP 地址判断。
以 eth0 为例,命令如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 // 清理iptables Mangle规则 iptables -t mangle -F // 清理eth0上原有的队列类型 tc qdisc del dev eth0 root // 给eth0添加一个根规则 tc qdisc add dev eth0 root handle 1: htb default 1 // 创建根类(100mbps替换成服务器的实际带宽) tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbps // 创建支类限速(以下数据根据需要进行替换) // rate1500Kbit代表最大带宽1536Kbit/s // ceil 2048Kbit代表突发带宽2048Kbit/s // ceil>=rate // 1:5指每5秒钟检查一次 tc class add dev eth0 parent 1:1 classid 1:5 htb rate 1500Kbit ceil 2048Kbit prio 1 // 创建过滤器(flowid和上一条的classid对应) tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 5 fw flowid 1:5 // 借助iptables针对端口限速(80为端口号) iptables -A OUTPUT -t mangle -p tcp --sport 80 -j MARK --set-mark 5 // 限制多端口 // iptables -A OUTPUT -t mangle -p tcp --sport 80,25,443,8989 -j MARK --set-mark 5 // 限制10000-20000端口 // iptables -A OUTPUT -t mangle -p tcp --sport 10000:20000 -j MARK --set-mark 5
挂机赚钱 Vagex 在命令行输入以下命令以安装容器。
1 docker run -d --name alpine-ssh-xfce4-vnc -p 22:22 -p 3389:3389 charliev5/alpine-desktop
安装完成后通过远程桌面连接到服务器,然后用 Firefox 打开以下网址,注册后安装插件并重启浏览器即可。
可通过以下命令检查是否正常运行。
1 2 wget https://raw.githubusercontent.com/WangCharlie/alpine-ssh-xfce4-vnc/master/check.sh sh check.sh
eBesucher 官网如下。
1 https://www.ebesucher.com/
Google Adsense 需要有个人网站。可用西联汇款收款。
1 https://www.google.com.tw/intl/zh-CN_cn/adsense/start/?utm_campaign=redirect-301
Docker 机制 Docker 即镜像,相当于打包好的系统,部署到服务器后即可直接使用。Docker 一般可在 Docker Hub 上找到。
1 https://registry.hub.docker.com/
Docker 部署到服务器后,该服务被称为 Container,即容器。以 Kubernetes 集群为例,安装 Docker 时一般需要有 yml 文件以配置相关参数。
示例如下。将 v2-app
改为另一个名称,pch18/baota:clear
更换为其他容器,port: 8888
改为容器内暴露端口即可,其中暴露端口可看相关镜像的说明。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 apiVersion: apps/v1 kind: Deployment metadata: name: v2-app spec: replicas: 1 selector: matchLabels: app: v2-app template: metadata: labels: app: v2-app spec: containers: - image: gingko/v2ray-nginx-websocket name: v2-app --- apiVersion: v1 kind: Service metadata: name: v2-app annotations: dev.okteto.com/auto-ingress: "true" spec: type: ClusterIP ports: - name: "http-port-tcp" port: 8080 selector: app: v2-app
保存后执行以下命令部署即可。
1 kubectl apply -f [yml文件路径]
仓库和示例如下。
1 https://github.com/pch18-docker/baota
yml 文件 搭建宝塔 完成后通过所给的网站即可访问。用户名为 username
,密码为 password
。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 apiVersion: apps/v1 kind: Deployment metadata: name: bt-app spec: replicas: 1 selector: matchLabels: app: bt-app template: metadata: labels: app: bt-app spec: containers: - image: baiyuetribe/baota-mini name: bt-app --- apiVersion: v1 kind: Service metadata: name: bt-app annotations: dev.okteto.com/auto-ingress: "true" spec: type: ClusterIP ports: - name: "http-port-tcp" port: 8888 selector: app: bt-app
搭建 Google 镜像网站 完成后通过所给的网站即可访问。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 apiVersion: apps/v1 kind: Deployment metadata: name: google-app spec: replicas: 1 selector: matchLabels: app: google-app template: metadata: labels: app: google-app spec: containers: - image: jim3ma/google-mirror name: google-app --- apiVersion: v1 kind: Service metadata: name: google-app annotations: dev.okteto.com/auto-ingress: "true" spec: type: ClusterIP ports: - name: "http-port-tcp" port: 80 selector: app: google-app
搭建 Linux 完成后通过所给的网站即可访问,默认以 root 身份登录。密码为 vncpassword
。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 apiVersion: apps/v1 kind: Deployment metadata: name: google-app spec: replicas: 1 selector: matchLabels: app: ubuntu-app template: metadata: labels: app: ubuntu-app spec: containers: - image: fallfor/ubuntuvnc name: ubuntu-app --- apiVersion: v1 kind: Service metadata: name: ubuntu-app annotations: dev.okteto.com/auto-ingress: "true" spec: type: ClusterIP ports: - name: "http-port-tcp" port: 6901 selector: app: ubuntu-app
可用的其他镜像如下,默认以非 root 身份登录。密码也为 vncpassword
。
1 2 3 4 consol/centos-xfce-vnc consol/ubuntu-xfce-vnc consol/centos-icewm-vnc consol/ubuntu-icewm-vnc
Docker 收集 库 1 https://github.com/mritd/dockerfile
签到 1 https://github.com/AragonSnow/qiandao
一键重装系统 原系统为 Linux 特别注意 OpenVZ 构架不适用,安装之前备份重要数据。适用于由 GRUB 引导的 CentOS/Ubuntu/Debian 系统。使用官方发行版去掉模板预装的软件,同时也可以解决内核版本与软件不兼容的问题。
全自动安装默认 root 密码为 Vicer。相关软件依赖如下。
1 2 3 4 5 6 7 // Debian/Ubuntu apt-get update apt-get install -y gawk sed grep // RedHat/CentOS yum update yum install -y gawk sed grep
在安装 Ubuntu 时可能会遇到 Getting the time form a network time server...
并界面进度条很长时间不会动,可以等待其超时,或更换别的版本。
Debian 7 1 2 3 4 5 # x86 wget --no-check-certificate -qO DebianNET.sh 'https://moeclub.org/attachment/LinuxShell/DebianNET.sh' && chmod -x DebianNET.sh && bash DebianNET.sh -d 7 -v 32 # x64 wget --no-check-certificate -qO DebianNET.sh 'https://moeclub.org/attachment/LinuxShell/DebianNET.sh' && chmod -x DebianNET.sh && bash DebianNET.sh -d 7 -v 64
Debian 8 1 2 3 4 5 # x86 wget --no-check-certificate -qO DebianNET.sh 'https://moeclub.org/attachment/LinuxShell/DebianNET.sh' && chmod -x DebianNET.sh && bash DebianNET.sh -d 8 -v 32 # x64 wget --no-check-certificate -qO DebianNET.sh 'https://moeclub.org/attachment/LinuxShell/DebianNET.sh' && chmod -x DebianNET.sh && bash DebianNET.sh -d 8 -v 64
Debian 9 1 2 3 4 5 # x86 wget --no-check-certificate -qO DebianNET.sh 'https://moeclub.org/attachment/LinuxShell/DebianNET.sh' && chmod -x DebianNET.sh && bash DebianNET.sh -d 9 -v 32 # x64 wget --no-check-certificate -qO DebianNET.sh 'https://moeclub.org/attachment/LinuxShell/DebianNET.sh' && chmod -x DebianNET.sh && bash DebianNET.sh -d 9 -v 64
Ubuntu 14.04 1 2 3 4 5 # x86 wget --no-check-certificate -qO DebianNET.sh 'https://moeclub.org/attachment/LinuxShell/DebianNET.sh' && chmod -x DebianNET.sh && bash DebianNET.sh -d trusty -v 32 # x64 wget --no-check-certificate -qO DebianNET.sh 'https://moeclub.org/attachment/LinuxShell/DebianNET.sh' && chmod -x DebianNET.sh && bash DebianNET.sh -d trusty -v 64
Ubuntu 16.04 1 2 3 4 5 # x86 wget --no-check-certificate -qO DebianNET.sh 'https://moeclub.org/attachment/LinuxShell/DebianNET.sh' && chmod -x DebianNET.sh && bash DebianNET.sh -d xenial -v 32 # x64 wget --no-check-certificate -qO DebianNET.sh 'https://moeclub.org/attachment/LinuxShell/DebianNET.sh' && chmod -x DebianNET.sh && bash DebianNET.sh -d xenial -v 64
Ubuntu 17.04 1 2 3 4 5 # x86 wget --no-check-certificate -qO DebianNET.sh 'https://moeclub.org/attachment/LinuxShell/DebianNET.sh' && chmod -x DebianNET.sh && bash DebianNET.sh -d zesty -v 32 # x64 wget --no-check-certificate -qO DebianNET.sh 'https://moeclub.org/attachment/LinuxShell/DebianNET.sh' && chmod -x DebianNET.sh && bash DebianNET.sh -d zesty -v 64
CentOS X64 版本,root 用户密码为 xiaofd.win
。
1 wget xiaofd.github.io/centos.sh && bash centos.sh
Windows 1 wget --no-check-certificate -qO DebianNET.sh 'https://moeclub.org/attachment/LinuxShell/DebianNET.sh' && bash DebianNET.sh -dd 'https://moeclub.org/get-win7embx86-auto'
原系统为 Windows Linux 下载以下脚本并运行即可。
1 https://moeclub.org/attachment/WindowsSoftware/win32loader.bat
特殊工具 Tor Tor 是经过层层加密的浏览器,从使用者本机直到出口节点的传输是强加密的,其他人无法偷窥到真实网络流量,除非 Tor 软件本身出现严重安全漏洞,或者碰到的出口节点是蜜罐节点(或称为陷阱节点),即故意引诱用户攻击的目标。
Tor 主要用于隐匿上网身份,也可用于伪装别国网民、隐匿公网 IP、保护隐私等。Tor 的官方 Wiki 如下。
1 https://gitlab.torproject.org/legacy/trac/-/wikis/home
原理 Tor 联网 当 Tor 客户端启动之后,会首先连接 Tor 的目录服务器,从目录服务器中获取全球的 Tor 节点信息。访问网站时,Tor 客户端会随机挑选三个节点用于中转,如下。
节点类型
特点
入口节点
直接与本机或前置代理(若使用双重代理)相连
中间节点
介于入口节点和出口节点之间,该节点威胁最小
出口节点
直接与访问的目标网站相连,该节点威胁最大
只有出口节点会看到用户的上网行为,包括访问的网站、从该网站传输的流量等。其它节点完全无法了解上网行为。
如果这个网站使用 HTTPS 协议,出口节点看到的原始流量是 HTTPS 的密文。但如果这个网站使用 HTTP 协议,那么出口节点看到的原始流量是 HTTP 的明文。
Tor 为了加强隐匿性,会动态变化中转线路,每隔一段时间随机挑选三个节点,重新构造一条传输线路。因为线路动态变化,出口节点自然也动态变化,所以即使出口节点偷窥上网行为,也只能看到一个短暂的片段。
流量混淆 若 ISP 和墙在监控流量,则可以判断出在使用 Tor。因此需要使用流量混淆,把 Tor 流量伪装成其它的上网流量。出于软件架构方面的考虑,流量混淆通过插件的方式来提供,因为混淆流量的方式是多种多样的。
meek 是常用的流量混淆插件,可以把 Tor 流量伪装成访问云计算平台的流量。当数据流量到达云计算平台之后,会经过一系列中转,最终转向真正访问的网站。由于传输流量经过伪装,墙比较难区分伪装的 Tor 流量和真正访问云计算的普通流量,而且 meek 依赖的云计算平台都是亚马逊、微软等大公司提供,墙不会轻易封锁其公网 IP。
使用 配置 打开以下链接下载并安装。Mac 也可直接通过 Homebrew 安装,但通过此方法安装的 Tor 并没有图形界面。
1 https://www.torproject.org/download/
也可通过发送标题为 help
的邮件到 gettor@torproject.org
获取。
安装完成后需要寻找支持 HTTPS 代理或 Socks 代理的代理,注意不能是 HTTP 代理。可以通过公共代理节点,也可通过在本地挂翻墙软件实现,大部分翻墙软件都可以与 Tor 组合。打开翻墙软件后,从配置中查看代理类型、代理地址和端口,比如 SOCKS5 代理的 localhost:1081
。
注意,GoAgent 是 Google Agent Engine(GAE)翻墙工具的一种,似乎只提供 HTTP 代理,没有提供原生的 HTTPS 代理,因此不能用作 Tor 的代理节点。
打开 Tor 后点击配置,勾选我所在的国家对Tor进行了审查
,并选择选择内置网桥
。勾选使用代理访问互联网
,填入上面查询的内容,然后连接即可。
验证 可通过以下链接判断当前是否在使用 Tor。
1 https://check.torproject.org/
屏蔽节点 为避免蜜罐节点,可通过修改 Tor 的配置文件,规避特定地区的节点。打开 Tor 的配置文件 torrc,添加以下内容。其中 ExcludeNodes 表示排除这些地区的节点,StrictNodes 表示强制执行。
如果不设置 strictnode 1,Tor 首先也会规避 ExcludeNodes 列出的这些地区,但如果 Tor 找不到可用的线路,就会去尝试位于排除列表中的节点。如果设置了 strictnode 1,即使 Tor 找不到可用的线路,也不会去尝试这些地区的节点。
1 2 ExcludeNodes {cn},{hk},{mo} StrictNodes 1
其余代码如下,可根据需求自行获取。
1 2 3 4 5 6 北朝鲜 / {kp} 伊朗 / {ir} 叙利亚 / {sy} 巴基斯坦 / {pk} 古巴 / {cu} 越南 / {vn}
共享 Tor 通道 打开 Tor 的配置文件 torrc,新增以下内容。
1 2 SocksListenAddress 0.0.0.0:9150 // SOCKSPort 0.0.0.0:9150
重启 Tor 后,Tor 的监听端口将绑定到 0.0.0.0,即任何地址(任何机器)都可以连接到 Tor 的监听端口。可能需要修改防火墙配置,允许 Tor 监听端口的 TCP 连入。
特殊说明 Tor 可以打开特有的 onion 域名链接,导航如下。注意抵制诱惑。
1 https://thehiddenwiki.org/
ZeroNet 也称零网,利用比特币加密和 BT 技术提供不受审查的网络与通信的 BT 平台。ZeroNet 默认不匿名,用户可以通过内置的 Tor 功能进行匿名化。ZeroNet 需要全局翻墙才能使用。
打开以下链接并下载软件包,双击打开即可。
ZeroMe 打开后点击 ZeroMe,点击右上角允许请求权限,进入请求认证证书界面,输入用户名后即可授权成功。点击在用户数据库中搜索
可查看已注册用户并拉入黑名单,点击右上角的 0
图标可回到控制台首页,在设置中也可管理屏蔽用户。再次进入 ZeroMe,选择已注册好的账户并下载相关组件,完成之后加入即可。
备份用户数据 若将 Zeronet 整个文件夹删除,重新载入则失去对当前账户的所有权且无法找回,因此需备份 users.json 文件。
重新载入时,打开 ZeroNet 让其生成 data 文件夹,复制已备份好的 users.json 文件放置在 data 文件夹。重启 ZeroNet 并打开 ZeroMe,下载完数据库点击授权,再重启 ZeroNet 打开 ZeroMe 即可。
网址导航 若遇到 site Blocked 或 disable proxy,将 www.zerogate.tk
换成 127.0.0.1:43110 即可。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 // 零搜索 https://www.zerogate.tk/lingdu.bit // 零123导航 https://www.zerogate.tk/0123.bit // 海盗湾种子站 http://127.0.0.1:43110/1PLAYgDQboKojowD3kwdb3CtWmWaokXvfp/ // Kindle电子书 http://127.0.0.1:43110/1KHCBG6dmbKXTZNenfwhWZ5x3oDyYyHSD4 // 中文主题 http://127.0.0.1:43110/1NzWeweqJ32aRVdM5UzFnYCszuvG5xV3vS
附录 通过信用卡验证 使用 VPS 服务需要 VISA 或 Mastercard 的卡,不同 VPS 供应商的验证标准不同。
免费虚拟卡 香港全球付预付卡(MasterCard) 可通过 2018 年 GCP 验证,不可通过 2019 年及以后的 GCP 验证。
1 https://www.globalcash.hk/v4/
香港拍住赏预付卡(MasterCard) 需要香港号码,在 App Store 下载拍住赏
即可。
Yandex Money(MasterCard) 提供免费万事达虚拟信用卡,一年有效期。GCP、DO、Vultr 均无法通过验证。
1 https://money.yandex.ru/
Uquid(VISA) 未验证。
1 https://uquid.com/uquid-card
付费虚拟卡 EastPay 1 https://card.easypayx.com/card/cards
实体卡 香港 neat 借记卡(MasterCard) 激活后若超过半年未使用,将从第七个月开始收取休眠费。
从 App Store 下载 neat
,把手机语言改成英语。打开 APP 并注册,添加收卡地址时会提示只能寄到商业地址,且用顺丰快递收取 36 到 43 人民币的邮费,但实际是可以寄到私人地址的,且通过 Hong Kong post 免费邮寄。
中国银行长城跨境通单标储蓄卡(Visa/MasterCard) 可通过 2019 年 GCP 验证。
爱汇国际旅支卡(MasterCard) 用微信打开以下链接,点击我要旅支卡
,跳转后点击添加新卡即可。
1 https://www.ihui.com/alliance/share/43cc72a60e694fdeb775d9566c04e4fc.html
获取美国号码 获取美国号码后可以很方便地通过 VPS 的验证。
虚拟号码 免费号码可使用 TextNow、TextPlus、HeyWire、Ring4、TalkU、TextMe、TextFree、TextNow、Talkatone、Dingtone、Pinger 等。
Google Voice 包括以上的虚拟号码基本已无法通过 Google Voice 验证。
注册 失效教程
全程挂美国全局代理,浏览器用无痕模式。通过以下付费接码网站接收 Google Voice 验证码,购买时类型选择 Google Voice。
1 2 3 4 5 6 // verfirywithsms https://verifywithsms.com/ // PVA Deals,购买Non VolP Numbers https://pvadeals.com/product/non-voip/
保号 如果超过六个月没有拨打或者接听电话,也没有发出或接收过短信,号码就会被回收。可利用 IFTTT 自动接收和发送短信以保号。
自动发送短信 注册 IFTTT 账号后打开以下链接,分别设置时区和 Google Voice 号码。
1 2 https://ifttt.com/services/date_and_time/settings https://ifttt.com/sms
打开以下链接以新建一个 Applet。
1 https://ifttt.com/create/
点 If This 后的 Add,并选择 Date&Time。有多种触发条件,根据自己的实际需求选择。再点 Then that 后的 Add,选择 SMS,并自定义短信内容。创建完打开该 Applet 即可。
自动回复短信 登录 Google Voice,进入 Settings—>Settings—>Forward messages to email,打开将短信转发到 Gmail 邮箱。完成后 Google Voice 收到的短信都会以邮件的形式发送到 Gmail 邮箱,邮件标题为 New text message from [发送者]
,发件人是后缀为 @txt.voice.google.com
的邮箱,前缀里包含短信发送方和接收方的号码。
仍打开上面的链接新建一个 Applet,If this 添加 Gmail,并选择 [Inactive] New email in inbox from search
,内容填写 txt.voice.google.com
。然后 Then that 添加 Gmail,并选择 Send an email
,按照以下内容配置,然后打开该 Applet 即可。
1 2 3 To address / 点Add ingredient,选FromAddress Body / 短信内容 Attachment URL / 清空
脚本 性能测试 1 2 3 wget -qO- 86.re/bench.sh | bash wget -qO- --no-check-certificate https://raw.githubusercontent.com/oooldking/script/master/superbench.sh | bash wget https://raw.githubusercontent.com/oooldking/script/master/superspeed.sh && chmod +x superspeed.sh && ./superspeed.sh
Socat 一个多功能的网络工具。
1 wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/socat.sh && chmod +x socat.sh && bash socat.sh
HaProxy 负载均衡,与 Nginx 类似。
1 wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/haproxy.sh && chmod +x haproxy.sh && bash haproxy.sh
iptables 端口转发。
1 wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/iptables-pf.sh && chmod +x iptables-pf.sh && bash iptables-pf.sh
SimpleHTTPServer 快速搭建 HTTP 服务。
1 wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/pythonhttp.sh && chmod +x pythonhttp.sh && bash pythonhttp.sh
V2Ray 安装 复制以下代码到文本编辑器并另存为 go.sh,放在工作目录即可使用。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 #!/bin/bash # This file is accessible as https://install.direct/go.sh # Original source is located at github.com/v2ray/v2ray-core/release/install-release.sh # If not specify, default meaning of return value: # 0: Success # 1: System error # 2: Application error # 3: Network error CUR_VER="" NEW_VER="" ARCH="" VDIS="64" ZIPFILE="/tmp/v2ray/v2ray.zip" V2RAY_RUNNING=0 VSRC_ROOT="/tmp/v2ray" EXTRACT_ONLY=0 ERROR_IF_UPTODATE=0 DIST_SRC="github" CMD_INSTALL="" CMD_UPDATE="" SOFTWARE_UPDATED=0 SYSTEMCTL_CMD=$(command -v systemctl 2>/dev/null) SERVICE_CMD=$(command -v service 2>/dev/null) CHECK="" FORCE="" HELP="" #######color code######## RED="31m" # Error message GREEN="32m" # Success message YELLOW="33m" # Warning message BLUE="36m" # Info message ######################### while [[ $# > 0 ]];do key="$1" case $key in -p|--proxy) PROXY="-x ${2}" shift # past argument ;; -h|--help) HELP="1" ;; -f|--force) FORCE="1" ;; -c|--check) CHECK="1" ;; --remove) REMOVE="1" ;; --version) VERSION="$2" shift ;; --extract) VSRC_ROOT="$2" shift ;; --extractonly) EXTRACT_ONLY="1" ;; -l|--local) LOCAL="$2" LOCAL_INSTALL="1" shift ;; --source) DIST_SRC="$2" shift ;; --errifuptodate) ERROR_IF_UPTODATE="1" ;; *) # unknown option ;; esac shift # past argument or value done ############################### colorEcho(){ COLOR=$1 echo -e "\033[${COLOR}${@:2}\033[0m" } sysArch(){ ARCH=$(uname -m) if [[ "$ARCH" == "i686" ]] || [[ "$ARCH" == "i386" ]]; then VDIS="32" elif [[ "$ARCH" == *"armv7"* ]] || [[ "$ARCH" == "armv6l" ]]; then VDIS="arm" elif [[ "$ARCH" == *"armv8"* ]] || [[ "$ARCH" == "aarch64" ]]; then VDIS="arm64" elif [[ "$ARCH" == *"mips64le"* ]]; then VDIS="mips64le" elif [[ "$ARCH" == *"mips64"* ]]; then VDIS="mips64" elif [[ "$ARCH" == *"mipsle"* ]]; then VDIS="mipsle" elif [[ "$ARCH" == *"mips"* ]]; then VDIS="mips" elif [[ "$ARCH" == *"s390x"* ]]; then VDIS="s390x" elif [[ "$ARCH" == "ppc64le" ]]; then VDIS="ppc64le" elif [[ "$ARCH" == "ppc64" ]]; then VDIS="ppc64" fi return 0 } downloadV2Ray(){ return 0 } installSoftware(){ COMPONENT=$1 if [[ -n `command -v $COMPONENT` ]]; then return 0 fi getPMT if [[ $? -eq 1 ]]; then colorEcho ${RED} "The system package manager tool isn't APT or YUM, please install ${COMPONENT} manually." return 1 fi if [[ $SOFTWARE_UPDATED -eq 0 ]]; then colorEcho ${BLUE} "Updating software repo" $CMD_UPDATE SOFTWARE_UPDATED=1 fi colorEcho ${BLUE} "Installing ${COMPONENT}" $CMD_INSTALL $COMPONENT if [[ $? -ne 0 ]]; then colorEcho ${RED} "Failed to install ${COMPONENT}. Please install it manually." return 1 fi return 0 } # return 1: not apt, yum, or zypper getPMT(){ if [[ -n `command -v apt-get` ]];then CMD_INSTALL="apt-get -y -qq install" CMD_UPDATE="apt-get -qq update" elif [[ -n `command -v yum` ]]; then CMD_INSTALL="yum -y -q install" CMD_UPDATE="yum -q makecache" elif [[ -n `command -v zypper` ]]; then CMD_INSTALL="zypper -y install" CMD_UPDATE="zypper ref" else return 1 fi return 0 } extract(){ colorEcho ${BLUE}"Extracting V2Ray package to /tmp/v2ray." mkdir -p /tmp/v2ray unzip $1 -d ${VSRC_ROOT} if [[ $? -ne 0 ]]; then colorEcho ${RED} "Failed to extract V2Ray." return 2 fi if [[ -d "/tmp/v2ray/v2ray-${NEW_VER}-linux-${VDIS}" ]]; then VSRC_ROOT="/tmp/v2ray/v2ray-${NEW_VER}-linux-${VDIS}" fi return 0 } # 1: new V2Ray. 0: no. 2: not installed. 3: check failed. 4: don't check. getVersion(){ if [[ -n "$VERSION" ]]; then NEW_VER="$VERSION" if [[ ${NEW_VER} != v* ]]; then NEW_VER=v${NEW_VER} fi return 4 else VER=`/usr/bin/v2ray/v2ray -version 2>/dev/null` RETVAL="$?" CUR_VER=`echo $VER | head -n 1 | cut -d " " -f2` if [[ ${CUR_VER} != v* ]]; then CUR_VER=v${CUR_VER} fi TAG_URL="https://api.github.com/repos/v2ray/v2ray-core/releases/latest" NEW_VER=`curl ${PROXY} -s ${TAG_URL} --connect-timeout 10| grep 'tag_name' | cut -d\" -f4` if [[ ${NEW_VER} != v* ]]; then NEW_VER=v${NEW_VER} fi if [[ $? -ne 0 ]] || [[ $NEW_VER == "" ]]; then colorEcho ${RED} "Failed to fetch release information. Please check your network or try again." return 3 elif [[ $RETVAL -ne 0 ]];then return 2 elif [[ `echo $NEW_VER | cut -d. -f-2` != `echo $CUR_VER | cut -d. -f-2` ]];then return 1 fi return 0 fi } stopV2ray(){ colorEcho ${BLUE} "Shutting down V2Ray service." if [[ -n "${SYSTEMCTL_CMD}" ]] || [[ -f "/lib/systemd/system/v2ray.service" ]] || [[ -f "/etc/systemd/system/v2ray.service" ]]; then ${SYSTEMCTL_CMD} stop v2ray elif [[ -n "${SERVICE_CMD}" ]] || [[ -f "/etc/init.d/v2ray" ]]; then ${SERVICE_CMD} v2ray stop fi if [[ $? -ne 0 ]]; then colorEcho ${YELLOW} "Failed to shutdown V2Ray service." return 2 fi return 0 } startV2ray(){ if [ -n "${SYSTEMCTL_CMD}" ] && [ -f "/lib/systemd/system/v2ray.service" ]; then ${SYSTEMCTL_CMD} start v2ray elif [ -n "${SYSTEMCTL_CMD}" ] && [ -f "/etc/systemd/system/v2ray.service" ]; then ${SYSTEMCTL_CMD} start v2ray elif [ -n "${SERVICE_CMD}" ] && [ -f "/etc/init.d/v2ray" ]; then ${SERVICE_CMD} v2ray start fi if [[ $? -ne 0 ]]; then colorEcho ${YELLOW} "Failed to start V2Ray service." return 2 fi return 0 } copyFile() { NAME=$1 ERROR=`cp "${VSRC_ROOT}/${NAME}" "/usr/bin/v2ray/${NAME}" 2>&1` if [[ $? -ne 0 ]]; then colorEcho ${YELLOW} "${ERROR}" return 1 fi return 0 } makeExecutable() { chmod +x "/usr/bin/v2ray/$1" } installV2Ray(){ # Install V2Ray binary to /usr/bin/v2ray mkdir -p /usr/bin/v2ray copyFile v2ray if [[ $? -ne 0 ]]; then colorEcho ${RED} "Failed to copy V2Ray binary and resources." return 1 fi makeExecutable v2ray copyFile v2ctl && makeExecutable v2ctl copyFile geoip.dat copyFile geosite.dat # Install V2Ray server config to /etc/v2ray if [[ ! -f "/etc/v2ray/config.json" ]]; then mkdir -p /etc/v2ray mkdir -p /var/log/v2ray cp "${VSRC_ROOT}/vpoint_vmess_freedom.json" "/etc/v2ray/config.json" if [[ $? -ne 0 ]]; then colorEcho ${YELLOW} "Failed to create V2Ray configuration file. Please create it manually." return 1 fi let PORT=$RANDOM+10000 UUID=$(cat /proc/sys/kernel/random/uuid) sed -i "s/10086/${PORT}/g" "/etc/v2ray/config.json" sed -i "s/23ad6b10-8d1a-40f7-8ad0-e3e35cd38297/${UUID}/g" "/etc/v2ray/config.json" colorEcho ${BLUE} "PORT:${PORT}" colorEcho ${BLUE} "UUID:${UUID}" fi return 0 } installInitScript(){ if [[ -n "${SYSTEMCTL_CMD}" ]];then if [[ ! -f "/etc/systemd/system/v2ray.service" ]]; then if [[ ! -f "/lib/systemd/system/v2ray.service" ]]; then cp "${VSRC_ROOT}/systemd/v2ray.service" "/etc/systemd/system/" systemctl enable v2ray.service fi fi return elif [[ -n "${SERVICE_CMD}" ]] && [[ ! -f "/etc/init.d/v2ray" ]]; then installSoftware "daemon" || return $? cp "${VSRC_ROOT}/systemv/v2ray" "/etc/init.d/v2ray" chmod +x "/etc/init.d/v2ray" update-rc.d v2ray defaults fi return } Help(){ echo "./install-release.sh [-h] [-c] [--remove] [-p proxy] [-f] [--version vx.y.z] [-l file]" echo " -h, --help Show help" echo " -p, --proxy To download through a proxy server, use -p socks5://127.0.0.1:1080 or -p http://127.0.0.1:3128 etc" echo " -f, --force Force install" echo " --version Install a particular version, use --version v3.15" echo " -l, --local Install from a local file" echo " --remove Remove installed V2Ray" echo " -c, --check Check for update" return 0 } remove(){ if [[ -n "${SYSTEMCTL_CMD}" ]] && [[ -f "/etc/systemd/system/v2ray.service" ]];then if pgrep "v2ray" > /dev/null ; then stopV2ray fi systemctl disable v2ray.service rm -rf "/usr/bin/v2ray" "/etc/systemd/system/v2ray.service" if [[ $? -ne 0 ]]; then colorEcho ${RED} "Failed to remove V2Ray." return 0 else colorEcho ${GREEN} "Removed V2Ray successfully." colorEcho ${BLUE} "If necessary, please remove configuration file and log file manually." return 0 fi elif [[ -n "${SYSTEMCTL_CMD}" ]] && [[ -f "/lib/systemd/system/v2ray.service" ]];then if pgrep "v2ray" > /dev/null ; then stopV2ray fi systemctl disable v2ray.service rm -rf "/usr/bin/v2ray" "/lib/systemd/system/v2ray.service" if [[ $? -ne 0 ]]; then colorEcho ${RED} "Failed to remove V2Ray." return 0 else colorEcho ${GREEN} "Removed V2Ray successfully." colorEcho ${BLUE} "If necessary, please remove configuration file and log file manually." return 0 fi elif [[ -n "${SERVICE_CMD}" ]] && [[ -f "/etc/init.d/v2ray" ]]; then if pgrep "v2ray" > /dev/null ; then stopV2ray fi rm -rf "/usr/bin/v2ray" "/etc/init.d/v2ray" if [[ $? -ne 0 ]]; then colorEcho ${RED} "Failed to remove V2Ray." return 0 else colorEcho ${GREEN} "Removed V2Ray successfully." colorEcho ${BLUE} "If necessary, please remove configuration file and log file manually." return 0 fi else colorEcho ${YELLOW} "V2Ray not found." return 0 fi } checkUpdate(){ echo "Checking for update." VERSION="" getVersion RETVAL="$?" if [[ $RETVAL -eq 1 ]]; then colorEcho ${BLUE} "Found new version ${NEW_VER} for V2Ray.(Current version:$CUR_VER)" elif [[ $RETVAL -eq 0 ]]; then colorEcho ${BLUE} "No new version. Current version is ${NEW_VER}." elif [[ $RETVAL -eq 2 ]]; then colorEcho ${YELLOW} "No V2Ray installed." colorEcho ${BLUE} "The newest version for V2Ray is ${NEW_VER}." fi return 0 } main(){ #helping information [[ "$HELP" == "1" ]] && Help && return [[ "$CHECK" == "1" ]] && checkUpdate && return [[ "$REMOVE" == "1" ]] && remove && return sysArch # extract local file if [[ $LOCAL_INSTALL -eq 1 ]]; then colorEcho ${YELLOW} "Installing V2Ray via local file. Please make sure the file is a valid V2Ray package, as we are not able to determine that." NEW_VER=local installSoftware unzip || return $? rm -rf /tmp/v2ray extract $LOCAL || return $? #FILEVDIS=`ls /tmp/v2ray |grep v2ray-v |cut -d "-" -f4` #SYSTEM=`ls /tmp/v2ray |grep v2ray-v |cut -d "-" -f3` #if [[ ${SYSTEM} != "linux" ]]; then # colorEcho ${RED} "The local V2Ray can not be installed in linux." # return 1 #elif [[ ${FILEVDIS} != ${VDIS} ]]; then # colorEcho ${RED} "The local V2Ray can not be installed in ${ARCH} system." # return 1 #else # NEW_VER=`ls /tmp/v2ray |grep v2ray-v |cut -d "-" -f2` #fi else # download via network and extract installSoftware "curl" || return $? getVersion RETVAL="$?" if [[ $RETVAL == 0 ]] && [[ "$FORCE" != "1" ]]; then colorEcho ${BLUE} "Latest version ${NEW_VER} is already installed." if [[ "${ERROR_IF_UPTODATE}" == "1" ]]; then return 10 fi return elif [[ $RETVAL == 3 ]]; then return 3 else colorEcho ${BLUE} "Installing V2Ray ${NEW_VER} on ${ARCH}" downloadV2Ray || return $? installSoftware unzip || return $? extract ${ZIPFILE} || return $? fi fi if [[ "${EXTRACT_ONLY}" == "1" ]]; then colorEcho ${GREEN} "V2Ray extracted to ${VSRC_ROOT}, and exiting..." return 0 fi if pgrep "v2ray" > /dev/null ; then V2RAY_RUNNING=1 stopV2ray fi installV2Ray || return $? installInitScript || return $? if [[ ${V2RAY_RUNNING} -eq 1 ]];then colorEcho ${BLUE} "Restarting V2Ray service." startV2ray fi colorEcho ${GREEN} "V2Ray ${NEW_VER} is installed." rm -rf /tmp/v2ray return 0 } main
系统重装 原系统为 Linux Linux 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 #!/bin/bash while [[ $# -ge 1 ]]; do case $1 in -v|--ver) shift VERtmp="$1" shift ;; -d|--debian|--ubuntu) shift vDEBtmp="$1" shift ;; -p|--password) shift WDtmp="$1" shift ;; -a|--auto) shift INStmp='auto' ;; -m|--manual) shift INStmp='manual' ;; -apt|--mirror) shift isMirror='1' tmpMirror="$1" shift ;; *) echo -ne " Usage:\n\tbash $0\t-d/--debian [7/\033[33m\033[04mwheezy\033[0m|8/jessie|9/stretch]\n\t\t\t\t-v/--ver [32/\033[33m\033[04mi386\033[0m|64/amd64]\n\t\t\t\t-apt/--mirror\n\t\t\t\t-a/--auto\n\t\t\t\t-m/--manual\n" exit 1; ;; esac done [ $EUID -ne 0 ] && echo "Error:This script must be run as root!" && exit 1 [ -f /boot/grub/grub.cfg ] && GRUBOLD='0' && GRUBDIR='/boot/grub' && GRUBFILE='grub.cfg' [ -z $GRUBDIR ] && [ -f /boot/grub2/grub.cfg ] && GRUBOLD='0' && GRUBDIR='/boot/grub2' && GRUBFILE='grub.cfg' [ -z $GRUBDIR ] && [ -f /boot/grub/grub.conf ] && GRUBOLD='1' && GRUBDIR='/boot/grub' && GRUBFILE='grub.conf' [ -z $GRUBDIR -o -z $GRUBFILE ] && echo "Error! Not Found grub path." && exit 1 [ -n $vDEBtmp ] && { [ "$vDEBtmp" == '7' -o "$vDEBtmp" == 'wheezy' ] && linuxdists='debian' && vDEB='wheezy'; [ "$vDEBtmp" == '8' -o "$vDEBtmp" == 'jessie' ] && linuxdists='debian' && vDEB='jessie'; [ "$vDEBtmp" == '9' -o "$vDEBtmp" == 'stretch' ] && linuxdists='debian' && vDEB='stretch'; [ "$vDEBtmp" == 'precise' ] && linuxdists='ubuntu' && vDEB='precise'; [ "$vDEBtmp" == 'trusty' ] && linuxdists='ubuntu' && vDEB='trusty'; [ "$vDEBtmp" == 'wily' ] && linuxdists='ubuntu' && vDEB='wily'; [ "$vDEBtmp" == 'xenial' ] && linuxdists='ubuntu' && vDEB='xenial'; [ "$vDEBtmp" == 'yakkety' ] && linuxdists='ubuntu' && vDEB='yakkety'; [ "$vDEBtmp" == 'zesty' ] && linuxdists='ubuntu' && vDEB='zesty'; } [ -n $vDEBtmp ] && { [ "$VERtmp" == '32' -o "$VERtmp" == 'i386' ] && VER='i386'; [ "$VERtmp" == '64' -o "$VERtmp" == 'amd64' ] && VER='amd64'; } [ -z $linuxdists ] && linuxdists='debian' [ -n $isMirror ] && [ "$isMirror" == '1' ] && [ -n $tmpMirror ] && { tmpDebianMirror="$(echo -n "$tmpMirror" |grep -Eo '.*\.(\w+)')" echo -n "$tmpDebianMirror" |grep -q '://' [ $? -eq '0' ] && { DebianMirror="$(echo -n "$tmpDebianMirror" |awk -F'://' '{print $2}')" } || { DebianMirror="$(echo -n "$tmpDebianMirror")" } } || { [[ $linuxdists == 'debian' ]] && DebianMirror='httpredir.debian.org' [[ $linuxdists == 'ubuntu' ]] && DebianMirror='archive.ubuntu.com' } [ -z $DebianMirrorDirectory ] && [ -n $DebianMirror ] && [ -n $tmpMirror ] && { DebianMirrorDirectory="$(echo -n "$tmpMirror" |awk -F''${DebianMirror}'' '{print $2}' |sed 's/\/$//g')" } [ "$DebianMirrorDirectory" == '/' ] && [ -n $DebianMirror ] && { [[ $linuxdists == 'debian' ]] && DebianMirrorDirectory='/debian' [[ $linuxdists == 'ubuntu' ]] && DebianMirrorDirectory='/ubuntu' } [ -z $DebianMirrorDirectory ] && [ -n $DebianMirror ] && { [[ $linuxdists == 'debian' ]] && DebianMirrorDirectory='/debian' [[ $linuxdists == 'ubuntu' ]] && DebianMirrorDirectory='/ubuntu' } [ -n $INStmp ] && { [ "$INStmp" == 'auto' ] && inVNC='n' [ "$INStmp" == 'manual' ] && inVNC='y' } [ -n $WDtmp ] && myPASSWORD="$WDtmp" [ -z $vDEB ] && vDEB='wheezy'; [ -z $VER ] && VER='i386'; [ -z $myPASSWORD ] && myPASSWORD='Vicer' clear && echo -e "\n\033[36m# Install\033[0m\n" [ -z $inVNC ] && ASKVNC(){ inVNC='y'; echo -ne "\033[34mCan you login VNC?\033[0m\e[33m[\e[32my\e[33m/n]\e[0m " read inVNCtmp [[ -n "$inVNCtmp" ]] && inVNC=$inVNCtmp [ "$inVNC" == 'y' -o "$inVNC" == 'Y' ] && inVNC='y' [ "$inVNC" == 'n' -o "$inVNC" == 'N' ] && inVNC='n' } [ "$inVNC" == 'y' -o "$inVNC" == 'n' ] || ASKVNC; [[ $linuxdists == 'debian' ]] && LinuxName='Debian' [[ $linuxdists == 'ubuntu' ]] && LinuxName='Ubuntu' [ "$inVNC" == 'y' ] && echo -e "\033[34mManual Mode\033[0m insatll \033[33m$LinuxName\033[0m [\033[33m$vDEB\033[0m] [\033[33m$VER\033[0m] in VNC. " [ "$inVNC" == 'n' ] && echo -e "\033[34mAuto Mode\033[0m insatll \033[33m$LinuxName\033[0m [\033[33m$vDEB\033[0m] [\033[33m$VER\033[0m]. " echo -e "\n[\033[33m$vDEB\033[0m] [\033[33m$VER\033[0m] Downloading..." [ -z $DebianMirror ] && echo -ne "\033[31mError! \033[0mGet debian mirror fail! \n" && exit 1 [ -z $DebianMirrorDirectory ] && echo -ne "\033[31mError! \033[0mGet debian mirror directory fail! \n" && exit 1 wget --no-check-certificate -qO '/boot/initrd.gz' "http://$DebianMirror$DebianMirrorDirectory/dists/$vDEB/main/installer-$VER/current/images/netboot/$linuxdists-installer/$VER/initrd.gz" [ $? -ne '0' ] && echo -ne "\033[31mError! \033[0mDownload 'initrd.gz' failed! \n" && exit 1 wget --no-check-certificate -qO '/boot/linux' "http://$DebianMirror$DebianMirrorDirectory/dists/$vDEB/main/installer-$VER/current/images/netboot/$linuxdists-installer/$VER/linux" [ $? -ne '0' ] && echo -ne "\033[31mError! \033[0mDownload 'linux' failed! \n" && exit 1 DEFAULTNET="$(ip route show |grep -o 'default via [0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.*' |head -n1 |sed 's/proto.*\|onlink.*//g' |awk '{print $NF}')" [ -n "$DEFAULTNET" ] && IPSUB="$(ip addr |grep ''${DEFAULTNET}'' |grep 'global' |grep 'brd' |head -n1 |grep -o '[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}/[0-9]\{1,2\}')" IPv4="$(echo -n "$IPSUB" |cut -d'/' -f1)" NETSUB="$(echo -n "$IPSUB" |grep -o '/[0-9]\{1,2\}')" GATE="$(ip route show |grep -o 'default via [0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}' |head -n1 |grep -o '[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}')" [ -n "$NETSUB" ] && MASK="$(echo -n '128.0.0.0/1,192.0.0.0/2,224.0.0.0/3,240.0.0.0/4,248.0.0.0/5,252.0.0.0/6,254.0.0.0/7,255.0.0.0/8,255.128.0.0/9,255.192.0.0/10,255.224.0.0/11,255.240.0.0/12,255.248.0.0/13,255.252.0.0/14,255.254.0.0/15,255.255.0.0/16,255.255.128.0/17,255.255.192.0/18,255.255.224.0/19,255.255.240.0/20,255.255.248.0/21,255.255.252.0/22,255.255.254.0/23,255.255.255.0/24,255.255.255.128/25,255.255.255.192/26,255.255.255.224/27,255.255.255.240/28,255.255.255.248/29,255.255.255.252/30,255.255.255.254/31,255.255.255.255/32' |grep -o '[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}'${NETSUB}'' |cut -d'/' -f1)" [ -n "$GATE" ] && [ -n "$MASK" ] && [ -n "$IPv4" ] || { echo "Not found `ip command`, It will use `route command`." ipNum() { local IFS='.' read ip1 ip2 ip3 ip4 <<<"$1" echo $((ip1*(1<<24)+ip2*(1<<16)+ip3*(1<<8)+ip4)) } SelectMax(){ ii=0 for IPITEM in `route -n |awk -v OUT=$1 '{print $OUT}' |grep '[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}'` do NumTMP="$(ipNum $IPITEM)" eval "arrayNum[$ii]='$NumTMP,$IPITEM'" ii=$[$ii+1] done echo ${arrayNum[@]} |sed 's/\s/\n/g' |sort -n -k 1 -t ',' |tail -n1 |cut -d',' -f2 } [[ -z $IPv4 ]] && IPv4="$(ifconfig |grep 'Bcast' |head -n1 |grep -o '[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}' |head -n1)" [[ -z $GATE ]] && GATE="$(SelectMax 2)" [[ -z $MASK ]] && MASK="$(SelectMax 3)" [ -n "$GATE" ] && [ -n "$MASK" ] && [ -n "$IPv4" ] || { echo "Error! Not configure network. " exit 1 } } [ -f /etc/network/interfaces ] && { [[ -z "$(sed -n '/iface.*inet static/p' /etc/network/interfaces)" ]] && AutoNet='1' || AutoNet='0' [ -d /etc/network/interfaces.d ] && { ICFGN="$(find /etc/network/interfaces.d -name '*.cfg' |wc -l)" || ICFGN='0' [ "$ICFGN" -ne '0' ] && { for NetCFG in `ls -1 /etc/network/interfaces.d/*.cfg` do [[ -z "$(cat $NetCFG | sed -n '/iface.*inet static/p')" ]] && AutoNet='1' || AutoNet='0' [ "$AutoNet" -eq '0' ] && break done } } } [ -d /etc/sysconfig/network-scripts ] && { ICFGN="$(find /etc/sysconfig/network-scripts -name 'ifcfg-*' |grep -v 'lo'|wc -l)" || ICFGN='0' [ "$ICFGN" -ne '0' ] && { for NetCFG in `ls -1 /etc/sysconfig/network-scripts/ifcfg-* |grep -v 'lo$' |grep -v ':[0-9]\{1,\}'` do [[ -n "$(cat $NetCFG | sed -n '/BOOTPROTO.*[dD][hH][cC][pP]/p')" ]] && AutoNet='1' || { AutoNet='0' && . $NetCFG [ -n $NETMASK ] && MASK="$NETMASK" [ -n $GATEWAY ] && GATE="$GATEWAY" } [ "$AutoNet" -eq '0' ] && break done } } [ ! -f $GRUBDIR/$GRUBFILE ] && echo "Error! Not Found $GRUBFILE. " && exit 1 [ ! -f $GRUBDIR/$GRUBFILE.old ] && [ -f $GRUBDIR/$GRUBFILE.bak ] && mv -f $GRUBDIR/$GRUBFILE.bak $GRUBDIR/$GRUBFILE.old mv -f $GRUBDIR/$GRUBFILE $GRUBDIR/$GRUBFILE.bak [ -f $GRUBDIR/$GRUBFILE.old ] && cat $GRUBDIR/$GRUBFILE.old >$GRUBDIR/$GRUBFILE || cat $GRUBDIR/$GRUBFILE.bak >$GRUBDIR/$GRUBFILE [ "$GRUBOLD" == '0' ] && { CFG0="$(awk '/menuentry /{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)" CFG2="$(awk '/menuentry /{print NR}' $GRUBDIR/$GRUBFILE|head -n 2 |tail -n 1)" CFG1="" for CFGtmp in `awk '/}/{print NR}' $GRUBDIR/$GRUBFILE` do [ $CFGtmp -gt "$CFG0" -a $CFGtmp -lt "$CFG2" ] && CFG1="$CFGtmp"; done [ -z "$CFG1" ] && { echo "Error! read $GRUBFILE. " exit 1 } sed -n "$CFG0,$CFG1"p $GRUBDIR/$GRUBFILE >/tmp/grub.new [ -f /tmp/grub.new ] && [ "$(grep -c '{' /tmp/grub.new)" -eq "$(grep -c '}' /tmp/grub.new)" ] || { echo -ne "\033[31mError! \033[0mNot configure $GRUBFILE. \n" exit 1 } sed -i "/menuentry.*/c\menuentry\ \'Install OS \[$vDEB\ $VER\]\'\ --class debian\ --class\ gnu-linux\ --class\ gnu\ --class\ os\ \{" /tmp/grub.new [ "$(grep -c '{' /tmp/grub.new)" -eq "$(grep -c '}' /tmp/grub.new)" ] || { echo "Error! configure append $GRUBFILE. " exit 1 } sed -i "/echo.*Loading/d" /tmp/grub.new } [ "$GRUBOLD" == '1' ] && { CFG0="$(awk '/title /{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)" CFG1="$(awk '/title /{print NR}' $GRUBDIR/$GRUBFILE|head -n 2 |tail -n 1)" [ -n $CFG0 ] && [ -z $CFG1 -o $CFG1 == $CFG0 ] && sed -n "$CFG0,$"p $GRUBDIR/$GRUBFILE >/tmp/grub.new [ -n $CFG0 ] && [ -z $CFG1 -o $CFG1 != $CFG0 ] && sed -n "$CFG0,$CFG1"p $GRUBDIR/$GRUBFILE >/tmp/grub.new [ ! -f /tmp/grub.new ] && echo "Error! configure append $GRUBFILE. " && exit 1 sed -i "/title.*/c\title\ \'Install OS \[$vDEB\ $VER\]\'" /tmp/grub.new sed -i '/^#/d' /tmp/grub.new } [ -n "$(grep 'initrd.*/' /tmp/grub.new |awk '{print $2}' |tail -n 1 |grep '^/boot/')" ] && Type='InBoot' || Type='NoBoot' LinuxKernel="$(grep 'linux.*/' /tmp/grub.new |awk '{print $1}' |head -n 1)" [ -z $LinuxKernel ] && LinuxKernel="$(grep 'kernel.*/' /tmp/grub.new |awk '{print $1}' |head -n 1)" LinuxIMG="$(grep 'initrd.*/' /tmp/grub.new |awk '{print $1}' |tail -n 1)" [ "$Type" == 'InBoot' ] && { sed -i "/$LinuxKernel.*\//c\\\t$LinuxKernel\\t\/boot\/linux auto=true hostname=$linuxdists domain= -- quiet" /tmp/grub.new sed -i "/$LinuxIMG.*\//c\\\t$LinuxIMG\\t\/boot\/initrd.gz" /tmp/grub.new } [ "$Type" == 'NoBoot' ] && { sed -i "/$LinuxKernel.*\//c\\\t$LinuxKernel\\t\/linux auto=true hostname=$linuxdists domain= -- quiet" /tmp/grub.new sed -i "/$LinuxIMG.*\//c\\\t$LinuxIMG\\t\/initrd.gz" /tmp/grub.new } sed -i '$a\\n' /tmp/grub.new [ "$inVNC" == 'n' ] && { GRUBPATCH='0' [ -f /etc/network/interfaces -o -d /etc/sysconfig/network-scripts ] && { sed -i ''${CFG0}'i\\n' $GRUBDIR/$GRUBFILE sed -i ''${CFG0}'r /tmp/grub.new' $GRUBDIR/$GRUBFILE [ -z $AutoNet ] && echo "Error, Not found interfaces config." && exit 1 [ -f $GRUBDIR/grubenv ] && sed -i 's/saved_entry/#saved_entry/g' $GRUBDIR/grubenv [ -d /boot/tmp ] && rm -rf /boot/tmp mkdir -p /boot/tmp/ cd /boot/tmp/ gzip -d < ../initrd.gz | cpio --extract --verbose --make-directories --no-absolute-filenames >>/dev/null 2>&1 cat >/boot/tmp/preseed.cfg<<EOF d-i debian-installer/locale string en_US d-i console-setup/layoutcode string us d-i keyboard-configuration/xkb-keymap string us d-i netcfg/choose_interface select auto d-i netcfg/disable_autoconfig boolean true d-i netcfg/dhcp_failed note d-i netcfg/dhcp_options select Configure network manually d-i netcfg/get_ipaddress string $IPv4 d-i netcfg/get_netmask string $MASK d-i netcfg/get_gateway string $GATE d-i netcfg/get_nameservers string 8.8.8.8 d-i netcfg/no_default_route boolean true d-i netcfg/confirm_static boolean true d-i mirror/country string manual d-i mirror/http/hostname string $DebianMirror d-i mirror/http/directory string $DebianMirrorDirectory d-i mirror/http/proxy string d-i passwd/root-login boolean ture d-i passwd/make-user boolean false d-i passwd/root-password password $myPASSWORD d-i passwd/root-password-again password $myPASSWORD d-i user-setup/allow-password-weak boolean true d-i user-setup/encrypt-home boolean false d-i clock-setup/utc boolean true d-i time/zone string US/Eastern d-i clock-setup/ntp boolean true d-i partman/early_command string \ debconf-set partman-auto/disk "\$(list-devices disk |head -n1)"; \ debconf-set grub-installer/bootdev string "\$(list-devices disk |head -n1)"; \ umount /media || true; d-i partman/mount_style select uuid d-i partman-auto/init_automatically_partition select Guided - use entire disk d-i partman-auto/method string regular d-i partman-lvm/device_remove_lvm boolean true d-i partman-md/device_remove_md boolean true d-i partman-auto/choose_recipe select atomic d-i partman-partitioning/confirm_write_new_label boolean true d-i partman/choose_partition select finish d-i partman-lvm/confirm boolean true d-i partman-lvm/confirm_nooverwrite boolean true d-i partman/confirm boolean true d-i partman/confirm_nooverwrite boolean true d-i debian-installer/allow_unauthenticated boolean true tasksel tasksel/first multiselect minimal d-i pkgsel/update-policy select none d-i pkgsel/include string openssh-server d-i pkgsel/upgrade select none popularity-contest popularity-contest/participate boolean false d-i grub-installer/only_debian boolean true d-i grub-installer/bootdev string default d-i finish-install/reboot_in_progress note d-i debian-installer/exit/reboot boolean true d-i preseed/late_command string \ sed -i 's/^.*PermitRootLogin.*/PermitRootLogin yes/g' /target/etc/ssh/sshd_config; \ sed -i 's/^.*PasswordAuthentication.*/PasswordAuthentication yes/g' /target/etc/ssh/sshd_config; EOF [ "$AutoNet" -eq '1' ] && { sed -i '/netcfg\/disable_autoconfig/d' /boot/tmp/preseed.cfg sed -i '/netcfg\/dhcp_options/d' /boot/tmp/preseed.cfg sed -i '/netcfg\/get_.*/d' /boot/tmp/preseed.cfg sed -i '/netcfg\/confirm_static/d' /boot/tmp/preseed.cfg } [ "$vDEB" == 'trusty' ] && GRUBPATCH='1' [ "$vDEB" == 'wily' ] && GRUBPATCH='1' [ "$GRUBPATCH" == '1' ] && { sed -i 's/^d-i\ grub-installer\/bootdev\ string\ default//g' /boot/tmp/preseed.cfg } [ "$GRUBPATCH" == '0' ] && { sed -i 's/debconf-set\ grub-installer\/bootdev.*\"\;//g' /boot/tmp/preseed.cfg } [ "$linuxdists" == 'debian' ] && { sed -i '/user-setup\/allow-password-weak/d' /boot/tmp/preseed.cfg sed -i '/user-setup\/encrypt-home/d' /boot/tmp/preseed.cfg sed -i '/pkgsel\/update-policy/d' /boot/tmp/preseed.cfg sed -i 's/umount\ \/media.*\;//g' /boot/tmp/preseed.cfg } rm -rf ../initrd.gz find . | cpio -H newc --create --verbose | gzip -9 > ../initrd.gz rm -rf /boot/tmp } } [ "$inVNC" == 'y' ] && { sed -i '$i\\n' $GRUBDIR/$GRUBFILE sed -i '$r /tmp/grub.new' $GRUBDIR/$GRUBFILE echo -e "\n\033[33m\033[04mIt will reboot! \nPlease look at VNC! \nSelect\033[0m\033[32m Install OS [$vDEB $VER] \033[33m\033[4mto install system.\033[04m\n\n\033[31m\033[04mThere is some information for you.\nDO NOT CLOSE THE WINDOW! \033[0m\n" echo -e "\033[35mIPv4\t\tNETMASK\t\tGATEWAY\033[0m" echo -e "\033[36m\033[04m$IPv4\033[0m\t\033[36m\033[04m$MASK\033[0m\t\033[36m\033[04m$GATE\033[0m\n\n" read -n 1 -p "Press Enter to reboot..." INP if [ "$INP" != '' ] ; then echo -ne '\b \n' echo ""; fi } chown root:root $GRUBDIR/$GRUBFILE chmod 444 $GRUBDIR/$GRUBFILE sleep 3 && reboot >/dev/null 2>&1
Windows 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 #!/bin/bash while [[ $# -ge 1 ]]; do case $1 in -v|--ver) shift VERtmp="$1" shift ;; -d|--debian|--ubuntu) shift vDEBtmp="$1" shift ;; -dd|--ddwin) shift ddMode='1' URLtmp="$1" shift ;; -p|--password) shift WDtmp="$1" shift ;; -a|--auto) shift INStmp='auto' ;; -m|--manual) shift INStmp='manual' ;; -apt|--mirror) shift isMirror='1' tmpMirror="$1" shift ;; -ssl) shift tmpSSL="$1" shift ;; *) echo -ne " Usage:\n\tbash $0\t-d/--debian [7/\033[33m\033[04mwheezy\033[0m|8/jessie|9/stretch]\n\t\t\t\t-v/--ver [32/\033[33m\033[04mi386\033[0m|64/amd64]\n\t\t\t\t-apt/--mirror\n\t\t\t\t-dd/--ddwin\n\t\t\t\t-a/--auto\n\t\t\t\t-m/--manual\n" exit 1; ;; esac done [[ $EUID -ne 0 ]] && echo "Error:This script must be run as root!" && exit 1 [[ -f /boot/grub/grub.cfg ]] && GRUBOLD='0' && GRUBDIR='/boot/grub' && GRUBFILE='grub.cfg' [[ -z $GRUBDIR ]] && [[ -f /boot/grub2/grub.cfg ]] && GRUBOLD='0' && GRUBDIR='/boot/grub2' && GRUBFILE='grub.cfg' [[ -z $GRUBDIR ]] && [[ -f /boot/grub/grub.conf ]] && GRUBOLD='1' && GRUBDIR='/boot/grub' && GRUBFILE='grub.conf' [ -z $GRUBDIR -o -z $GRUBFILE ] && echo "Error! Not Found grub path." && exit 1 [[ -n $vDEBtmp ]] && { [ "$vDEBtmp" == '7' -o "$vDEBtmp" == 'wheezy' ] && linuxdists='debian' && vDEB='wheezy'; [ "$vDEBtmp" == '8' -o "$vDEBtmp" == 'jessie' ] && linuxdists='debian' && vDEB='jessie'; [ "$vDEBtmp" == '9' -o "$vDEBtmp" == 'stretch' ] && linuxdists='debian' && vDEB='stretch'; [[ "$vDEBtmp" == 'precise' ]] && linuxdists='ubuntu' && vDEB='precise'; [[ "$vDEBtmp" == 'trusty' ]] && linuxdists='ubuntu' && vDEB='trusty'; [[ "$vDEBtmp" == 'wily' ]] && linuxdists='ubuntu' && vDEB='wily'; [[ "$vDEBtmp" == 'xenial' ]] && linuxdists='ubuntu' && vDEB='xenial'; [[ "$vDEBtmp" == 'yakkety' ]] && linuxdists='ubuntu' && vDEB='yakkety'; [[ "$vDEBtmp" == 'zesty' ]] && linuxdists='ubuntu' && vDEB='zesty'; } [[ -n $vDEBtmp ]] && { [ "$VERtmp" == '32' -o "$VERtmp" == 'i386' ] && VER='i386'; [ "$VERtmp" == '64' -o "$VERtmp" == 'amd64' ] && VER='amd64'; } [[ -n $ddMode ]] && [[ "$ddMode" == '1' ]] && { [[ -n $URLtmp ]] && { linuxdists='debian'; vDEB='jessie'; VER='amd64'; INStmp='auto' DDURL="$URLtmp" [[ -n $tmpSSL ]] && CURL_SUPPORT="$tmpSSL" [[ -z $CURL_SUPPORT ]] && CURL_SUPPORT='https://moeclub.org/get-curl_udeb_amd64' } || { echo 'Please input vaild URL! ' exit 1 } } || { ddMode='0'; } [[ -z $linuxdists ]] && linuxdists='debian' [[ -n $isMirror ]] && [[ "$isMirror" == '1' ]] && [[ -n $tmpMirror ]] && { tmpDebianMirror="$(echo -n "$tmpMirror" |grep -Eo '.*\.(\w+)')" echo -n "$tmpDebianMirror" |grep -q '://' [[ $? -eq '0' ]] && { DebianMirror="$(echo -n "$tmpDebianMirror" |awk -F'://' '{print $2}')" } || { DebianMirror="$(echo -n "$tmpDebianMirror")" } } || { [[ $linuxdists == 'debian' ]] && DebianMirror='httpredir.debian.org' [[ $linuxdists == 'ubuntu' ]] && DebianMirror='archive.ubuntu.com' } [[ -z $DebianMirrorDirectory ]] && [[ -n $DebianMirror ]] && [[ -n $tmpMirror ]] && { DebianMirrorDirectory="$(echo -n "$tmpMirror" |awk -F''${DebianMirror}'' '{print $2}' |sed 's/\/$//g')" } [[ "$DebianMirrorDirectory" == '/' ]] && [[ -n $DebianMirror ]] && { [[ $linuxdists == 'debian' ]] && DebianMirrorDirectory='/debian' [[ $linuxdists == 'ubuntu' ]] && DebianMirrorDirectory='/ubuntu' } [[ -z $DebianMirrorDirectory ]] && [[ -n $DebianMirror ]] && { [[ $linuxdists == 'debian' ]] && DebianMirrorDirectory='/debian' [[ $linuxdists == 'ubuntu' ]] && DebianMirrorDirectory='/ubuntu' } [[ -n $INStmp ]] && { [[ "$INStmp" == 'auto' ]] && inVNC='n' [[ "$INStmp" == 'manual' ]] && inVNC='y' } [[ -n $WDtmp ]] && myPASSWORD="$WDtmp" [[ -z $vDEB ]] && vDEB='wheezy'; [[ -z $VER ]] && VER='i386'; [[ -z $myPASSWORD ]] && myPASSWORD='Vicer' clear && echo -e "\n\033[36m# Install\033[0m\n" [[ -z $inVNC ]] && ASKVNC(){ inVNC='y'; [[ "$ddMode" == '0' ]] && { echo -ne "\033[34mCan you login VNC?\033[0m\e[33m[\e[32my\e[33m/n]\e[0m " read inVNCtmp [[ -n "$inVNCtmp" ]] && inVNC=$inVNCtmp } [ "$inVNC" == 'y' -o "$inVNC" == 'Y' ] && inVNC='y' [ "$inVNC" == 'n' -o "$inVNC" == 'N' ] && inVNC='n' } [ "$inVNC" == 'y' -o "$inVNC" == 'n' ] || ASKVNC; [[ $linuxdists == 'debian' ]] && LinuxName='Debian' [[ $linuxdists == 'ubuntu' ]] && LinuxName='Ubuntu' [[ "$ddMode" == '0' ]] && { [[ "$inVNC" == 'y' ]] && echo -e "\033[34mManual Mode\033[0m insatll \033[33m$LinuxName\033[0m [\033[33m$vDEB\033[0m] [\033[33m$VER\033[0m] in VNC. " [[ "$inVNC" == 'n' ]] && echo -e "\033[34mAuto Mode\033[0m insatll \033[33m$LinuxName\033[0m [\033[33m$vDEB\033[0m] [\033[33m$VER\033[0m]. " } [[ "$ddMode" == '1' ]] && { echo -ne "\033[34mAuto Mode\033[0m insatll \033[33mWindows\033[0m\n[\033[33m$DDURL\033[0m]\n" } echo -e "\n[\033[33m$vDEB\033[0m] [\033[33m$VER\033[0m] Downloading..." [[ -z $DebianMirror ]] && echo -ne "\033[31mError! \033[0mGet debian mirror fail! \n" && exit 1 [[ -z $DebianMirrorDirectory ]] && echo -ne "\033[31mError! \033[0mGet debian mirror directory fail! \n" && exit 1 wget --no-check-certificate -qO '/boot/initrd.gz' "http://$DebianMirror$DebianMirrorDirectory/dists/$vDEB/main/installer-$VER/current/images/netboot/$linuxdists-installer/$VER/initrd.gz" [[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'initrd.gz' failed! \n" && exit 1 wget --no-check-certificate -qO '/boot/linux' "http://$DebianMirror$DebianMirrorDirectory/dists/$vDEB/main/installer-$VER/current/images/netboot/$linuxdists-installer/$VER/linux" [[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'linux' failed! \n" && exit 1 DEFAULTNET="$(ip route show |grep -o 'default via [0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.*' |head -n1 |sed 's/proto.*\|onlink.*//g' |awk '{print $NF}')" [[ -n "$DEFAULTNET" ]] && IPSUB="$(ip addr |grep ''${DEFAULTNET}'' |grep 'global' |grep 'brd' |head -n1 |grep -o '[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}/[0-9]\{1,2\}')" IPv4="$(echo -n "$IPSUB" |cut -d'/' -f1)" NETSUB="$(echo -n "$IPSUB" |grep -o '/[0-9]\{1,2\}')" GATE="$(ip route show |grep -o 'default via [0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}' |head -n1 |grep -o '[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}')" [[ -n "$NETSUB" ]] && MASK="$(echo -n '128.0.0.0/1,192.0.0.0/2,224.0.0.0/3,240.0.0.0/4,248.0.0.0/5,252.0.0.0/6,254.0.0.0/7,255.0.0.0/8,255.128.0.0/9,255.192.0.0/10,255.224.0.0/11,255.240.0.0/12,255.248.0.0/13,255.252.0.0/14,255.254.0.0/15,255.255.0.0/16,255.255.128.0/17,255.255.192.0/18,255.255.224.0/19,255.255.240.0/20,255.255.248.0/21,255.255.252.0/22,255.255.254.0/23,255.255.255.0/24,255.255.255.128/25,255.255.255.192/26,255.255.255.224/27,255.255.255.240/28,255.255.255.248/29,255.255.255.252/30,255.255.255.254/31,255.255.255.255/32' |grep -o '[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}'${NETSUB}'' |cut -d'/' -f1)" [[ -n "$GATE" ]] && [[ -n "$MASK" ]] && [[ -n "$IPv4" ]] || { echo "Not found `ip command`, It will use `route command`." ipNum() { local IFS='.' read ip1 ip2 ip3 ip4 <<<"$1" echo $((ip1*(1<<24)+ip2*(1<<16)+ip3*(1<<8)+ip4)) } SelectMax(){ ii=0 for IPITEM in `route -n |awk -v OUT=$1 '{print $OUT}' |grep '[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}'` do NumTMP="$(ipNum $IPITEM)" eval "arrayNum[$ii]='$NumTMP,$IPITEM'" ii=$[$ii+1] done echo ${arrayNum[@]} |sed 's/\s/\n/g' |sort -n -k 1 -t ',' |tail -n1 |cut -d',' -f2 } [[ -z $IPv4 ]] && IPv4="$(ifconfig |grep 'Bcast' |head -n1 |grep -o '[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}' |head -n1)" [[ -z $GATE ]] && GATE="$(SelectMax 2)" [[ -z $MASK ]] && MASK="$(SelectMax 3)" [[ -n "$GATE" ]] && [[ -n "$MASK" ]] && [[ -n "$IPv4" ]] || { echo "Error! Not configure network. " exit 1 } } [[ -f /etc/network/interfaces ]] && { [[ -z "$(sed -n '/iface.*inet static/p' /etc/network/interfaces)" ]] && AutoNet='1' || AutoNet='0' [[ -d /etc/network/interfaces.d ]] && { ICFGN="$(find /etc/network/interfaces.d -name '*.cfg' |wc -l)" || ICFGN='0' [[ "$ICFGN" -ne '0' ]] && { for NetCFG in `ls -1 /etc/network/interfaces.d/*.cfg` do [[ -z "$(cat $NetCFG | sed -n '/iface.*inet static/p')" ]] && AutoNet='1' || AutoNet='0' [[ "$AutoNet" -eq '0' ]] && break done } } } [[ -d /etc/sysconfig/network-scripts ]] && { ICFGN="$(find /etc/sysconfig/network-scripts -name 'ifcfg-*' |grep -v 'lo'|wc -l)" || ICFGN='0' [[ "$ICFGN" -ne '0' ]] && { for NetCFG in `ls -1 /etc/sysconfig/network-scripts/ifcfg-* |grep -v 'lo$' |grep -v ':[0-9]\{1,\}'` do [[ -n "$(cat $NetCFG | sed -n '/BOOTPROTO.*[dD][hH][cC][pP]/p')" ]] && AutoNet='1' || { AutoNet='0' && . $NetCFG [[ -n $NETMASK ]] && MASK="$NETMASK" [[ -n $GATEWAY ]] && GATE="$GATEWAY" } [[ "$AutoNet" -eq '0' ]] && break done } } [[ ! -f $GRUBDIR/$GRUBFILE ]] && echo "Error! Not Found $GRUBFILE. " && exit 1 [[ ! -f $GRUBDIR/$GRUBFILE.old ]] && [[ -f $GRUBDIR/$GRUBFILE.bak ]] && mv -f $GRUBDIR/$GRUBFILE.bak $GRUBDIR/$GRUBFILE.old mv -f $GRUBDIR/$GRUBFILE $GRUBDIR/$GRUBFILE.bak [[ -f $GRUBDIR/$GRUBFILE.old ]] && cat $GRUBDIR/$GRUBFILE.old >$GRUBDIR/$GRUBFILE || cat $GRUBDIR/$GRUBFILE.bak >$GRUBDIR/$GRUBFILE [[ "$GRUBOLD" == '0' ]] && { CFG0="$(awk '/menuentry /{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)" CFG2="$(awk '/menuentry /{print NR}' $GRUBDIR/$GRUBFILE|head -n 2 |tail -n 1)" CFG1="" for CFGtmp in `awk '/}/{print NR}' $GRUBDIR/$GRUBFILE` do [ $CFGtmp -gt "$CFG0" -a $CFGtmp -lt "$CFG2" ] && CFG1="$CFGtmp"; done [[ -z "$CFG1" ]] && { echo "Error! read $GRUBFILE. " exit 1 } sed -n "$CFG0,$CFG1"p $GRUBDIR/$GRUBFILE >/tmp/grub.new [[ -f /tmp/grub.new ]] && [[ "$(grep -c '{' /tmp/grub.new)" -eq "$(grep -c '}' /tmp/grub.new)" ]] || { echo -ne "\033[31mError! \033[0mNot configure $GRUBFILE. \n" exit 1 } sed -i "/menuentry.*/c\menuentry\ \'Install OS \[$vDEB\ $VER\]\'\ --class debian\ --class\ gnu-linux\ --class\ gnu\ --class\ os\ \{" /tmp/grub.new [[ "$(grep -c '{' /tmp/grub.new)" -eq "$(grep -c '}' /tmp/grub.new)" ]] || { echo "Error! configure append $GRUBFILE. " exit 1 } sed -i "/echo.*Loading/d" /tmp/grub.new } [[ "$GRUBOLD" == '1' ]] && { CFG0="$(awk '/title /{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)" CFG1="$(awk '/title /{print NR}' $GRUBDIR/$GRUBFILE|head -n 2 |tail -n 1)" [[ -n $CFG0 ]] && [ -z $CFG1 -o $CFG1 == $CFG0 ] && sed -n "$CFG0,$"p $GRUBDIR/$GRUBFILE >/tmp/grub.new [[ -n $CFG0 ]] && [ -z $CFG1 -o $CFG1 != $CFG0 ] && sed -n "$CFG0,$CFG1"p $GRUBDIR/$GRUBFILE >/tmp/grub.new [[ ! -f /tmp/grub.new ]] && echo "Error! configure append $GRUBFILE. " && exit 1 sed -i "/title.*/c\title\ \'Install OS \[$vDEB\ $VER\]\'" /tmp/grub.new sed -i '/^#/d' /tmp/grub.new } [[ -n "$(grep 'initrd.*/' /tmp/grub.new |awk '{print $2}' |tail -n 1 |grep '^/boot/')" ]] && Type='InBoot' || Type='NoBoot' LinuxKernel="$(grep 'linux.*/' /tmp/grub.new |awk '{print $1}' |head -n 1)" [[ -z $LinuxKernel ]] && LinuxKernel="$(grep 'kernel.*/' /tmp/grub.new |awk '{print $1}' |head -n 1)" LinuxIMG="$(grep 'initrd.*/' /tmp/grub.new |awk '{print $1}' |tail -n 1)" [[ "$Type" == 'InBoot' ]] && { sed -i "/$LinuxKernel.*\//c\\\t$LinuxKernel\\t\/boot\/linux auto=true hostname=$linuxdists domain= -- quiet" /tmp/grub.new sed -i "/$LinuxIMG.*\//c\\\t$LinuxIMG\\t\/boot\/initrd.gz" /tmp/grub.new } [[ "$Type" == 'NoBoot' ]] && { sed -i "/$LinuxKernel.*\//c\\\t$LinuxKernel\\t\/linux auto=true hostname=$linuxdists domain= -- quiet" /tmp/grub.new sed -i "/$LinuxIMG.*\//c\\\t$LinuxIMG\\t\/initrd.gz" /tmp/grub.new } sed -i '$a\\n' /tmp/grub.new [[ "$inVNC" == 'n' ]] && { GRUBPATCH='0' [ -f /etc/network/interfaces -o -d /etc/sysconfig/network-scripts ] && { sed -i ''${CFG0}'i\\n' $GRUBDIR/$GRUBFILE sed -i ''${CFG0}'r /tmp/grub.new' $GRUBDIR/$GRUBFILE [[ -z $AutoNet ]] && echo "Error, Not found interfaces config." && exit 1 [[ -f $GRUBDIR/grubenv ]] && sed -i 's/saved_entry/#saved_entry/g' $GRUBDIR/grubenv [[ -d /boot/tmp ]] && rm -rf /boot/tmp mkdir -p /boot/tmp/ cd /boot/tmp/ gzip -d < ../initrd.gz | cpio --extract --verbose --make-directories --no-absolute-filenames >>/dev/null 2>&1 cat >/boot/tmp/preseed.cfg<<EOF d-i debian-installer/locale string en_US d-i console-setup/layoutcode string us d-i keyboard-configuration/xkb-keymap string us d-i netcfg/choose_interface select auto d-i netcfg/disable_autoconfig boolean true d-i netcfg/dhcp_failed note d-i netcfg/dhcp_options select Configure network manually d-i netcfg/get_ipaddress string $IPv4 d-i netcfg/get_netmask string $MASK d-i netcfg/get_gateway string $GATE d-i netcfg/get_nameservers string 8.8.8.8 d-i netcfg/no_default_route boolean true d-i netcfg/confirm_static boolean true d-i hw-detect/load_firmware boolean false d-i mirror/country string manual d-i mirror/http/hostname string $DebianMirror d-i mirror/http/directory string $DebianMirrorDirectory d-i mirror/http/proxy string d-i passwd/root-login boolean ture d-i passwd/make-user boolean false d-i passwd/root-password password $myPASSWORD d-i passwd/root-password-again password $myPASSWORD d-i user-setup/allow-password-weak boolean true d-i user-setup/encrypt-home boolean false d-i clock-setup/utc boolean true d-i time/zone string US/Eastern d-i clock-setup/ntp boolean true d-i preseed/early_command string anna-install libfuse2-udeb fuse-udeb ntfs-3g-udeb fuse-modules-3.16.0-4-amd64-di d-i partman/early_command string \ debconf-set partman-auto/disk "\$(list-devices disk |head -n1)"; \ wget -qO- '$DDURL' |gunzip -dc |/bin/dd of=\$(list-devices disk |head -n1); \ mount.ntfs-3g \$(list-devices partition |head -n1) /mnt; \ cp -f '/net.bat' '/mnt/ProgramData/Microsoft/Windows/Start Menu/Programs/Startup/net.bat'; \ /sbin/reboot; \ debconf-set grub-installer/bootdev string "\$(list-devices disk |head -n1)"; \ umount /media || true; \ d-i partman/mount_style select uuid d-i partman-auto/init_automatically_partition select Guided - use entire disk d-i partman-auto/method string regular d-i partman-lvm/device_remove_lvm boolean true d-i partman-md/device_remove_md boolean true d-i partman-auto/choose_recipe select atomic d-i partman-partitioning/confirm_write_new_label boolean true d-i partman/choose_partition select finish d-i partman-lvm/confirm boolean true d-i partman-lvm/confirm_nooverwrite boolean true d-i partman/confirm boolean true d-i partman/confirm_nooverwrite boolean true d-i debian-installer/allow_unauthenticated boolean true tasksel tasksel/first multiselect minimal d-i pkgsel/update-policy select none d-i pkgsel/include string openssh-server d-i pkgsel/upgrade select none popularity-contest popularity-contest/participate boolean false d-i grub-installer/only_debian boolean true d-i grub-installer/bootdev string default d-i finish-install/reboot_in_progress note d-i debian-installer/exit/reboot boolean true d-i preseed/late_command string \ sed -i 's/^.*PermitRootLogin.*/PermitRootLogin yes/g' /target/etc/ssh/sshd_config; \ sed -i 's/^.*PasswordAuthentication.*/PasswordAuthentication yes/g' /target/etc/ssh/sshd_config; EOF [[ "$AutoNet" -eq '1' ]] && { sed -i '/netcfg\/disable_autoconfig/d' /boot/tmp/preseed.cfg sed -i '/netcfg\/dhcp_options/d' /boot/tmp/preseed.cfg sed -i '/netcfg\/get_.*/d' /boot/tmp/preseed.cfg sed -i '/netcfg\/confirm_static/d' /boot/tmp/preseed.cfg } [[ "$vDEB" == 'trusty' ]] && GRUBPATCH='1' [[ "$vDEB" == 'wily' ]] && GRUBPATCH='1' [[ "$GRUBPATCH" == '1' ]] && { sed -i 's/^d-i\ grub-installer\/bootdev\ string\ default//g' /boot/tmp/preseed.cfg } [[ "$GRUBPATCH" == '0' ]] && { sed -i 's/debconf-set\ grub-installer\/bootdev.*\"\;//g' /boot/tmp/preseed.cfg } [[ "$vDEB" == 'xenial' ]] && { sed -i 's/^d-i\ clock-setup\/ntp\ boolean\ true/d-i\ clock-setup\/ntp\ boolean\ false/g' /boot/tmp/preseed.cfg } [[ "$linuxdists" == 'debian' ]] && { sed -i '/user-setup\/allow-password-weak/d' /boot/tmp/preseed.cfg sed -i '/user-setup\/encrypt-home/d' /boot/tmp/preseed.cfg sed -i '/pkgsel\/update-policy/d' /boot/tmp/preseed.cfg sed -i 's/umount\ \/media.*true\;\ //g' /boot/tmp/preseed.cfg } [[ "$ddMode" == '1' ]] && { [[ "$AutoNet" -eq '1' ]] && echo -ne "@ECHO OFF\r\ncd\040\057d\040\042\045ProgramData\045\057Microsoft\057Windows\057Start\040Menu\057Programs\057Startup\042\r\ndel\040\057f\040\057q\040net\056bat\r\n\r\n" >'/boot/tmp/net.tmp'; [[ "$AutoNet" -eq '0' ]] && echo -ne "@ECHO OFF\r\ncd\056\076\045windir\045\GetAdmin\r\nif\040exist\040\045windir\045\GetAdmin\040\050del\040\057f\040\057q\040\042\045windir\045\GetAdmin\042\051\040else\040\050\r\necho\040CreateObject^\050\042Shell\056Application\042^\051\056ShellExecute\040\042\045~s0\042\054\040\042\045\052\042\054\040\042\042\054\040\042runas\042\054\040\061\040\076\076\040\042\045temp\045\Admin\056vbs\042\r\n\042\045temp\045\Admin\056vbs\042\r\ndel\040\057f\040\057q\040\042\045temp\045\Admin\056vbs\042\r\nexit\040\057b\040\062\051\r\nfor\040\057f\040\042tokens=\063\052\042\040\045\045i\040in\040\050\047netsh\040interface\040show\040interface\040^|more\040+3\040^|findstr\040\057R\040\042本地\056\052\040以太\056\052\040Local\056\052\040Ethernet\042\047\051\040do\040\050set\040EthName=\045\045j\051\r\nnetsh\040-c\040interface\040ip\040set\040address\040name=\042\045EthName\045\042\040source=static\040address=$IPv4\040mask=$MASK\040gateway=$GATE\r\nnetsh\040-c\040interface\040ip\040add\040dnsservers\040name=\042\045EthName\045\042 address=\070\056\070\056\070\056\070\040index=1\040validate=no\r\nnetsh\040-c\040interface\040ip\040add\040dnsservers\040name=\042\045EthName\045\042\040address=\070\056\070\056\064\056\064\040index=2\040validate=no\r\ncd\040\057d\040\042\045ProgramData\045\057Microsoft\057Windows\057Start\040Menu\057Programs\057Startup\042\r\ndel\040\057f\040\057q\040net\056bat\r\n\r\n" >'/boot/tmp/net.tmp'; iconv -f 'UTF-8' -t 'GBK' '/boot/tmp/net.tmp' -o '/boot/tmp/net.bat' rm -rf '/boot/tmp/net.tmp' echo "$DDURL" |grep -q '^https://' [[ $? -eq '0' ]] && { echo -ne '\nAdd curl support...\n' [[ -n $CURL_SUPPORT ]] && { wget --no-check-certificate -qO- "$CURL_SUPPORT" |tar -x [[ ! -f /boot/tmp/usr/bin/curl ]] && echo 'Error! CURL_SUPPORT.' && exit 1; sed -i 's/wget\ -qO-/\/usr\/bin\/curl -ksSL/g' /boot/tmp/preseed.cfg [[ $? -eq '0' ]] && echo 'Success! \n\n' } || { echo -ne 'Not curl support package! \n\n' exit 1 } } } [[ "$ddMode" == '0' ]] && { sed -i '/anna-install/d' /boot/tmp/preseed.cfg sed -i 's/wget.*\/sbin\/reboot\;\ //g' /boot/tmp/preseed.cfg } rm -rf ../initrd.gz find . | cpio -H newc --create --verbose | gzip -9 > ../initrd.gz rm -rf /boot/tmp } } [[ "$inVNC" == 'y' ]] && { sed -i '$i\\n' $GRUBDIR/$GRUBFILE sed -i '$r /tmp/grub.new' $GRUBDIR/$GRUBFILE echo -e "\n\033[33m\033[04mIt will reboot! \nPlease look at VNC! \nSelect\033[0m\033[32m Install OS [$vDEB $VER] \033[33m\033[4mto install system.\033[04m\n\n\033[31m\033[04mThere is some information for you.\nDO NOT CLOSE THE WINDOW! \033[0m\n" echo -e "\033[35mIPv4\t\tNETMASK\t\tGATEWAY\033[0m" echo -e "\033[36m\033[04m$IPv4\033[0m\t\033[36m\033[04m$MASK\033[0m\t\033[36m\033[04m$GATE\033[0m\n\n" read -n 1 -p "Press Enter to reboot..." INP if [[ "$INP" != '' ]] ; then echo -ne '\b \n' echo ""; fi } chown root:root $GRUBDIR/$GRUBFILE chmod 444 $GRUBDIR/$GRUBFILE sleep 3 && reboot >/dev/null 2>&1
原系统为 Windows Linux 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 @ECHO OFF&PUSHD %~DP0 &TITLE Win32Loader setlocal enabledelayedexpansion ::Author MoeClub.org color 87 cd.>%windir%\GetAdmin if exist %windir%\GetAdmin (del /f /q "%windir%\GetAdmin") else ( echo CreateObject^("Shell.Application"^).ShellExecute "%~s0", "%*", "", "runas", 1 >> "%temp%\Admin.vbs" "%temp%\Admin.vbs" del /s /q "%temp%\Admin.vbs" exit /b 2) cls echo * Init Win32Loader. set URL=https://moeclub.org/attachment/WindowsSoftware set download=0 set try_download=1 :Init mkdir "%SystemDrive%\win32-loader" >NUL 2>NUL if exist "%SystemDrive%\Windows\System32\WindowsPowerShell" ( set use_ps=1 ) else ( set use_ps=0 ) if %use_ps% equ 1 ( goto InitIt ) else ( goto InitFail ) :InitIt set try_download=0 powershell.exe -command "& {$client = new-object System.Net.WebClient; $client.DownloadFile('!URL!/g2ldr/g2ldr','%SystemDrive%\g2ldr')}" >NUL 2>NUL powershell.exe -command "& {$client = new-object System.Net.WebClient; $client.DownloadFile('!URL!/g2ldr/g2ldr.mbr','%SystemDrive%\g2ldr.mbr')}" >NUL 2>NUL powershell.exe -command "& {$client = new-object System.Net.WebClient; $client.DownloadFile('!URL!/g2ldr/grub.cfg','%SystemDrive%\win32-loader\grub.cfg')}" >NUL 2>NUL goto InitDone :InitFail echo Not found powershell, please download them by yourself. echo '%SystemDrive%\g2ldr' echo '%SystemDrive%\g2ldr.mbr' echo '%SystemDrive%\win32-loader\grub.cfg' echo Press [ENTER] when you finished. pause >NUL 2>NUL goto InitDone :InitDone if !try_download! equ 0 ( set InitOption=InitFail ) else ( set InitOption=Init ) if not exist "%SystemDrive%\g2ldr" goto !InitOption! if not exist "%SystemDrive%\g2ldr.mbr" goto !InitOption! if not exist "%SystemDrive%\win32-loader\grub.cfg" goto !InitOption! :Image echo. echo * Please select initrd mode. echo [1] Online download echo [2] Local file choice /n /c 12 /m Select: if errorlevel 2 goto LocalMode if errorlevel 1 goto OnlineMode goto Image :OnlineMode echo. echo * Please select source. echo [1] by MoeClub (DHCP or VNC Support) echo [2] by yourself choice /n /c 12 /m Select: if errorlevel 2 goto Yourself if errorlevel 1 goto MoeClub goto OnlineMode :Yourself echo. echo if 'initrd.img' URL is 'https://moeclub.org/onedrive/IMAGE/Loader/DebianJessie/initrd.img', Please input 'https://moeclub.org/onedrive/IMAGE/Loader/DebianJessie'. set /p IMG_URL=URL : if defined IMG_URL ( goto Download ) else ( goto MoeClub ) :MoeClub set IMG_URL=https://moeclub.org/onedrive/IMAGE/Loader/DebianJessie goto Download :Download if %use_ps% equ 1 ( echo. echo Downloading 'initrd.img'... powershell.exe -command "& {$client = new-object System.Net.WebClient; $client.DownloadFile('!IMG_URL!/initrd.img','%SystemDrive%\win32-loader\initrd.img')}" >NUL 2>NUL echo Downloading 'vmlinuz'... powershell.exe -command "& {$client = new-object System.Net.WebClient; $client.DownloadFile('!IMG_URL!/vmlinuz','%SystemDrive%\win32-loader\vmlinuz')}" >NUL 2>NUL set download=1 ) else ( echo Not support online download, auto change Local initrd. goto LocalMode ) :LocalMode if !download! equ 0 ( echo. echo Please put 'initrd.img' and 'vmlinuz' to '%SystemDrive%\win32-loader' . echo Press [ENTER] when you finished. pause >NUL 2>NUL ) :Done0 set download=0 if exist "%SystemDrive%\win32-loader\initrd.img" ( goto Done1 ) else ( echo Not found '%SystemDrive%\win32-loader\initrd.img' . goto LocalMode ) :Done1 set download=0 if exist "%SystemDrive%\win32-loader\vmlinuz" ( goto Done ) else ( echo Not found '%SystemDrive%\win32-loader\vmlinuz' . goto LocalMode ) :Done echo. echo Press [ENTER] to reboot... pause >NUL 2>NUL if not exist "%SystemDrive%\g2ldr" echo Not found '%SystemDrive%\g2ldr' . && exit 1 if not exist "%SystemDrive%\g2ldr.mbr" echo Not found '%SystemDrive%\g2ldr.mbr' . && exit 1 if not exist "%SystemDrive%\win32-loader\grub.cfg" echo Not found '%SystemDrive%\win32-loader\grub.cfg' . && exit 1 if not exist "%SystemDrive%\win32-loader\initrd.img" echo Not found '%SystemDrive%\win32-loader\initrd.img' . && exit 1 if not exist "%SystemDrive%\win32-loader\vmlinuz" echo Not found '%SystemDrive%\win32-loader\vmlinuz' . && exit 1 set id={01234567-89ab-cdef-0123-456789abcdef} bcdedit /create %id% /d "Debian GUN/Linux" /application bootsector >NUL 2>NUL bcdedit /set %id% device partition=%SystemDrive% >NUL 2>NUL bcdedit /set %id% path \g2ldr.mbr >NUL 2>NUL bcdedit /displayorder %id% /addlast >NUL 2>NUL bcdedit /bootsequence %id% /addfirst >NUL 2>NUL shutdown -r -t 0
HTTP/2 检测 在支持 loadTimes 的 chrome 浏览器下执行。
1 2 3 4 5 6 7 8 9 10 11 12 (function(){ if(window.chrome && typeof chrome.loadTimes === 'function') { var loadTimes = window.chrome.loadTimes(); var spdy = loadTimes.wasFetchedViaSpdy; var info = loadTimes.npnNegotiatedProtocol || loadTimes.connectionInfo; // 就以 「h2」作为判断标识 if(spdy && /^h2/i.test(info)) { return console.info('本站点使用了HTTP/2'); } } console.warn('本站点没有使用HTTP/2'); })();
生成 UUID 可在终端输入以下命令。
1 cat /proc/sys/kernel/random/uuid
也可通过以下网站。
1 https://www.uuidgenerator.net/
生成指定前缀信用卡卡号 运行以下命令即可。
1 2 wget https://raw.githubusercontent.com/malaohu/ruyo-shell/master/credit_card_number.py python credit_card_number.py
运行示例如下。
1 2 3 4 5 6 # 生成前缀为'123456',1个,卡号长度16位 fakecard = credit_card_number('123456') # 生成前缀为'123456',1个,卡号长度16位 fakecard = credit_card_number('123456',1,16) # 生成前缀为'123'或'234'的信用卡卡号,共15个,卡号长度16位 fakecard = credit_card_number(['123','234'], 15,16)
脚本如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 from random import Random import copy def completed_number(prefix, length): """ 'prefix' is the start of the CC number as a string, any number of digits. 'length' is the length of the CC number to generate. Typically 13 or 16 """ generator = Random() generator.seed() # Seed from current time ccnumber = prefix # generate digits while len(ccnumber) < (length - 1): digit = str(generator.choice(range(0, 10))) ccnumber.append(digit) # Calculate sum sum = 0 pos = 0 reversedCCnumber = [] reversedCCnumber.extend(ccnumber) reversedCCnumber.reverse() while pos < length - 1: odd = int(reversedCCnumber[pos]) * 2 if odd > 9: odd -= 9 sum += odd if pos != (length - 2): sum += int(reversedCCnumber[pos + 1]) pos += 2 # Calculate check digit checkdigit = ((sum // 10 + 1) * 10 - sum) % 10 ccnumber.append(str(checkdigit)) return ''.join(ccnumber) def credit_card_number(prefixList, howMany=1, length=16): generator = Random() generator.seed() # Seed from current time if type(prefixList)==str: prefixList=[[i for i in prefixList]] if type(prefixList[0])==str: prefixList=[[i for i in List] for List in prefixList] result = [] while len(result) < howMany: ccnumber = copy.copy(generator.choice(prefixList)) result.append(completed_number(ccnumber, length)) return result
DNS DNS 列表 普通 DNS 如下。
带安全功能的 DNS 如下。
供应商
主 DNS
备用 DNS
Norton ConnectSafe
198.153.192.40
198.153.194.40
198.153.192.50
198.153.194.50
198.153.192.60
198.153.194.60
Comodo Secure DNS
8.26.56.26
8.20.247.20
Securly
184.169.143.224
184.169.161.155
ScrubIT
67.138.54.100
207.225.209.66
DNS 供应商 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 # 阿里云公共DNS https://www.alidns.com/setup/ # Public DNS https://www.publicdns.xyz/public/puntcat.html # Yandex.DNS https://dns.yandex.com/ # Freenom World http://www.freenom.world/zh/index.html # 1.1.1.1 https://1.1.1.1/ # Quad9 https://quad9.net/ # OpenNIC https://www.opennic.org/ # 京东智联云 https://www.jdcloud.com/cn/products/jd-cloud-dns # 华为云 https://www.huaweicloud.com/product/dns.html # DNS.COM https://www.dns.com/ # dnsever https://www.dnsever.com/ # Zoneedit https://www.zoneedit.com/ # DNS EXIT,免费动态DNS,托管DNS服务 https://www.dnsexit.com/ # GeoScaling DNS2,每月最多100万个DNS请求 https://www.geoscaling.com/ # DNS.LA https://www.dns.la/ # 八戒DNS https://www.bajiedns.com/ # DNS盾 https://www.dnsdun.com/ # xip.io http://xip.io/ # dynv6 https://dynv6.com/ # SPDYN https://www.spdyn.de/ # FreeDNS https://freedns.afraid.org/ # DYNDNSS https://dyndnss.net/eng/ # ClouDNS https://asia.cloudns.net/ # DNSPOD https://www.dnspod.cn/ https://www.dnspod.com/ # 优惠券 https://www.dnspod.cn/promo/coupon https://cloud.tencent.com/act/pro/DNSPodDomainsCarnival?fromSource=gwzcw.1293314.1293314.1293314&cps_key=98e3b13dc4a1659435daf62289161ee5 # Duck DNS https://www.duckdns.org/ # FreeDNS https://freedns.afraid.org/ # LuaDNS https://www.luadns.com/ # Hurricane Electric Free DNS Management https://dns.he.net/ # Dynu https://www.dynu.com/ # no.ip https://www.noip.com/ # ZoneWatcher https://zonewatcher.com/ # Zoneedit https://www.zoneedit.com/free-dns/ # Lilore https://zilore.com/en/dns # GratisDNS https://web.gratisdns.dk/domaener/dns/ # Selectel https://old.selectel.ru/en/services/additional/dns/ # PointDNS https://pointhq.com/developer # NS1 https://ns1.com/ # DomainTools https://www.domaintools.com/
DNS 服务程序 1 2 3 4 5 6 7 8 9 10 11 # Overture https://github.com/shawn1m/overture # glider https://github.com/nadoo/glider # dnsmasq-china-list https://github.com/felixonmars/dnsmasq-china-list # ChinaDNS https://github.com/aa65535/ChinaDNS
Hosts 源 1 2 3 4 5 # GoogleHosts https://github.com/googlehosts/hosts # ipv6-hosts https://github.com/lennylxx/ipv6-hosts
管理工具 1 2 3 4 5 6 7 8 # SwitchHosts! https://oldj.github.io/SwitchHosts/ # Gas Mask https://www.macupdate.com/app/mac/29949/gas-mask/ # Hozz https://blog.zhangruipeng.me/Hozz/
GeoIP 1 2 3 4 5 6 7 8 9 10 # Free IP Geolocation API https://freegeoip.app/ # GeoDataSource https://www.geodatasource.com/ # Maxmind https://dev.maxmind.com/geoip/geoip2/geolite2/ https://geolite.clash.dev/ https://github.com/Dreamacro/maxmind-geoip
参考教程 trojan-gfw/trojan 1 https://github.com/trojan-gfw/trojan
Shadowsocks 官网 1 https://shadowsocks.org/en/index.html
V2Ray 官网 1 2 3 4 5 https://www.v2ray.com/ https://github.com/v2fly/v2ray-core https://www.v2fly.org/ https://guide.v2fly.org/ https://toutyrater.github.io/
Proxifier 使用教程 1 https://blog.csdn.net/u013066730/article/details/88788191
V2Ray+TLS+DNSSEC+WS+Nginx+BBRPlus 搭建教程【2020 年最新】 1 https://yuchuanfeng.github.io/posts/v2ray+tls+ws+nginx/
德国 Euserv 免费 VPS 申请 + 开通 V2RAY + 安装宝塔图文教程 1 2 3 https://www.shopee6.com/web/web-tutorial/euserv-order-v2ray-bt.html https://lala.im/6781.html https://1rmb.net/t/31.html
使用宝塔快速安装 WordPress 教程 1 https://www.wpmee.com/5976.html
Okteto 上部署 v2ray 1 https://704sjf.coding-pages.com/post/hello-gridea/
自制一个真正属于自己的 v2ray 订阅地址(自己动手创建 v2ray 订阅地址教程) 1 https://aishangyou.tube/?p=6885
Goorm Shell Auto Deploy 1 https://github.com/guleonseon/goorm-auto
okteto 容器破解搭建宝塔 shell 教程 1 2 https://fbk.ink/946.html https://www.hostloc.com/forum.php?mod=viewthread&tid=667527
在 Compute Engine 上设置适用于 Linux 的 Chrome 远程桌面 1 https://cloud.google.com/solutions/chrome-desktop-remote-on-compute-engine?hl=zh-cn#installing_chrome_remote_desktop_on_the_vm_instance
10 分钟快速掌握 Docker 必备基础知识 1 2 https://juejin.im/post/6844903918372143112 https://juejin.im/post/6844903938030845966
wget/curl large file from google drive 1 https://stackoverflow.com/questions/25010369/wget-curl-large-file-from-google-drive/39225039#39225039
如何卸载阿里云 & 腾讯云官方的监控软件服务 1 https://51.ruyo.net/5369.html
oooldking/script 1 https://github.com/oooldking/script
教程 01:如何通过 V2Ray 搭配使用洋葱 tor 浏览器? 1 https://test.enuotime.com/guide01
别以为有 vpn 我找不到你(网警抓人全过程) 1 http://www.91ri.org/3599.html
浅谈 HTTP 劫持、DNS 污染的影响及解决办法(仅个人理解) 1 https://doubibackup.com/6t3mypbm-5.html
关于目前 GFW (墙) 的封锁方式 TCP 封锁 (阻断) 猜想 1 https://doubibackup.com/wkcjzpyd-2.html
SS 二级(前置)代理设置实现中转加速观看 BBC iPlayer 1 https://www.itengli.com/ss-relay/
macOS - ClashX 使用教程 1 https://wiki.kache.moe/2019/12/11/macOS-ClashX/
ClashX 教程 | macOS 上好看又好用的科学上网工具 1 https://merlinblog.xyz/wiki/ClashX.html
如何对 Linux 服务器的端口限速? 1 https://51.ruyo.net/2877.html
免费 Docker 容器来挂机 Vagex 赚美刀 1 https://51.ruyo.net/3290.html
国内申请 Google Adsense 账号以及完成首笔收款 1 https://51.ruyo.net/12240.html
2020Google 镜像大全,谷歌镜像网址 1 https://www.uedbox.com/post/54776/
香港实体预付万事达借记卡 neat 注册申请指南 1 https://www.vpsdawanjia.com/1817.html
注册 Google Voice 方案,成功率较高 1 https://github.com/masonme/GoogleVoice
使用 IFTTT 让 Google Voice 自动回复短信来保号 1 https://www.vpsdawanjia.com/1452.html
Accesser 1 https://urenko.github.io/Accesser/
“如何翻墙” 系列:关于 Tor 的常见问题解答 1 https://program-think.blogspot.com/2013/11/tor-faq.html
w3-goto-world/reademe.md 1 2 https://hoochanlon.github.io/fq-book/#/browse/zeronet https://github.com/hoochanlon/w3-goto-world/blob/master/%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91%E3%80%81%E6%9A%97%E7%BD%91%E3%80%81%E9%9B%B6%E7%BD%91/%E9%9B%B6%E7%BD%91%E4%B8%8E%E6%9A%97%E7%BD%91/reademe.md
SSH-Tunnel 1 https://hoochanlon.github.io/fq-book/#/proxy/SSH-Tunnel
Clash For Windows 小贴士:允许局域网 @320 资源私享家 1 https://www.hottg.com/www_320nle_com/133/zh-TW.html
Surge Mac 3 无限试用方案 1 2 https://blog.cat73.org/20190528/2019052801.surge3-crack/ https://gist.github.com/whyliam/a27bae053207dcb4c46bb5c9cf8ef274
Alvin9999/new-pac Wiki 1 https://github.com/Alvin9999/new-pac/wiki
shuuzhoou/doubi: 一个逗比写的各种逗比脚本~ 1 https://github.com/shuuzhoou/doubi
configuration · Dreamacro/clash Wiki 1 https://github.com/Dreamacro/clash/wiki/configuration
Clash 基本配置记录 1 http://blog.joylau.cn/2020/05/01/Clash-Config/
Clash proxy-provider 搭配 subconverter 使用小记 1 https://10101.io/2020/02/12/use-clash-proxy-provider-with-subconverter
V2Ray 白话文教程 1 2 3 4 https://toutyrater.github.io/ https://toutyrater.github.io/advanced/vps_relay.html https://toutyrater.github.io/app/netflix.html https://toutyrater.github.io/advanced/outboundproxy.html
流媒体解锁服务,解锁不能看 Netflix 的服务器 1 https://www.mainstriker.com/archives/1207
Getting Started with Software-Defined Networking and Creating a VPN with ZeroTier One 1 https://www.digitalocean.com/community/tutorials/getting-started-software-defined-networking-creating-vpn-zerotier-one?utm_medium=social&utm_source=twitter&utm_campaign=zerotier_tut&utm_content=no_image
启用 ZeroTier 的 VPN 功能,通过 VPN 转发客户端流量 1 https://github.com/aturl/awesome-anti-gfw/blob/master/ZeroTier/ZeroTier's_VPN.md
使用 VMWare 安装 macOS 虚拟机使用 Surge 作为代理网关 1 https://blog.skk.moe/post/macos-vmware-surge-gateway/
解锁 netflix 网飞代理观看方式原理及多种方法 1 https://www.mebi.me/1035.html
Introduce - Clash 1 https://lancellc.gitbook.io/clash/
一台闲置笔记本的 NAS 改造娇嗔(一)从内网穿透到远程办公 1 https://post.smzdm.com/p/awx09gg2/
1 https://andy6804tw.github.io/2018/01/19/gcp-tutorial(2)/
linux 下使用 clash (GUI) 1 https://www.jianshu.com/p/02e3e8ccfe80
国外黑科技!不可多得的云浏览器,无限制访问所有网站 1 https://mp.weixin.qq.com/s/bmidD6nygCl5JnrRO-bdyg
不小心挖出的大厂官方 Google 搜索访问渠道,低调但是放心大胆的用! 1 https://mp.weixin.qq.com/s/Ay9pfz0CLb_8R_CNQ5jCbw
整整 13 款加速器,要的赶紧白嫖啦! 1 https://mp.weixin.qq.com/s/ubJNdNdY1T5QqtCP-5wwag
免费 DNS 推荐 (国外篇) 1 https://51.ruyo.net/609.html
国内外提供免费的域名 DNS 解析的服务商 1 https://51.ruyo.net/13274.html