{"id":13775899,"url":"https://github.com/henryho2006/rpiproxy","last_synced_at":"2026-01-16T08:22:02.041Z","repository":{"id":216003243,"uuid":"58724986","full_name":"HenryHo2006/RpiProxy","owner":"HenryHo2006","description":"Make a Raspberry PI as a proxy route, work with shadowsocks server, provide clean dns/proxy service","archived":false,"fork":false,"pushed_at":"2018-05-03T11:39:33.000Z","size":339,"stargazers_count":94,"open_issues_count":0,"forks_count":16,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-13T14:37:49.542Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HenryHo2006.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-05-13T09:42:20.000Z","updated_at":"2025-01-17T07:43:35.000Z","dependencies_parsed_at":"2024-01-28T03:24:33.626Z","dependency_job_id":null,"html_url":"https://github.com/HenryHo2006/RpiProxy","commit_stats":null,"previous_names":["henryho2006/rpiproxy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HenryHo2006%2FRpiProxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HenryHo2006%2FRpiProxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HenryHo2006%2FRpiProxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HenryHo2006%2FRpiProxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HenryHo2006","download_url":"https://codeload.github.com/HenryHo2006/RpiProxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253540462,"owners_count":21924522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T17:01:53.998Z","updated_at":"2026-01-16T08:22:02.001Z","avatar_url":"https://github.com/HenryHo2006.png","language":"Shell","funding_links":[],"categories":["\u003ca id=\"d03d494700077f6a65092985c06bf8e8\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"cb16466a31a167bb61f39e2a4a85f449\"\u003e\u003c/a\u003eShadowsocks"],"readme":"﻿# RpiProxy\nMake a Raspberry PI as a proxy route, work with shadowsocks server, provide clean dns/proxy service\n\u003e 前言：  \n\u003e 　　书籍是人类进步的阶梯，墙是阻碍人类进步的陷阱   --- 高尔基·马克西姆·方·滨兴\n\u003e  \n\u003e 　　翻墙的最佳姿势，当然是不在电脑/手机/pad上安装任何软件，不更改任何设置，就能访问到任何网址，墙变得透明了。\n\u003e 实现这个目标主要有两种做法：  \n1. 刷路由器固件，用OpenWrt加上其它软件。这个方式适合爱折腾的玩家，也有上网不稳定的风险存在。  \n2. 用一台专用电脑充当网关/DNS服务器，安装设置上专用软件。这种方式优点很多，还可以出差时随时携带。要说低成本电脑，\n当然要首推树莓派了。本文就是专门介绍如何让树莓派做为透明翻墙网关。已经在Raspbian(Jiessie)和OSMC系统下面测试通过了。\n\n\u003e 说明：工作目录在/home/pi下面  \n\u003e 说明：用su取得root权限，我下面的命令不再加sudo前缀  \n\u003e 说明：我的安装配置都是按systemd系统的，较老的系统不适用  \n\n\u003e v2更新说明：本文的第一版写在2016年，这段时间内：  \n  shadowsocks-libev升了很多版本，修正了一些bug，增加了更多的加密方式，用起来速度更快一些  \n  chinadns已经停止维护很久了，ss-tunnel转发dns查询的模式也不太稳定，因此决定切换到[overture](https://github.com/shawn1m/overture)上去  \n  [overture](https://github.com/shawn1m/overture)自带dns分流查询、TTL、缓存，因此个人使用也没必要安装dnsmasq了  \n  整个架构就由shadowsocks-libev + overture构成，安装维护更简单了  \n\n![系统架构图](systems.jpg \"系统架构图\")\n\n## 1.1、安装shadowsocks-libev\n    vps服务端的安装教程网上汗牛充栋，这里就不详述了  \n    但在树莓派上安装shadowsocks-libev最新版本却没那么容易，如果想自己编译安装，shadowsocks-libev的依赖库极多，  \n    又有版本要求，比较繁琐，推荐从[Debian Backports](https://backports.debian.org/Instructions/)上安装最新版本  \n    \n    vi /etc/apt/sources.list  \n    jessie版本加这行：  \n         deb http://ftp.debian.org/debian jessie-backports main  \n    stretch版本加这行：  \n         deb http://ftp.debian.org/debian stretch-backports main  \n    \n    给这个源添加公钥，否则apt-get update会报错    \n    apt-get install dirmngr    \n\n    gpg --keyserver pgpkeys.mit.edu --recv-key  8B48AD6246925553    \n    gpg -a --export 8B48AD6246925553 | sudo apt-key add -    \n\n    gpg --keyserver pgpkeys.mit.edu --recv-key  7638D0442B90D010    \n    gpg -a --export 7638D0442B90D010 | sudo apt-key add -    \n    \n    apt-get update  \n    stretch版本执行这句：  \n         apt-get install shadowsocks-libev -t jessie-backports  \n    jessie版本执行这句：  \n         apt-get install shadowsocks-libev -t stretch-backports  \n    \n## 1.2、禁用shadowsocks-libev-server服务，这个服务默认是打开的\n\n    systemctl stop shadowsocks-libev.service\n    systemctl disable shadowsocks-libev.service\n\n## 1.3、配置启动shadowsocks-libev-redir服务\n\n    vi /etc/shadowsocks-libev/ss-redir.json  \n    格式如下：  \n    {  \n        \"server\":\"境外shadowsocks服务器ip地址\",  \n        \"server_port\":境外shadowsocks服务器端口,  \n        \"local_address\": \"0.0.0.0\",  \n        \"local_port\":8888,  \n        \"password\":\"境外shadowsocks服务密码\",  \n        \"timeout\":3000,  \n        \"method\":\"chacha20-ietf-poly1305\"  \n    }  \n\n    mv /lib/systemd/system/shadowsocks-libev-redir@.service /lib/systemd/system/shadowsocks-libev-redir.service  \n    vi /lib/systemd/system/shadowsocks-libev-redir.service  \n    注意这行：ExecStart=/usr/bin/ss-redir -c /etc/shadowsocks-libev/ss-redir.json  \n    systemctl daemon-reload  \n    systemctl enable shadowsocks-libev-redir  \n    systemctl start shadowsocks-libev-redir  \n    用下面这句检查运行状态  \n    systemctl status shadowsocks-libev-redir  \n\n## 1.4、配置启动shadowsocks-libev-local服务  \n\n    注意：ss-redir是透明代理（转发）服务，ss-local是socket5转发服务，这个不同需要很清楚  \n          在本文中，8888端口用于透明代理，1080端口用于socket5转发  \n          ss-local给overture使用，用于向境外dns服务器查询  \n          \n    cp /etc/shadowsocks-libev/ss-redir.json /etc/shadowsocks-libev/ss-local.json  \n    vi /etc/shadowsocks-libev/ss-local.json  \n    {  \n        \"server\":\"境外shadowsocks服务器ip地址\",  \n        \"server_port\":境外shadowsocks服务器端口,  \n        \"local_address\": \"127.0.0.1\",  \n        \"local_port\":1080,  \n        \"password\":\"境外shadowsocks服务密码\",  \n        \"timeout\":3000,  \n        \"method\":\"chacha20-ietf-poly1305\"  \n    }  \n    mv /lib/systemd/system/shadowsocks-libev-local@.service /lib/systemd/system/shadowsocks-libev-local.service  \n    vi /lib/systemd/system/shadowsocks-libev-local.service  \n    注意这行：ExecStart=/usr/bin/ss-local -c /etc/shadowsocks-libev/ss-local.json  \n    systemctl daemon-reload  \n    systemctl enable shadowsocks-libev-local  \n    systemctl start shadowsocks-libev-local  \n    用下面这句检查运行状态  \n    systemctl status shadowsocks-libev-local  \n\n## 2.1、设置nat转发规则\n\n    vi /etc/sysctl.conf\n    注意这句：net.ipv4.ip_forward = 1\n    sysctl -p\n    下载本项目文件/etc/shadowsocks-libev/iptables.up.rules\n    修改你自己的Shadowsocks服务器ip\n    vi /etc/network/if-pre-up.d/iptables\n        #!/bin/bash\n        /sbin/iptables-restore \u003c /etc/shadowsocks-libev/iptables.up.rules\n    chmod +x /etc/network/if-pre-up.d/iptables\n\n    **注意：raspberry PI的发行版本OSMC中，不支持网络接口链接/断开脚本，做为临时办法，放到rc.local中执行\n\n## 3.1、安装配置启动overture服务\n    \n    到https://github.com/shawn1m/overture 下载安装，我的配置如下：  \n    {  \n      \"BindAddress\": \":53\",  \n      \"PrimaryDNS\": [  \n        {  \n        \"Name\": \"aliDNS\",  \n        \"Address\": \"223.5.5.5:53\",  \n        \"Protocol\": \"udp\",  \n        \"SOCKS5Address\": \"\",  \n        \"Timeout\": 6,  \n        \"EDNSClientSubnet\": {  \n          \"Policy\": \"disable\",  \n          \"ExternalIP\": \"\"  \n          }  \n        }  \n       ],  \n      \"AlternativeDNS\": [  \n      {  \n        \"Name\": \"googleDNS\",  \n        \"Address\": \"8.8.8.8:53\",  \n        \"Protocol\": \"tcp\",  \n        \"SOCKS5Address\": \"127.0.0.1:1080\",  \n        \"Timeout\": 6,  \n        \"EDNSClientSubnet\": {  \n          \"Policy\": \"disable\",  \n          \"ExternalIP\": \"\"  \n        }  \n      }  \n    ],  \n    \"OnlyPrimaryDNS\": false,  \n    \"RedirectIPv6Record\": false,  \n    \"IPNetworkFile\": \"/etc/shadowsocks-libev/china_ip_list.txt\",  \n    \"DomainFile\": \"/etc/shadowsocks-libev/gfwlist.txt\",  \n    \"DomainBase64Decode\": true,  \n    \"HostsFile\": \"/usr/bin/overture/hosts_sample\",  \n    \"MinimumTTL\": 86400,  \n    \"CacheSize\" : 604800,  \n    \"RejectQtype\": [255]  \n  }  \n    \n    注意：境外辅助dns服务器需要支持tcp，走socket5代理模式  \n    配置中指定的地址段china_ip_list，域名单gfwlist，都是众所周知的github项目，可自行下载，本项目内也有提供  \n    接下来配置为自动启动的服务：  \n    \n    vi /lib/systemd/system/overture.service  \n    格式如下：  \n    [Unit]\n    Description=overture service\n    \n    [Service]\n    ExecStart=/usr/bin/overture/overture-linux-arm -c /etc/shadowsocks-libev/overture.json\n    Restart=on-failure\n    RestartSec=42s\n    \n    [Install]\n    WantedBy=multi-user.target\n\n    systemctl daemon-reload\n    systemctl enable overture\n    systemctl start overture\n    用下面这句检查运行状态\n    systemctl status overture\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenryho2006%2Frpiproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhenryho2006%2Frpiproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenryho2006%2Frpiproxy/lists"}