Speaking on how the articleInstall SHADOWSOCKS on OPENWRT to use transparent proxy + DNS poisoning,But finished only configuration orThere are many drawbacksof。
For example, the block list is dead,The ever-changing Internet content,I'm afraid you could not pass a list of a few weeks out of date;
For example, software updates,You can not always bother to manually upload,scp ...... blah blah blah ......
so,We must have a permanent solution,Let all the automation!
First of all,It is
Automatic Updates DNS forwarding list
In the catalog/usr/binDirectory do the following command:
1 2 3 4 5 6 |
touch updatednsmasq //创建一个空文件 chmod +x updatednsmasq //给予执行权限 vi updatednsmasq //编辑它: |
Then enter the following to updatednsmasq:
1 2 3 4 5 |
cnlist() { wget -4 --no-check-certificate -O /etc/dnsmasq.d/accelerated-domains.china.conf https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf wget -4 --no-check-certificate -O /etc/dnsmasq.d/bogus-nxdomain.china.conf https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/bogus-nxdomain.china.conf } cnlist |
input:wqThen press Enter to exit the save。
This created a new list to update the two scripts,We then create a scheduled task,Let it run once every day 12:00。
In your router management web page,turn up"system"→"Scheduled Tasks”,As shown below
Then enter the following in the blank box in:
1 |
* 12 * * * /usr/bin/updatednsmasq |
Such,Every day 12:00,As long as there is network,Then the DNS on both lists are updated once!
Software update
The authors provide software update source,Then later you can use the package management tool on OpenWRT directly updated! Including CLI and web pages!
http://openwrt-dist.sourceforge.net/releases/
then,Open the router administration page,turn up"system"→"Package"→"Configuration"Tab,Where you can add the following two lines:
1 2 |
<del>src/gz openwrt_dist http://openwrt-dist.sourceforge.net/releases/brcm63xx/packages src/gz openwrt_dist_luci http://openwrt-dist.sourceforge.net/releases/luci/packages</del> |
but,due tosourceforge.netIt is named domain,So you needAfter successful configuration SS,To update the two lists。
This update source has the shelf,I would not have been updated ......
Detection SS state long,Kneeling automatic restart
Long hung SS,Inevitably kneel,So we can also write a script,It can be detected after a predetermined time of connection state SS,If the normal,Exit;If broken,Then restart SS service。
We use wget command to test,Let wget try to download at Google Japan homepage,It is to try,Not really downloaded,Once a successful connection then the SS normal,Then if they fail,The test Baidu Home,Description SS kneeling success,Restart Service;If this does not succeed,Description Network kneeling,drop out。
Code is as follows,According to the script written on top of the process of creating scripts in the directory / usr / bin directory and give execute permissions,Follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#!/bin/sh LOGTIME=$(date "+%Y-%m-%d %H:%M:%S") wget -4 --spider --quiet --tries=1 --timeout=3 www.google.co.jp if [ "$?" == "0" ]; then echo '['$LOGTIME'] No Problem.' exit 0 else wget -4 --spider --quiet --tries=1 --timeout=3 www.baidu.com if [ "$?" == "0" ]; then echo '['$LOGTIME'] Problem decteted, restarting shadowsocks.' /etc/init.d/shadowsocks restart else echo '['$LOGTIME'] Network Problem. Do nothing.' fi fi |
same,The following statement is added to the Scheduled Tasks,Including test once every ten minutes a day and SS 1:00 empty the log file to avoid excessive log fill your router pathetic memory ╮(╯▽╰)╭
1 2 |
*/10 * * * * /root/tester >> /var/log/shadowsocks_watchdog.log 2>&1 0 1 * * * echo "" > /var/log/shadowsocks_watchdog.log |
Original article written by LogStudio:R0uter's Blog » Brush OpenWRT routers use a transparent proxy ShadowSocks Advanced Configuration
Reproduced Please keep the source and description link:https://www.logcg.com/archives/868.html
The part about automatically restarting when you kneel has been taught.,I'll take it and change it so it can be used in other programs.