NAS: Boot your router….

Having the Synology DiskStation hooked up to the UPS I have avoided any sudden problems when Eskom decides to load-shed again. Over the last few days I did notice (especially since now my iBurst modem and WLAN-access point is on 24×7) that leaving the iBurst modem on for too long seems to deteriorate throughput.

Neither the iBurst modem nor the Belkin access-point have remote management functions, and so I devised the following script to give my router the boot (resulting in the modem being disconnected and reconnected after the rooter boots).

How does it work: I wrote a small script which logs onto the routers management interface and then issues a restart command. This can be easily achieved with the post-method in wget. The script itself runs periodically on the NAS via a cronjob.

This mechanism will work for any router which has a browser-interface via HTTP. I created the script below after HTTP-sniffing the post-requests:

#!/bin/ash DT=`date +%b\ %d\ %T` echo $DT ROUTER: Restarting router >>/var/log/crond.log wget http://172.16.0.1/setup.cgi --post-data="pws=&itsbutton1=Submit&todo=login&this_file=login.html&next_file=ut_reset.html&language=en&message=&passwd=[BASE64-encoded-string]" wget http://172.16.0.1/setup.cgi --post-data="reboot=Restart Router&todo=reboot&this_file=ut_reset.html&next_file=reset_ok.html&message=" echo $DT ROUTER: Restarted >>/var/log/crond.log

 

In the above I use wget to submit the post request and have sniffed the http-login and reset request via HTTP Scoop – a sweet little HTTP protocol sniffer for Mac OSX.

Now you just need to automate this on your NAS via a cronjob:

MuffinStation> cat /etc/crontab

#minute hour mday month wday who command 0 2 1/5 * ? root sh /volume1/webapps/restartrouter.sh 

 

The above will restart the router at 2am every five days starting with the 1st of the month (which is great, as by the first my cap is normally gone – smile).

Print Friendly, PDF & Email