OPNsense Forum

Archive => 20.1 Legacy Series => Topic started by: dilby on March 10, 2020, 08:10:25 PM

Title: Automate restart of WAN interface
Post by: dilby on March 10, 2020, 08:10:25 PM
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.
Title: Re: Automate restart of WAN interface
Post by: dilby on March 10, 2020, 10:08:43 PM
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.
Title: Re: Automate restart of WAN interface
Post by: ark on October 19, 2020, 10:26:15 PM
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.