Restarting EdgeOS PPPoE automatically.

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 1.1.1.1
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.

Comments

  1. Have you set up a ~/.ssh/config alias or set ‘router’ in you r Pi host file?

    Or are you just using router a a reference assuming most people reading this will know your meaning for them to enter their edgerouter ip address

  2. I’ve more done it as an example but on the Pi, “router” is referenced in /etc/hosts. You can substitute it with the IP of your router also.

Leave a Reply

Your email address will not be published. Required fields are marked *