下载和设置OpenWrt路由器翻墙配置文件

自己手工收集编辑翻墙所用到的配置文件是件比较累的事情。最快的方法是 git clone 本项目,修改其中某些选项

下载翻墙配置文件

cd ~/Downloads
git clone https://github.com/softwaredownload/openwrt-fanqiang

默认配置文件目录:openwrt-fanqiang/openwrt/default

针对特定路由器的配置文件目录,以路由器型号为目录名,如 openwrt-fanqiang/openwrt/wndr4300

复制配置文件,以wndr4300路由器为例:

  • 本地建立配置文件目录,如 ~/Downloads/openwrt-wndr4300

  • 复制默认配置文件到 ~/Downloads/openwrt-wndr4300

      mkdir ~/Downloads/openwrt-wndr4300
    
      # Linux下复制默认配置文件
      cp -R ~/Downloads/openwrt-fanqiang/openwrt/default/* ~/Downloads/openwrt-wndr4300/
    
      # 复制WNDR4300路由器的特定配置文件,同名文件就覆盖
      cp -R ~/Downloads/openwrt-fanqiang/openwrt/wndr4300/* ~/Downloads/openwrt-wndr4300/
    

修改配置文件,编译后就直接可以用了。否则刷上固件后登录路由器再修改。主要修改如下文件:

~/Downloads/openwrt-wndr4300/etc/shadowsocks-libev/config.json
~/Downloads/openwrt-wndr4300/usr/bin/ss-firewall-asia
~/Downloads/openwrt-wndr4300/etc/uci-defaults/defaults
  • shadowsocks.json 中 server必须改成你的服务器实际IP

  • defaults 中wan-username 和 wan-password必改

  • ss-firewall 中 1.0.9.8必须改成你的服务器实际IP

  • 编译自定义固件时,设置FILES=~/Downloads/openwrt-wndr4300

自定义配置文件用途说明

定制固件的前提是你要有一台服务器运行shadowsocks服务端ss-server

  • etc/dnsmasq.conf 设置dnsmasq配置文件目录
  • etc/shadow 登录路由器的密码, 默认是fanqiang
  • etc/uci-defaults/defaults 默认上网设置及时区等设置

关于 /etc/uci-defaults目录

uci-defaults目录下的文件会在路由器第一次启动时由/etc/init.d/boot执行,如果在文件末尾加上exit 0, 则执行就会删除此文件,否则执行成功则删除,不成功则在下次启动时继续执行直到成功

我们在这个目录下创建一个defaults文件,在这个文件中设置上网参数,时区等

To set some system defaults the first time the device boots, create a script in the folder

All scripts in that folder are automatically executed by /etc/init.d/boot and if they exited with code 0 deleted afterwards (scripts that did not exit with code 0 are not deleted and will be re-executed during the next boot until they also successfully exit)

默认端口及修改方法(可以不改)

  • shadowsocks服务端监听端口:1098

    • 文件位置: 服务器/etc/shadowsocks-libev/config.json
    • 如更改,路由器里 /etc/shadowsocks-libev/config.json也相应更改
  • 路由器shadowsocks ss-redir 监听端口:7654

    • 文件位置: 路由器/etc/shadowsocks-libev/config.json
    • 如更改, 路由器/usr/bin/ss-firewall-asia也相应更改
  • 路由器shadowsocks ss-tunnel监听端口: 3210

    • 文件位置: 路由器/etc/init.d/shadowsocks
    • 如更改, 路由器 /etc/dnsmasq.d/gfwlist.conf也相应更改

以上端口建议不改。程序运行稳定后,相关密码可以改掉

端口关联的理解

  • ss-firewall负责把非中国流量转发到本地端口7654
  • ss-redir监听端口7654,该端口流量都加密走自己的服务器通道
  • dnsmasq把非国内重要域名的dns查询转发本地3210端口
  • ss-tunnel监听本地端口3210,把该端口的dns查询转发到自己服务器向8.8.4.4查询

设置可执行权限

chmod +x usr/bin
chmod +x usr/bin/*
chmod +x etc/uci-defaults
chmod +x etc/uci-defaults/defaults

相关资源:


感谢 movie editor converter download 提供空间