Hi,
I need to turn off this rule off (wait) then back on, automatically.
Now Luci did give me the command it uses.
uci set firewall.cfg0e93c8.enabled='0'
uci del firewall.cfg0e93c8.enabled
But these special number only work on that particular instance of my router, but I wipe it often, and these numbers will change. I need a command that is "general".
The rule is
root@router:~# uci show firewall | grep -i snat
firewall.@nat[0].name='public_snat'
firewall.@nat[0].target='SNAT'
firewall.@nat[0].snat_ip='69.69.69.69'
root@router:~#
I can't rely on "@nat[0]" as a future router might not have that as the "rule 0". It really is the rule named public_snat that I need to turn off then on.
So, what it comes down to, is, is the following the "right way" to identify the rule number ?
root@router:~# uci show firewall | grep "name='public_snat'" | cut -d. -f2
@nat[0]
root@router:~#
Can I expect that formulation to last and be of general use ?
Something like this
id=$(uci show firewall | grep "name='public_snat'" | cut -d. -f2)
uci set firewall.$id.enabled='0'
uci commit firewall
/etc/init.d/firewall reload
sleep 5
uci del firewall.$id.enabled
uci commit firewall
/etc/init.d/firewall reload
I made a oneliner version
id=$(uci show firewall | grep "name='public_snat'" | cut -d. -f2); uci set firewall.$id.enabled='0'; uci commit firewall; /etc/init.d/firewall reload; sleep 5; uci del firewall.$id.enabled; uci commit firewall; /etc/init.d/firewall reload
This works.
Next I will need to, ping to check if internet is up, if internet not up, ping gateway, if no response, run that series of command. Loop and wait 15 seconds to do it again forever.
Also I will need to run this script at boot and it should automatically restart itself if it stops itself on its own.
