What's new

Script to toggle WAN

  • 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!

CMc

Occasional Visitor
In recent weeks I’m having issues with my ISP modem (virgin media SH3) dropping and out and failing to give my ASUS router a DHCP address.
I can fix this by toggling the “Internet Connection” in main page.

Can I put this into a script? I don’t know enough to write the script. I watched the log to see if I could commands sent when I manually cycled, but nothing showed worthwhile.

then I can run this via SSH and could invoke via Siri Shortcuts. Saves family logging in and faffing etc

off
wait 5
on

Any ideas?
 
Should be possible with the command "service restart_wan". Service commands are mostly undocumented but you can poke around the source here and find them by searching for strcmp/strncmp.
 
  • Like
Reactions: CMc
In recent weeks I’m having issues with my ISP modem (virgin media SH3) dropping and out and failing to give my ASUS router a DHCP address.
I can fix this by toggling the “Internet Connection” in main page.

Can I put this into a script? I don’t know enough to write the script. I watched the log to see if I could commands sent when I manually cycled, but nothing showed worthwhile.

then I can run this via SSH and could invoke via Siri Shortcuts. Saves family logging in and faffing etc

off
wait 5
on

Any ideas?

Add wan-event script in /jffs/scripts
and build a script something like....

Code:
#!/bin/sh

# variables passed to wan-event
# $1 > Wan Adaptor
# $2 > Wan state
#               init
#               connecting
#               connected
#               disconnected
#               stopped
#               disabled
#               stopping

if [ $2 == "disconnected" ]; then
  service stop_wan
  sleep <number of seconds>
  service start_wan
fi

Have not tested to see if I got all the bugs out, you may be able to issue service restart_wan without having to sleep first.
 
Add wan-event script in /jffs/scripts
and build a script something like....

Code:
#!/bin/sh

# variables passed to wan-event
# $1 > Wan Adaptor
# $2 > Wan state
#               init
#               connecting
#               connected
#               disconnected
#               stopped
#               disabled
#               stopping

if [ $2 == "disconnected" ]; then
  service stop_wan
  sleep <number of seconds>
  service start_wan
fi

Have not tested to see if I got all the bugs out, you may be able to issue service restart_wan without having to sleep first.
Without a sleep of about four seconds, the second _wan command would be skipped over as the first it still being run.
I would use service restart_wan as the sole command and see if that fixes the problem.
 

Latest threads

Sign Up For SNBForums Daily Digest

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