So in the spirit of Colin's and Johns helpful input, one could do this:
Create /jffs/scripts/wan_if_restart.sh and add this code to it:
Then call it from /jffs/scripts/services-start:Code:#!/bin/sh # restart primary WAN interface if not connected check_wanup(){ ping -c 1 -W 1 www.google.com >/dev/null if [ $? -eq 1 ];then logger "restarting WAN interface $(nvram get wan_primary) via $0" service "restart_wan_if $(nvram get wan_primary)" >/dev/null fi sleep 10 check_wanup } check_wanup
Create or add to /jffs/scripts/services-start
Make sure the files are working:Code:#!/bin/sh /jffs/scripts/wan_if_restart.sh # start the WAN checker
This runs continually in the background and checks every 10 seconds if the WAN interface is reported as up.Code:dos2unix /jffs/scripts/* chmod a+rx /jffs/scripts/*
If not it restarts the interface.
Edit: Code uses ping to determine WAN up
Thanks for the script, I have been getting randomly the error "DHCP does not function properly"every few days lately. Not sure if it is my ISP to blame or new firmware revision issue but it has been driving me crazy as I have bunch of IoT devices and security cameras that all fail while I am at work and have to wait to go home and reboot router to have WAN reconnect. Hopefully this script will resolve requiring the reboot. It seems odd that WAN DHCP auto reconnect is not enabled in firmware by default.