找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 118829|回复: 553

[k3] K3官改版装SS透明代理,S-S R server总结

 火... [复制链接]
发表于 2017-6-15 15:03 | 显示全部楼层 |阅读模式
本帖最后由 涛娃子 于 2018-1-5 10:44 编辑

首先说明我也是初学者,自己一步步的敲代码摸索出来的,写出来只是为了让和我一样的新手少走一点弯路(但是不想动脑子的点下右上的X),有问题大家回贴,我尽力回复,但请喷子死走(你牛B为什么你不写)
先感谢一下tianbaoha原帖地址:斐讯K3 官方固件root版本 安装插件 entware,没有这个固件,我们也不可能折腾,要是大神能把TUN模块ipset支持tpoxy都搞进去就好了,呵呵,不太现实,这些要重新编译内核,还是要谢谢大神本贴中有所有软件都是在斐讯K3 官方固件root版本 安装插件 entware,大神的网盘里下载的放进/opt/bin/里加755权限
一.刷root固件
按这个贴子刷,斐讯K3 官方固件root版本 安装插件 entware,不会?右上角的X看到没?点一下
二.装opt
方法1:只装几个软件的没必要用U盘了,直接opt install就行了
方法2:在/mnt/sda1/下建立opt目录,在/media/nand/下建个软链接到/mnt/sda1/opt/,opt install 这下所有的东西都会安装到你的U盘上了,我是挂了片128G的SSD在上面
为了更好的上网,GFW两个墙1.DNS污染2.IP地址封杀
三.用dnsmasq+pdnsd+gfwlist解决DNS污染
dnsmasq系统自带了(不是FULL版本,不用ipset也能用了)
1.在/opt/etc/下建立dnsmasq.conf文件
  1. user=nobody
  2. resolv-file=/tmp/resolv.conf
  3. no-poll
  4. bogus-priv
  5. no-negcache
  6. clear-on-reload
  7. bind-dynamic
  8. listen-address=192.168.2.1,127.0.0.1,0.0.0.0
  9. port=53
  10. min-port=4096
  11. cache-size=1024
  12. conf-dir=/opt/etc/dnsmasq.d
复制代码
建立/opt/etc/dnsmasq.d目录
建个/opt/etc/dnsmasq.d/user_dnsmasq.conf文件
  • server=/.g2w.online/127.0.0.1#8053

[color=rgb(51, 102, 153) !important]复制代码

2.安装pdnsd
方法:下个编译好的放/opt/bin里加755(tianbaoha原帖的网盘里有)
编辑/opt/etc/pdnsd.conf
  1. global {
  2. perm_cache=2048;
  3. cache_dir="/opt/var/pdnsd";
  4. run_as="nobody";
  5. server_port = 8053;
  6. server_ip = 127.0.0.1;
  7. status_ctl = on;
  8. tcp_server = on;
  9. query_method=tcp_only;
  10. min_ttl=1m;
  11. max_ttl=1w;
  12. timeout=5;
  13. }
  14. server {
  15. label= "opendns";
  16. ip = 208.67.222.222, 208.67.220.220;
  17. port = 443;           
  18. root_server = on;        
  19. uptest= none;                 
  20. }

  21. server {
  22. label= "google dns";
  23. ip = 8.8.8.8, 8.8.4.4;
  24. port = 53;           
  25. root_server = on;        
  26. uptest= none;                 
  27. }

复制代码
到这里两个软件就装好了
下载gfwlist文件,放入/opt/etc/dnsmasq.d,我比较懒,没用脚本搞,我用在线生成文件https://g2w.online/,更新的方法,用计划任务
  1. nano /mnt/sda1/opt/etc/crontabs/admin
  2. 0 4 * * * wget --no-check-certificate -O /opt/etc/dnsmasq.d/gfwlist_dnsmasq.conf https://g2w.online/dnsq/127.0.0.1:8053  #每天4点自动更新,按自己的配置改
复制代码


配置开机运行
编辑/opt/started_script.sh
  1. #!/bin/sh
  2. # add by tianbaoha

  3. killall dnsmasq && dnsmasq -C /opt/etc/dnsmasq.conf
  4. pdnsd -d
复制代码


不重启就复制上面代码运行一下就行了

四.布署SS透明代理
装SS方法也有两种
1.通过opkg install SS(这个会被论坛和谐,用SS代替)
2.下编译好的放进/opt/bin/目录里去
编辑配置文件/opt/etc/ss.json

  1. {
  2. "server": "**.**.**.**",     #你SS或S-S R服务器的IP
  3. "server_port": "8388",      #服务器端口
  4. "local_address": "0.0.0.0",        #一定是0.0.0.0,要不iptables不能转发
  5. "local_port": "1081",              #SS本机的端口
  6. "password": "1233333",      #服务器密码
  7. "timeout": "180",
  8. "method": "chacha20",      #加密
  9. "protocol": "auth_sha1_v4",    #从这行下面4行是S-S R才用的,SS不用
  10. "protocol_param": "",
  11. "obfs": "http_simple",
  12. "obfs_param": ""
  13. }
复制代码

启动命令
rss-redir -c /opt/etc/redir.json -u >/dev/null 2>&1 &
把这行加入/opt/started_script.sh
  1. #!/bin/sh
  2. # add by tianbaoha

  3. killall dnsmasq && dnsmasq -C /opt/etc/dnsmasq.conf
  4. pdnsd -d
  5. rss-redir -c /opt/etc/redir.json -u >/dev/null 2>&1 &  #SS就用ss-redir,我是S-S R
复制代码



编辑iptables转发
由于没ipset支持,只能用白名单方式,我也不会写脚本,所以用手动用excel,5000多条,把国内IP RETURN,国外IP转发,我写个我的方法,要是你有更好的下面回复吧
去复制一份国内IP   http://f.ip.cn/rt/chnroutes.txt 下载下来,右键点打开方式用excel打开,删除第一行在B列加入公式如下图



生成规规则不要关,winscp打开/opt/etc/firewall.user编辑(这个是固件的自带用户iptables规则,开机自动加入iptables里)

  1. #白名单
  2. iptables -t nat -N s-s

  3. iptables -t nat -A s-s -d **.**.** -j RETURN #你SS的IP

  4. #lan ip
  5. iptables -t nat -A s-s -d 0.0.0.0/8 -j RETURN
  6. iptables -t nat -A s-s -d 10.0.0.0/8 -j RETURN
  7. iptables -t nat -A s-s -d 127.0.0.0/8 -j RETURN
  8. iptables -t nat -A s-s -d 169.254.0.0/16 -j RETURN
  9. iptables -t nat -A s-s -d 172.16.0.0/12 -j RETURN
  10. iptables -t nat -A s-s -d 192.168.0.0/16 -j RETURN
  11. iptables -t nat -A s-s -d 224.0.0.0/4 -j RETURN
  12. iptables -t nat -A s-s -d 240.0.0.0/4 -j RETURN

  13. #china ip(把excel里B列全复制到下面)

  14. #转发规则
  15. iptables -t nat -A s-s -p tcp -j REDIRECT --to-ports 1081  #1081是ss-reir的端口

  16. iptables -t nat -A PREROUTING -p tcp -s 192.168.2.0/24 -j s-s  #192.168.2.0/24是lan 网段

  17. iptables -t nat -A OUTPUT -p tcp -j s-s  #这条是本机生效,为的是后面S-S R连上也能用

复制代码
上面的S-S是给合谐过的,自己看我excel表里用的是什么字段
填好后保存,重启生效,想不重启也行,5300多行,一行行的复制,不要尝试一次从excel里全复制,我试过CPU处理不过来,好多行会出错

到这里你就可以兲朝上网了,其实我还是更喜欢黑名单方式,用ipset被墙的走代理,这个chnroute里ip不全,我还自己加了几个ip地址段,但是没办法内核不支持ipset

五.布署S-S R服务器
为什么要布署S-S R服务器呢,免流,不玩的可以不要看了
S-S R服务器只有python版本的,所以要安装python
1.安装支持
  1. opkg install python python-pip wget git git-http libsodium nano
复制代码

2.获取源码
  1. cd /opt/usr/local/ #这是我的安装目录,自己决定
  2. git clone https://github.com/koolshare/s-sr.git  #获取源码,自己去了-,合谐没办法
  3. cd s-sr
  4. cp config.json user-config.json
  5. nano user-config.json  #编辑配置文件
  6. {
  7.     "server": "0.0.0.0",
  8.     "server_ipv6": "::",
  9.     "server_port": 8388,
  10.     "local_address": "127.0.0.1",
  11.     "local_port": 1080,

  12.     "password": "1231111",
  13.     "timeout": 120,
  14.     "udp_timeout": 60,
  15.     "method": "chacha20",
  16.     "protocol": "auth_sha1_v4",
  17.     "protocol_param": "",
  18.     "obfs": "http_simple",
  19.     "obfs_param": "",
  20.     "speed_limit_per_con": 0,
  21.     "speed_limit_per_user": 0,

  22.     "dns_ipv6": false,  #这里删了两行,单用户不用这两行的
  23.     "connect_verbose_info": 0,
  24.     "redirect": "",
  25.     "fast_open": false
  26. }
复制代码





要用chacha20加密的还要改个文件/opt/usr/local/s-sr/s-s/crypto/util.py改成
在/opt/etc/建立个resolv.conf
  1. nameserver 127.0.0.1
复制代码
编辑/opt/usr/local/s-sr/s-s/asyncdns.py
把/etc/resolv.conf改成/opt/etc/resolv.conf
启动命令
python /opt/usr/local/s-sr/s-s/server.py -c /opt/usr/local/s-sr/user-config.json -d start
可以加入/opt/started_script.sh
  1. #!/bin/sh
  2. # add by tianbaoha

  3. killall dnsmasq && dnsmasq -C /opt/etc/dnsmasq.conf
  4. pdnsd -d
  5. rss-redir -c /opt/etc/redir.json -u >/dev/null 2>&1 & #SS就用ss-redir,我是S-S R
  6. python /opt/usr/local/s-sr/s-s/server.py -c /opt/usr/local/s-sr/user-config.json -d start
复制代码




开放端口
port_tcp=22,8388
iptables -I INPUT -p tcp -m multiport --dport $port_tcp -j ACCEPT

把这个加入/opt/etc/firewall.user,就开机自动了
手机装个S-S R找个混淆试试免流加兲朝上网吧

我又重新编辑了下,S-S  s-sr是被合谐过的,自己理解下吧

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

点评

我只想知道有人跟着成功了吗?  发表于 2017-6-18 15:30

评分

参与人数 12恩山币 +14 收起 理由
renyouser + 1 谢楼主分享,写的很详细,学习一下
鲜锅兔儿 + 3 支付宝已转5毛给你!
sw_yp + 1 支付宝已转500w给你!
Prescribe7361 + 1 小伙子很6
jerryjdp + 1 支付宝已转500w给你!
2711106269 + 1 我来恩山就是为了看你!
走向大山 + 1 支付宝已转500w给你!
Zwin + 1 支付宝已转500w给你!
8850 + 1 支付宝已转500w给你!
usaaus + 1 支付宝已转500w给你!
郁闷d + 1 不错~
Toktoe + 1 看完了 不过小白看的跟天书一样 还是谢谢

查看全部评分

我的恩山、我的无线 The best wifi forum is right here.
 楼主| 发表于 2017-6-15 15:10 来自手机 | 显示全部楼层
沙发自以已的
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-6-15 15:13 | 显示全部楼层
来看看, 上次我研究了一半就放弃了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-6-15 15:13 | 显示全部楼层
没有K3,但支持楼主
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-6-15 15:16 | 显示全部楼层
看看效果如何!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-6-15 15:18 | 显示全部楼层
楼主的帖子很好赞一个
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-6-15 15:20 | 显示全部楼层
支持¥¥-人?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-6-15 15:22 | 显示全部楼层
我来学习一下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-6-15 15:22 | 显示全部楼层
111111111111
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-6-15 15:23 | 显示全部楼层
看看能不能用,回家试试!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-6-15 15:24 | 显示全部楼层
楼主,你是一个大好人!!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-6-15 15:29 | 显示全部楼层
赞 折腾了几天了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-6-15 15:31 | 显示全部楼层
谢谢分享.............................
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-6-15 15:38 来自手机 | 显示全部楼层
感谢楼主的无私奉献
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-6-15 15:41 | 显示全部楼层
新手少走一点弯路
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-3-29 05:47

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表