要翻墙成功,这一步是最重要的。
分三步,下载本项目openwrt-fanqiang;复制配置文件;修改配置文件。
下面以linux系统 ~/Downloads 下操作为例。
-
git下载openwrt-fanqiang项目
cd ~/Downloads git clone https://github.com/softwaredownload/openwrt-fanqiang
-
或者下载zip文件
https://github.com/softwaredownload/openwrt-fanqiang/archive/master.zip
本地项目文件夹是: ~/Downloads/openwrt-fanqiang
建立一个配置文件夹,以路由器型号结束,如 ~/Downloads/openwrt-wndr4300。
cd ~/Downloads
mkdir openwrt-wndr4300
cd openwrt-fanqiang
cp -R openwrt/default/* ~/Downloads/openwrt-wndr4300/
cp -R openwrt/wndr4300/* ~/Downloads/openwrt-wndr4300/
上面的操作,先复制共用的配置文件 openwrt/default/* 到 openwrt-wndr4300目录下 然后复制wndr4300专用的配置文件到 openwrt/wndr4300/* 到 openwrt-wndr4300目录下,如果有同名文件就覆盖。
如果你要贡献本项目,也是先在openwrt-fanqiang/openwrt目录下先建立路由器型号为名称的文件夹,再把专用的配置文件放到此文夹下。注意文件夹和文件名都是小写的。
openwrt-wndr4300/etc/shadowsocks.json
openwrt-wndr4300/usr/bin/shadowsocks-firewall
openwrt-wndr4300/etc/uci-defaults/defaults
为了方便以后升级,可以写个bash文件自动修改配置文件。
一切操作尽量自动化,你甚至可以自动化一切操作:下载ImageBuilder,下载OpenWrt源码,下载shadowsocks-libev源码,同步openwrt-fanqiang源码,编译ipk,修改翻墙设置,编译翻墙固件,早上一觉醒来,新鲜出炉、美味可口的翻墙固件就已经摆放在桌上了。
下面是一个自动修改配置文件的例子,从中可以知道需要修改哪些地方。从2015年12月起,可能用于自动化修改的默认值都应该标准化,方便自动化操作。
#!/bin/bash
# Author: https://github.com/softwaredownload/openwrt-fanqiang
# Date: 2015-12-20
REPOSITORY=~/Downloads/openwrt-fanqiang
CONFIG=~/Downloads/openwrt-wndr4300
createdir() {
rm -rf $CONFIG
mkdir $CONFIG
}
copy() {
cp -R $REPOSITORY/openwrt/default/* $CONFIG/
cp -R $REPOSITORY/openwrt/wndr4300/* $CONFIG/
}
setmod() {
chmod +x $CONFIG/usr/bin/shadowsocks-firewall
chmod +x $CONFIG/etc/uci-defaults
chmod +x $CONFIG/etc/uci-defaults/*
}
modify() {
# server ip address
sed -i 's/1.0.9.8/server_ip/' $CONFIG/etc/shadowsocks.json
# server_port
sed -i 's/1098/server_port/' $CONFIG/etc/shadowsocks.json
# local_port
sed -i 's/7654/7654/' $CONFIG/etc/shadowsocks.json
# password
sed -i 's/killgfw/killgfw/' $CONFIG/etc/shadowsocks.json
# method
sed -i 's/aes-256-cfb/aes-256-cfb/' $CONFIG/etc/shadowsocks.json
# server ip addresss
sed -i 's/1.0.9.8/server_ip/' $CONFIG/usr/bin/shadowsocks-firewall
# local_port
sed -i 's/7654/7654/' $CONFIG/usr/bin/shadowsocks-firewall
# ppoe username
sed -i 's/wan-username/wan-username/' $CONFIG/etc/uci-defaults/defaults
# ppoe password
sed -i 's/wan-password/wan-password/' $CONFIG/etc/uci-defaults/defaults
# wifi password
sed -i 's/icanfly9876/icanfly9876/g' $CONFIG/etc/uci-defaults/defaults
# router login password for root
sed -i 's/\\nfanqiang/\\nfanqiang/' $CONFIG/etc/uci-defaults/defaults
}
if [ "$1" = "createdir" ]; then
createdir
elif [ "$1" = "copy" ]; then
copy
elif [ "$1" = "setmod" ]; then
setmod
elif [ "$1" = "modify" ]; then
modify
else
echo "usage: createdir copy setmod modify"
fi
必改值是:
server_ip
wan-username
wan-password
如果你比较懒,就改这三项就行了,可以说本教程是最简单的翻墙方案了。
选改值:
router login password for root
wifi password
其他值一般保持默认值就可以了。
假设config-wndr4300.sh在~/Downloads目录下,运行命令自动修改翻墙配置:
cd ~/Downloads
sudo chmod +x config-wndr4300.sh
./config-wndr4300.sh createdir
./config-wndr4300.sh copy
./config-wndr4300.sh setmod
./config-wndr4300.sh modify