Hi.
I cannot figure out how to run a cron job to programmatically Stop or Restart an interface as shown on the Luci interface for say 'LAN'. See below.
How do I achieve this?
Thanks.
Hi.
I cannot figure out how to run a cron job to programmatically Stop or Restart an interface as shown on the Luci interface for say 'LAN'. See below.
How do I achieve this?
Thanks.
ifdown br-lan && ifup br-lan
should do an restart.
Thanks. @admon
I just opened a CLI via SSH and entered "ifdown br-lan" and got the response:
"Interface br-lan not found"
Is the br-lan a special device that is not available to attach/associate to an interface via LUCI?
You are right, it appears that you can't restart a bridge like this.
What is the ultimate goal? Because stopping br-lan
will lock you out for sure.
I want to lock out br-lan at a specific time and restart at another. I have also set it not to be available on boot in case the router is manually restarted. I just want a wifi bridge available to access the interface in the br-lan down times. I want to disable all ethernet ports easily.
But br-lan
includes the Wi-Fi as well.
I have a separate device and wifi bridge for IOT devices that is outside the br-lan device/LAN bridge
In that case you can try
ip link set br-lan down
Just in case I locked myself out, I tried the above command on another bridge I have which only has 1 x port associated with it and no wifi (it's for an XBOX connection which only connects to the WAN.)
Although the command appeared to work, the bridge remains UP in the Luci interface. It does not seem to shutdown using the command. I refreshed the LUCI page, but the XBOX bridge is showing as working.
EDIT. Do you think this will need a UCI command and an interface commit or something similar?
EDIT#2 @admon It looks like the OPENWRT command 'network stop 'bridge-name' 'takes bridges down, but this does not appear to be a valid command in GL speak. Any ideas?
Well, it depends what the goal is.
A active bridge with blocked IP communication isn't an active bridge, is it?
I would assume that my command should be sufficient.
Ah, OK, I missed the subtlety of 'ip' being down rather than the bridge itself.
Just need to check if it survives a reboot or not. I would like the IP communication to be down between specific hours irrespective of whether the router is manually rebooted or not!
EDIT: You probably knew the answer to this!!! The command does not survive a manual reboot. So I need something a bit more sophisticated to ensure the IP comms remain down between say 1:00 am and 9:00 am and are taken offline again on any manual reboot that occurs only between those hours.! Any suggestions?
In the end I approached the issue in a slightly different way to achieve the same result.
I noted the commands that needed to be applied in order to edit each interface's "Bring up on boot' flag on the general settings page to be on or off. When the flag is cleared to prevent the interface being loaded on bootup, the CL command was to set the 'auto' option to '1'. When toggled, the CL command was to delete this option, which gave me a few problems with UCI when resetting. So instead I set the flag to '1' instead of '0' IN both 'on' or 'off' cases, I made the system reboot.
So the following I have put in the Scheduled Tasks screen to run at 1:00 am and 8:00am
So I turn off 3 bridges/interfaces in effect!
0 1 * * * uci del dhcp.XBOX.ra_flags && uci add_list dhcp.XBOX.ra_flags='none' && uci set network.XBOX.auto='0' && uci del dhcp.VOIP.ra_flags && uci add_list dhcp.VOIP.ra_flags='none' && uci set network.VOIP.auto='0' && uci del dhcp.lan.ra_flags && uci add_list dhcp.lan.ra_flags='none' && uci set network.lan.auto='0' && uci commit && reboot.
0 8 * * * uci del dhcp.XBOX.ra_flags && uci add_list dhcp.XBOX.ra_flags='none' && uci set network.XBOX.auto='1' && uci del dhcp.VOIP.ra_flags && uci add_list dhcp.VOIP.ra_flags='none' && uci set network.VOIP.auto='1' && uci del dhcp.lan.ra_flags && uci add_list dhcp.lan.ra_flags='none' && uci set network.lan.auto='1' && uci commit && reboot
It worked fine last night/this morning! Yay!