参考https://github.com/trojan-gfw/openwrt-trojan
这个版本也支持trojan-go
git clone https://github.com/trojan-gfw/openwrt-trojan.git ./package/openwrt-trojangit clone https://github.com/trojan-gfw/openwrt-trojan.git ./package/openwrt-trojan
然后 ./scripts/feeds update -a && ./scripts/feeds install -a
make menuconfig
openwrt中trojan的配置:
将/etc/config/trojan 文件中的0改为1
编辑etc/trojan.json 文件,如果仅仅作socks5 将下面 "run_type": "nat",改为 "run_type": "client",
{
"run_type": "nat", "local_addr": "0.0.0.0", "local_port": 1080, "remote_addr": "xxxxx", "remote_port": 443, "password": [ "xxxxx" ], "log_level": 1, "ssl": { "verify": true, "verify_hostname": true, "cert": "", "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", "cipher_tls13": "TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384", "sni": "xxxxx", "alpn": [ "h2", "http/1.1" ], "reuse_session": true, "session_ticket": false, "curves": "" }, "tcp": { "no_delay": true, "keep_alive": true, "reuse_port": false, "fast_open": false, "fast_open_qlen": 20 } }
在防火墙自定义规则中,输入:
ipset -N gfwlist iphash
iptables -t nat -A PREROUTING -p tcp -m set --match-set gfwlist dst -j REDIRECT --to-port 1080
iptables -t nat -A OUTPUT -p tcp -m set --match-set gfwlist dst -j REDIRECT --to-port 1080
创建 /etc/dnsmasq.d/gfwlist.conf 文件
添加需要翻墙的网站,格式如下
server=/google.com/127.0.0.1#5054 (你本机DNS服务器端口是5054.否则请指向合适的dns服务器)
ipset=/google.com/gfwlist
编辑/etc/dnsmasq.conf 文件如下,(注意dnsmasq的版本是dnsmasq-full)
no-resolv
no-poll
conf-dir=/etc/dnsmasq.d
cache-size=1000
server=114.114.114.114
启动: /etc/init.d/trojan start