找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 17992|回复: 85

openwrt官方SDK编译、安装使用trojan,并实现透明代理

 火.. [复制链接]
发表于 2020-3-28 21:35 | 显示全部楼层 |阅读模式
本帖最后由 99010 于 2020-3-28 22:18 编辑

参考https://www.atrandys.com/2020/2343.html的教程,完善了一些不足。

以openwrt官方19.07.2的mt7621为例。


下载openwrt官方SDK
  1. wget https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.2/targets/ramips/mt7621/openwrt-sdk-19.07.2-ramips-mt7621_gcc-7.5.0_musl.Linux-x86_64.tar.xz
复制代码
解压SDK
  1. tar xvJf  openwrt-sdk-19.07.2-ramips-mt7621_gcc-7.5.0_musl.Linux-x86_64.tar.xz
复制代码
进入SDK编译目录
  1. cd openwrt-sdk-19.07.2-ramips-mt7621_gcc-7.5.0_musl.Linux-x86_64
复制代码
拉取openwrt组件
  1. make package/symlinks
复制代码
下载github上的openwrt-trojan、dns-forwarder
  1. git clone https://github.com/trojan-gfw/openwrt-trojan.git package/trojan
复制代码
  1. git clone https://github.com/aa65535/openwrt-dns-forwarder.git package/dns-forwarder
复制代码
进入组件目录,再退出并保存
  1. make menuconfig
复制代码
编译Trojan、dns-forwarder,可以用 -j4 参数加快编译
  1. make package/trojan/compile V=s
复制代码
  1. make package/dns-forwarder/compile V=s
复制代码
bin目录里面有编译好的ipk。

-----------------------------------------------------------------------------------------------------------

将trojan、dns-forwarder的ipk上传到路由器tmp目录并安装
  1. opkg update
  2. opkg install /tmp/*.ipk
复制代码
编辑dns-forwarder配置文件
  1. vi /etc/config/dns-forwarder
复制代码
内容如下
  1. config dns-forwarder
  2. option listen_addr '0.0.0.0'
  3. option listen_port '5353'
  4. option dns_servers '8.8.8.8'
  5. option enable '1'
复制代码
编辑trojan.配置文件
  1. vi /etc/trojan.json
复制代码
内容如下
  1. {
  2.         "run_type": "nat",        //可选client、forward、nat,要在路由器上做透明代理就用nat,注:nat需要1.15.1以上版本的trojan
  3.         "local_addr": "0.0.0.0",
  4.         "local_port": 1080,
  5.         "remote_addr": "example.com",                //你的服务器域名
  6.         "remote_port": 443,
  7.         "password": [
  8.                 "password1"        //密码
  9.                 ],
  10.         "log_level": 1,
  11.         "ssl": {
  12.                 "verify": true,
  13.                 "verify_hostname": true,
  14.                 "cert": "",                //证书,可选自定义证书。
  15.                 "cipher": "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:AES128-SHA:AES256-SHA:DES-CBC3-SHA",
  16.                 "cipher_tls13": "TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384",
  17.                 "sni": "",
  18.                 "alpn": [
  19.                         "h2",
  20.                         "http/1.1"
  21.                         ],
  22.                 "reuse_session": true,
  23.                 "session_ticket": false,
  24.                 "curves": ""
  25.                 },
  26.         "tcp": {
  27.                 "no_delay": true,
  28.                 "keep_alive": true,
  29.                 "reuse_port": false,
  30.                 "fast_open": false,
  31.                 "fast_open_qlen": 20
  32.                     }
  33. }
复制代码
修改/etc/config/trojan
  1. config trojan
  2.         option enabled     '1'
复制代码


到此,trojan安装完成。

---------------------------------------------------------------------------------------------------------------------


要实现透明代理,还需要做如下步骤。
安装必要的组件
  1. opkg update
  2. opkg remove dnsmasq
  3. rm -rf /etc/config/dhcp
  4. opkg install dnsmasq-full ipset iptables-mod-nat-extra
复制代码
修改/etc/firewall.user,添加如下
  1. ipset -N gfwlist iphash
  2. iptables -t nat -A PREROUTING -p tcp -m set --match-set gfwlist dst -j REDIRECT --to-port 1080
  3. iptables -t nat -A PREROUTING -p tcp -d 8.8.8.8/32 -j REDIRECT --to-ports 1080
  4. iptables -t nat -A OUTPUT -p tcp -d 8.8.8.8/32 -j REDIRECT --to-ports 1080
复制代码
修改/etc/dnsmasq.conf,添加如下
  1. conf-dir=/etc/dnsmasq.d
复制代码
创建/etc/dnsmasq.d/gfwlist.conf文件
  1. mkdir  -p /etc/dnsmasq.d
  2. vi /etc/dnsmasq.d/gfw.conf
复制代码
内容如下(可自行添加或者找网上分享的gfwlist列表,注意一下格式)
  1. server=/google.com/127.0.0.1#5353
  2. ipset=/google.com/gfwlist
  3. server=/gstatic.com/127.0.0.1#5353
  4. ipset=/gstatic.com/gfwlist
  5. server=/googleusercontent.com/127.0.0.1#5353
  6. ipset=/googleusercontent.com/gfwlist
  7. server=/ggpht.com/127.0.0.1#5353
  8. ipset=/ggpht.com/gfwlist
  9. server=/ytimg.com/127.0.0.1#5353
  10. ipset=/ytimg.com/gfwlist
  11. server=/googlevideo.com/127.0.0.1#5353
  12. ipset=/googlevideo.com/gfwlist
  13. server=/twitter.com/127.0.0.1#5353
  14. ipset=/twitter.com/gfwlist
  15. server=/twimg.com/127.0.0.1#5353
  16. ipset=/twimg.com/gfwlist
  17. server=/t.co/127.0.0.1#5353
  18. ipset=/t.co/gfwlist
  19. server=/facebook.com/127.0.0.1#5353
  20. ipset=/facebook.com/gfwlist
  21. server=/fbcdn.net/127.0.0.1#5353
  22. ipset=/fbcdn.net/gfwlist
复制代码


重启路由让所有配置生效即可。

编译好的ipk,mt762x、ar71xx、x86_64 for openwrt 19.07.2

链接: https://share.weiyun.com/5FNekfL (密码:y5lD)

评分

参与人数 2恩山币 +2 收起 理由
mxwz01 + 1 很多人不知道这个的价值,因为人们习惯懒惰罢了,为楼主点赞希望楼主解惑于大家
ShiroiSky + 1 为辛苦付出的人点赞

查看全部评分

我的恩山、我的无线 The best wifi forum is right here.
 楼主| 发表于 2020-3-28 21:39 | 显示全部楼层
占坑备用。。。。。。。。。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-3-29 14:54 | 显示全部楼层
高大全的19.07
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-3-29 15:53 | 显示全部楼层
自己编译下试试
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-3-31 11:58 来自手机 | 显示全部楼层
我也是按照他的教程作的目前发现问题可能是etc/firewall.user没有做
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-3-31 11:59 来自手机 | 显示全部楼层
本帖最后由 mxwz01 于 2020-4-1 07:28 编辑

我到时候可以发一下ip409x和powerpc 464fp的ipk
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-4-1 23:57 | 显示全部楼层
感谢大佬分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-4-2 00:23 | 显示全部楼层
本帖最后由 mxwz01 于 2020-4-2 20:30 编辑

和楼主反馈一下目前成功了。但是我想楼主到时候解释一下openwrt配置的具体步骤和相关的因果,谢谢大佬啊!楼主还有2个开机启动没有加上去。dnsmasq.d需要赋值吗!
我这边加几个自己编译好了的
链接:https://share.weiyun.com/59BH9Tt 密码:g69uwc
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-4-3 12:47 | 显示全部楼层
感谢分享   
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-4-3 14:45 | 显示全部楼层
有用, 感谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-4-3 14:48 | 显示全部楼层
看看帖子里藏了啥好东西~~~
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-4-3 20:58 | 显示全部楼层
……手欠把trojan删了,烦躁……
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-4-3 21:03 | 显示全部楼层
谢谢楼主辛苦的劳动~!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-4-4 06:45 | 显示全部楼层
不错!谢谢
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-4-5 19:24 | 显示全部楼层
占坑备用。。。。。。。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-19 06:24

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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

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