My parents often have internet outages – this is a problem with them being rural. Sometimes their Edgerouter doesn’t reconnect the PPPoE session which means I need to get my father to reboot the router. I’ve got a Raspberry Pi on the network so thought I’d implement a watchdog if you like to attempt to automate this. It is a quick hack, but also shows how you’re able to automate some commands on the Edgerouter from a remote host also.
First, generate a SSH key on your Pi using ssh-keygen and apply this to your Edgerouter.
On your Raspberry Pi – create a new file called “uptime.sh” and paste the following into it:
#!/bin/bash ping -c 1 184.108.40.206 if [ $? -eq 0 ]; then echo "We're alive!" else echo "`date`: Internet dropped. Resetting PPPoE Session" >> ping.log # ssh router '/opt/vyatta/bin/vyatta-op-cmd-wrapper disconnect interface pppoe0' >> ping.log ssh router '/opt/vyatta/bin/vyatta-op-cmd-wrapper connect interface pppoe0' >> ping.log echo "-----" >> ping.log fi
Run “touch ping.log” – this is just a log of events. Can be useful for troubleshooting reasons.
Add this to your crontab (crontab -e) – I have mine running every 5mins.
*/5 * * * * bash /path/to/uptime.sh >/dev/null 2>&1
Completed. If your PPPoE drops there will at-least be some sort of automated attempt to recover it quicker than the Edgerouter normally does.