Automate restart of WAN interface

Started by dilby, March 10, 2020, 08:10:25 PM

Previous topic - Next topic
Hi,

I have a script that pings multiple addresses, and if all fails attempts to bring down  then up the WAN interface using :

ifconfig vtnet1 down
delay(20)
ifconfig vtnet1 up

Whilst the internet is fully functioning, using the above two commands seems to work ok.

However, there has been an instance where the internet dropped and the above commands didn't work, but I am able to go into Interface->[WAN]->Untick Enable Interface->Apply, Then re-tick, then apply.
I'm just wondering is different in the process of using ifconfig vs. the Web UI.

Thanks Dilby.

I've replaced both ifconfig lines with :

/usr/local/etc/rc.configure_interface wan

This is called by one of the predefined cron jobs called "Periodic interface reset" which I assume does what it says. I'll see if that works the next time there is an issue.

sorry to ressurect this thread, can you share the scripts? because I have similar problem with wan interfaces that need restart every week due to subnet changes, thank you.