安装部署 Surge Snell

发布地址:https://kb.nssurge.com/surge-knowledge-base/release-notes/snell

wget https://dl.nssurge.com/snell/snell-server-v5.0.1-linux-amd64.zip

unzip snell-server-v5.0.1-linux-amd64.zip
mv snell-server /usr/local/bin/

vim /usr/lib/systemd/system/snell.service

snell.service 内容如下:

[Unit]
Description=Snell Proxy Service
After=network.target

[Service]
Type=simple
User=nobody
Group=nogroup
LimitNOFILE=32768
ExecStart=/usr/local/bin/snell-server -c /etc/snell-server.conf

[Install]
WantedBy=multi-user.target

vim /etc/snell-server.conf

snell-server.conf 内容如下:

[snell-server]
listen = ::0:端口
psk = 密码
ipv6 = true

继续执行:

systemctl daemon-reload
systemctl enable snell
systemctl start snell

Windows 配置 mihomo

https://github.com/MetaCubeX/mihomo/releases 下载mihomo,选择Latest版本里的 mihomo-linux-amd64-compatible-版本号.gz

https://github.com/winsw/winsw/releases 下载WinSW,选择Latest版本里的 WinSW-x64.exe

mihomo安装于C:\mihomo 目录,先创建此文件夹。

mihomo-linux-amd64-compatible-版本号.gz解压,解压后将mihomo-windows-amd64-compatible.exe改命为mihomo.exe,并移动到C:\mihomo目录。

C:\mihomo目录创建clash配置文件config.yaml,内容如下:

ipv6: false
external-controller: 0.0.0.0:9090
external-ui: ui
geodata-mode: true  # 开启 dat 模式 面板可显示规则数量
geo-auto-update: true
geo-update-interval: 24
geox-url:
  geoip: "https://fastly.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip-lite.dat"  # lite 版本 GEOIP 体积小
tun:
  enable: true
  auto-route: true
  auto-detect-interface: true
  strict-route: true
  stack: system
  dns-hijack:
    - 0.0.0.0:53
dns:
  enable: true
  listen: 0.0.0.0:53
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  fake-ip-filter:
    - '*.lan'
    - localhost.ptlogin2.qq.com
    - +.msftconnecttest.com
    - +.msftncsi.com
  nameserver:
    - system  # 调用系统 DNS 兼容性和速度最佳
proxies:
  - 代理A
  - 代理B

# ========== Proxy Groups ==========
proxy-groups:
  - name: "PROXY"
    type: select
    proxies:
      - "代理A"
      - "代理B"
      - DIRECT
rule-providers:
  global:
    type: http
    path: ./global.yaml
    url: "https://fastly.jsdelivr.net/gh/ACL4SSR/ACL4SSR@master/Clash/Providers/ProxyLite.yaml"
    interval: 86400
    proxy: DIRECT
    behavior: classical
    format: yaml
  china:
    type: http
    path: ./china.yaml
    url: "https://fastly.jsdelivr.net/gh/ACL4SSR/ACL4SSR@master/Clash/Providers/ChinaDomain.yaml"
    interval: 86400
    proxy: DIRECT
    behavior: classical
    format: yaml
rules:
  - GEOIP,private,DIRECT,no-resolve  # GEOIP 规则前加入 no-resolve 不提前解析 DNS
  - RULE-SET,global,PROXY,no-resolve
  - RULE-SET,china,DIRECT,no-resolve
  - GEOIP,cn,DIRECT
  - MATCH,PROXY

WinSW-x64.exe移动到C:\mihomo目录,重命名为mihomo-service.exe

C:\mihomo目录创建WinSW配置文件mihomo-service.xml,内容如下:

<service>
  <!-- 服务基础信息 -->
  <id>mihomo</id>
  <name>mihomo</name>
  <description>MetaCubeX mihomo service (run: mihomo.exe -f config.yaml)</description>

  <!-- 运行程序 -->
  <executable>%BASE%\mihomo.exe</executable>
  <arguments>-f "%BASE%\config.yaml"</arguments>

  <!-- 工作目录 -->
  <workingdirectory>%BASE%</workingdirectory>

  <!-- 日志目录 -->
  <logpath>%BASE%\logs</logpath>

  <!-- 输出日志 -->
  <log mode="roll-by-size">
    <sizeThreshold>10485760</sizeThreshold> <!-- 10MB -->
    <keepFiles>10</keepFiles>
  </log>

  <!-- 崩溃/退出自动拉起 -->
  <onfailure action="restart" delay="5 sec"/>

  <!-- 优雅停止:发送 Ctrl+C -->
  <stopparentprocessfirst>true</stopparentprocessfirst>
  <stoptimeout>10 sec</stoptimeout>

  <!-- 以自动启动运行 -->
  <startmode>Automatic</startmode>

</service>

以管理员身份运行CMD,cd到C:\mihomo目录,运行mihomo-service install mihomo-service.xml

至此,Windows服务中就有了mihomo,运行服务后,浏览器访问 http://127.0.0.1:9090/ui 是管理UI。

GL.iNet MT3000 路由器修改区域

We regret to make the following annoucement. Due to current legal and policy restrictions in mainland China, we are unable to provide VPN and AdGuard Home features in our CN version products sold in mainland China.

参考https://github.com/Zayrick/GL-iNet-GeoChanger中命令,试图修改MT3000的区域。

如果是OpenWrt 21,直接参照执行即可,如果是OpenWrt 24,dd if=/dev/mtdblock3 bs=1 count=2 skip=136 2>/dev/null | hexdump -C 不会返回地区代码,因为24和21的分区不同。

root@GL-MT3000:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00100000 00020000 "BL2"
mtd1: 00080000 00020000 "u-boot-env"
mtd2: 00200000 00020000 "Factory"
mtd3: 00200000 00020000 "FIP"
mtd4: 00040000 00020000 "log"
mtd5: 0f640000 00020000 "ubi"

OpenWrt 24的Factory分区是mtd2,需要执行dd if=/dev/mtdblock2 bs=1 count=2 skip=136 2>/dev/null | hexdump -C 查看地区代码。

root@GL-MT3000:~# echo -n "US" | dd of=/dev/mtdblock2 bs=1 seek=136 conv=notrunc
dd: error writing '/dev/mtdblock2': Operation not permitted
1+0 records in
0+0 records out

在OpenWrt 24写mtdblock2会报错,需要刷机回退OpenWrt 21修改地区,修改后再升级到OpenWrt 24。

Defined MONGO_HOST unifi-db is not reachable, cannot proceed.

内网部署的 UniFi Network application,https://hub.docker.com/r/linuxserver/unifi-controller 已deprecated,今天有空迁移到https://hub.docker.com/r/linuxserver/unifi-network-application

unifi-network-application需要mongodb。

部署mongodb正常,服务正常启动。部署unifi-network-application后启动失败报错如下:

[migrations] started
[migrations] no migrations found
usermod: no changes
───────────────────────────────────────
      ██╗     ███████╗██╗ ██████╗ 
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝ 
   Brought to you by linuxserver.io
───────────────────────────────────────
To support LSIO projects visit:
https://www.linuxserver.io/donate/
───────────────────────────────────────
GID/UID
───────────────────────────────────────
User UID:    1000
User GID:    1000
───────────────────────────────────────
*** Waiting for MONGO_HOST unifi-db to be reachable. ***
*** Defined MONGO_HOST unifi-db is not reachable, cannot proceed. ***

寻找解决方案,发现不少同样问题,普遍确认过mongodb连接信息正确。尝试过一些解决方法无效后,想起来container需要link才能互相通信。将mongodb和unifi-network-application容器设置`–link`后重启,服务正常启动。