Skip to content

Shadowsocks 正经用途 搭建 IPv6 节点 远程访问局域网

警告

本篇不涉及科学上网相关知识,仅通过 Shadowsocks 作为常规代理用于访问家中局域网

前言

众所周知,VPN 的正经用途一般就是用于远程访问局域网,后来渐渐的用作了科学上网;而各类加密协议则是为科学上网而生的,但是逆向思维,这类加密协议能不能作为远程访问局域网的一种途径呢?

当然可以。在我们连接了代理节点之后,相当于通过搭建了节点的机器进行上网,那当我们通过 IPv6 连接到家中的设备后,通过该设备自然也可以访问局域网中的其他设备了。

现在流行的加密协议有很多,但是我们作为正经用途,流量并不会通过 GFW,所以选择最基础简单的 Shadowsocks 即可,支持的客户端多,搭建配置也相对简单。

服务端

旧版

对于旧设备,可以直接使用 shadowsocks-libev,安装起来比较简单(不支持新的 2022 加密方式)

sh
apt install shadowsocks-libev

安装完成后,编辑 /etc/shadowsocks-libev/config.json 配置文件,其中 server 中一定要包含 [::0] 才能通过 IPv6 进行连接

提示

不支持 AES 的处理器,建议使用 chacha20-ietf-poly1305 作为加密方式

json
{
  "server": ["[::0]", "0.0.0.0"],
  "server_port": 8388,
  "password": "<password>",
  "timeout": 120,
  "method": "chacha20-ietf-poly1305"
}

启动 Shadowsocks 并设置开机自启

sh
systemctl start shadowsocks-libev
systemctl enable shadowsocks-libev

新版

对于新设备,如果你更在意安全性,则需要安装新版的服务端,例如 shadowsocks-rust 或者 Xray,新版支持了 2022 加密方式,对于密钥也有要求,需要使用 openssl rand -base64 <长度> 以生成与 shadowsocks-rust 兼容的密钥,长度取决于所使用的加密方法。

加密方法密钥长度
2022-blake3-aes-128-gcm16
2022-blake3-aes-256-gcm32
2022-blake3-chacha20-poly130532

下面以 Xray 为例,可以通过一键脚本安装 Xray

sh
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install
json
{
  "log": {
    "loglevel": "waring",
    "access": "/var/log/xray/access.log",
    "error": "/var/log/xray/error.log"
  },
  "inbounds": [
    {
      "listen": "0.0.0.0",
      "port": 8388,
      "protocol": "shadowsocks",
      "settings": {
        "network": "tcp,udp",
        "method": "2022-blake3-aes-256-gcm",
        "password": "<password>"
      }
    }
  ],
  "outbounds": [{ "protocol": "freedom" }]
}

客户端

配置

客户端类型很多,以目前比较流行的 Clash 为例,其中 server 填写 DDNS 的域名,用来连接服务端

不知道怎么设置 DDNS 的可以看之前发过的《通过 ddns-go 动态域名解析 实现公网访问内网服务》

yaml
  - name: 🌐 Shadowsocks
    type: ss
    server: <ddns.com>
    port: 8388
    cipher: chacha20-ietf-poly1305
    password: <password>
    udp: true

设置

还需要添加一条分流规则,将内网网段分流到 Shadowsocks

yaml
rules:
  - IP-CIDR,192.168.1.0/24,🌐 Shadowsocks,no-resolve

除此之外,大部分客户端会绕过内网网段,还需要单独设置一下

  • Clash for Windows:Settings -> System Proxy -> Bypass Domain/IPNet 将你的内网网段删除
  • Clash Meta for Android:设置 -> 网络 取消勾选绕过私有网络
关注微信公众号
你认为这篇文章怎么样?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0

预览:

评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v3.1.3