Avatar

Organizations

1 results for ShadowSocks
  • 本文记录OpenWrt设置透明代理的步骤及原理。

    1. 系统环境

    • 硬件环境:Windows 10 Hyper-V虚拟机,单核处理器,256M内存
    • 固件版本:OpenWrt 19.07.6 r11278-8055e38794 / LuCI openwrt-19.07 branch git-21.101.59933-c56d9f2
    • shadowsocks-libev:3.3.5
    • luci-app-shadowsocks:2.0.2
    • v2ray-plugin:4.37.3-20210413
    • ChinaDNS:1.3.3
    • luci-app-chinadns:1.6.2
    • https-dns-proxy:2021-01-17-5
    • luci-app-https-dns-proxy:git-21.062.76689-a607f9c-1
    • luci-i18n-https-dns-proxy-zh-cn:git-21.062.76689-a607f9c-1

    2. 运行流程

    透明代理的运行原理主要由DNS访问流程IP访问流程两部分组成组成

    2.1 DNS访问流程

    flowchart LR
        lh((localhost));
        dm(Dnsmasq);
        cd(ChinaDNS);
        hdp(https-dns-proxy);
        ss(Shadowsocks);
        fd(国外DNS);
        dd(国内DNS);
    
        lh -- 1 udp:53 --> dm;
        dm -- 2 udp:5555 --> cd;
        cd -- 3.1 udp:5353--> hdp;
        cd -- 3.2 udp --> dd;
        hdp -- 4 tcp --> ss;
        ss -- 5 tcp --> fd;
    
        fd -. 6 .-> ss;
        ss -. 7 .-> hdp;
        hdp -. 8.1 .-> cd;
        dd -. 8.2 .-> cd;
        cd -. 9 缓存 .-> dm;
        dm -. 10 IP地址 .-> lh;
    

    2.2 IP访问流程

    flowchart LR
        fs(国外服务器);
        ds(国内服务器);
        lh((localhost));
        route{chinadns_chnroute.txt};
        ss(Shadowsocks);
    
        lh -- 1 --> route;
        route -- 2.1 国内IP --> ds;
        route -- 2.2 国外IP --> ss;
        ss -- 3 加密访问 --> fs;
    
        fs -. 4 返回加密数据 .-> ss;
        ds -. 5.1 返回数据 .-> lh;
        ss -. 5.2 返回解密数据 .-> lh;
    

    3. 配置

    3.1 Shadowsocks-libev + v2ray-plugin

    • 服务器管理-编辑服务器-插件参数:一定要加上"loglevel=none",如果不加v2ray-plugin插件几分钟就会被系统杀死
    • 访问控制-被忽略IP列表:/etc/chinadns_chnroute.txt

    3.2 https-dns-proxy

    由于使用了v2ray-plugin 插件,导致Shadowsocks不再支持UDP包,所以使用TCP的方式查询DNS

    v2ray proxy ShadowSocks OpenWRT Created Mon, 07 Feb 2022 13:37:19 +0800