2.7 KiB
2.7 KiB
SOCKS5代理
SOCKS5,本地科学上网代理协议,监听 127.0.0.1:10808,在 Mac Mini、Ubuntu1、Ubuntu2 上正常运行,NAS 上仅本机监听。
Overview
SOCKS5 代理是一种网络协议,通过 SOCKS 代理服务器转发客户端的网络请求,支持 TCP 和 UDP。本方案中各节点通过 v2rayA 或类似代理客户端在本地启动 SOCKS5 代理服务,供本机应用走科学上网通道。
Node Status
|| 节点 | IP | 端口 | 状态 | FRP 暴露 | |------|-----|-----|------|----------| | Mac Mini M4 | 127.0.0.1 | 10808 | ✅ 正常 | — | | Ubuntu Server 1 | 127.0.0.1 | 10808 | ✅ 正常 | — | | Ubuntu Server 2 | 127.0.0.1 | 10808 | ✅ 正常 | — | | Synology NAS | 127.0.0.1 | 20170 | ❌ 仅本机监听 | 否 |
Usage Patterns
终端命令级(ProxyChains)
ProxyChains 通过 LD_PRELOAD 劫持 socket 调用,强制任意终端命令走 SOCKS5 代理:
# /etc/proxychains4.conf
socks5 127.0.0.1 10808
# 使用
proxychains4 curl https://google.com
Git 全局代理
Git 不读取系统环境变量,必须显式配置:
git config --global http.proxy socks5://127.0.0.1:10808
git config --global https.proxy socks5://127.0.0.1:10808
Docker Daemon 代理
通过 systemd drop-in 文件注入环境变量:
# /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=socks5://127.0.0.1:10808"
Environment="HTTPS_PROXY=socks5://127.0.0.1:10808"
Docker 容器环境变量
# 容器内使用 ALL_PROXY 环境变量
docker run -e ALL_PROXY=socks5://172.24.0.1:10808 ...
Key Distinction: socks5 vs socks5h
- socks5:DNS 解析在本地完成,可能 DNS 污染
- socks5h:DNS 解析由代理服务器完成,防止本地 DNS 污染
curl -x socks5h://127.0.0.1:10808 https://google.com
Docker 网络网关 IP
Docker 容器内访问宿主机的 IP 不是 127.0.0.1(那是容器自身),而是 Docker 网络网关 IP:
- bridge 网络默认:
172.17.0.1 - 自定义网络(如 compose 项目):
172.24.0.1
Related Concepts
- 透明代理 — V2RayA 通过 iptables 劫持系统出站流量
- 环境变量代理 — HTTP_PROXY/HTTPS_PROXY/ALL_PROXY 环境变量
- Docker-Daemon-Proxy — systemd drop-in 方式为 docker pull 配置代理
- ProxyChains — 终端命令级流量劫持工具
- Git 全局代理 — Git 专用代理配置
Related Entities
- v2rayA — NAS 上的 SOCKS5 代理来源(端口20170)
- Mac Mini M4 — SOCKS5 代理节点之一
- Ubuntu Server — SOCKS5 代理节点
- Synology NAS DS718 — v2rayA 部署位置(仅本机监听)