What's new

How to restart WAN connection?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

What script commands are available to stop and restart the WAN connection?
You could try this:

Code:
service "restart_wan_if 0"
 
Is there a watchdog script to ping say google servers every say 30 seconds, if no reply restart WAN? Seem to be having issues losing WAN every now and then, a reboot fixes the issue.
 
That is similar to what happens here. Every now and then, the cable network has some kind of "event", but the modem stays "up" and my router thinks it is all still connected. The only way to recover is to power cycle the modem, or restart the WAN on the router. So that's what my script does now. It gets invoked from /jffs/scripts/init-start like this:

/jffs/bin/wan_watch.sh &>/dev/null &

Code:
#!/bin/bash
sleep 60
count=0
while true ; do
        sleep 15
        if ping -c1 -w1 8.8.8.8 >/dev/null 2>&1 ; then
                count=0                                 
        else
                count=$((count + 1))
                if [ $count -gt 4 ]; then
                        count=0
                        ifconfig eth0 down
                        sleep 1
                        service "restart_wan_if 0"
                fi             
        fi       
done
 
Last edited:
Edited my original post above, with new/improved version of the script. This one doesn't hit google nearly as often as the earlier script.
 
  • Like
Reactions: foz

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!

Members online

Top