Today a guy from BT was fiddling with the junction box outside, and my modem dropped connection to my router.
At the time, the router did not automatically force reconnect (my fault, hadn't configured it to do so). When I noticed what had happened, I reconnected to the modem. So far so good.
A couple of hours later, I noticed that two of my three Pi (all of which are connected with ethernet cables) had not reconnected to the router. The one that did reconnect is running Raspbmc (XBMC port to Raspberry Pi); the two that did not are running Apache with some bits on top.
This is a pain because not only did it take the services offline, but I was unable to ssh to the Pi to correct the problem. I'm not sure if removing and reconnecting the ethernet cable would have worked, in the end I just pulled the power and rebooted.
I found a thread on the RasPi forums about reconnecting WiFi with a BASH script after a drop. My guess is that Raspbmc includes something similar:
I'd have to modify this for ethernet instead of wlan, but I guess it would work.
The thread mentions either putting this in /etc/rc.local, or using cron to execute something similar (presumably just the ifup bit, without the sleep parts) at a given interval.
I was wondering which is more efficient, the cron way or running a script in the background?
Feathers
At the time, the router did not automatically force reconnect (my fault, hadn't configured it to do so). When I noticed what had happened, I reconnected to the modem. So far so good.
A couple of hours later, I noticed that two of my three Pi (all of which are connected with ethernet cables) had not reconnected to the router. The one that did reconnect is running Raspbmc (XBMC port to Raspberry Pi); the two that did not are running Apache with some bits on top.
This is a pain because not only did it take the services offline, but I was unable to ssh to the Pi to correct the problem. I'm not sure if removing and reconnecting the ethernet cable would have worked, in the end I just pulled the power and rebooted.
I found a thread on the RasPi forums about reconnecting WiFi with a BASH script after a drop. My guess is that Raspbmc includes something similar:
Code:
#!/bin/bash while true ; do if ifconfig wlan0 | grep -q "inet addr:" ; then sleep 60 else echo "Network connection down! Attempting reconnection." ifup --force wlan0 sleep 10 fi done
The thread mentions either putting this in /etc/rc.local, or using cron to execute something similar (presumably just the ifup bit, without the sleep parts) at a given interval.
I was wondering which is more efficient, the cron way or running a script in the background?
Feathers
Comment