安装配置shadowsocks+ChinaDNS+dns-forwarder

添加软件源

  1. 添加证书
    wget http://openwrt-dist.sourceforge.net/openwrt-dist.pub
    opkg-key add openwrt-dist.pub
  2. 编辑/etc/opkg/customfeeds.conf,添加软件源
    src/gz openwrt_dist http://openwrt-dist.sourceforge.net/packages/base/x86_64
    src/gz openwrt_dist_luci http://openwrt-dist.sourceforge.net/packages/luci

在线安装

opkg update
opkg install ChinaDNS
opkg install luci-app-chinadns
opkg install dns-forwarder
opkg install luci-app-dns-forwarder
opkg install shadowsocks-libev
opkg install luci-app-shadowsocks

离线安装

opkg update
wget http://openwrt-dist.sourceforge.net/packages/base/x86_64/ChinaDNS_1.3.3-1_x86_64.ipk
opkg install ChinaDNS_1.3.3-1_x86_64.ipk
wget http://openwrt-dist.sourceforge.net/packages/base/x86_64/dns-forwarder_1.2.1-2_x86_64.ipk
opkg install dns-forwarder_1.2.1-2_x86_64.ipk
wget http://openwrt-dist.sourceforge.net/packages/base/x86_64/shadowsocks-libev_3.3.4-1_x86_64.ipk
opkg install shadowsocks-libev_3.3.4-1_x86_64.ipk
opkg install luci-app-chinadns
opkg install luci-app-dns-forwarder
opkg install luci-app-shadowsocks

配置shadowsocks

添加服务器

设置

访问控制

配置ChinaDNS

配置dns-forwarder

安装配置HTTP代理privoxy(可选)

安装

opkg install privoxy 
opkg install luci-app-privoxy
opkg install luci-i18n-privoxy-zh-cn

配置 方式一(注意先,先配置好再启动)


配置 方式二

编辑/etc/config/privoxy

config privoxy 'privoxy'
option confdir '/etc/privoxy'
option logdir '/var/log'
option logfile 'privoxy.log'
list filterfile 'default.filter'
list actionsfile 'match-all.action'
list actionsfile 'default.action'
list listen_address '0.0.0.0:8118'
option toggle '1'
option enable_remote_toggle '1'
option enable_edit_actions '1'
option forwarded_connect_retries '0'
option keep_alive_timeout '300'
option debug_512 '1'
option debug_4096 '1'
option debug_8192 '1'
list forward_socks5 '/ 127.0.0.1:1080 .'
list forward '192.168.*.*/ .'
list forward '127.*.*.*/ .'
list forward '10.*.*.*/ .'
list forward 'localhost/ .'

config system 'system'
option boot_delay '5'

配置PAC文件

安装pip

opkg install python3-pip

安装genpac

pip install genpac

生成SOCKS5代理方式

genpac --proxy="SOCKS5 192.168.3.2:1080" --gfwlist-proxy="SOCKS5 192.168.3.2:1080" -o /www/gfwlist.pac

生成HTTP代理方式

genpac --proxy="SOCKS5 192.168.3.2:1080" --gfwlist-proxy="PROXY 192.168.3.2:8118" -o /www/gfwlist.pac

自动更新配置

新建脚本

  • /etc/script/gen_pac.sh

    /usr/bin/genpac --proxy="SOCKS5 192.168.3.2:1080" --gfwlist-proxy="SOCKS5 192.168.3.2:1080" -o /www/gfwlist.pac
  • /etc/script/gen_chnroute.sh

    /bin/wget -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | awk -F\| '/CN\|ipv4/ { printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > /etc/chinadns_chnroute.txt

更改权限

系统 >> 计划任务

chmod +x /etc/script/gen_pac.sh
chmod +x /etc/script/gen_chnroute.sh

添加定时任务

14  4  8  *  *  sh /etc/script/gen_chnroute.sh 
14 4 8 * * sh /etc/script/gen_pac.sh

使用

macos系统

参考文献