Toggle firewall rules from script/home assistant?

Hi,

I am denying one of the devices in my network internet access using firewall rules.

Now I'd like to be able to temporarily disable this rule using home assistant. I wasn't able to find an API so I guess this is something that is only possible using a workaround?

If somebody could point me into the right direction I'd be really happy!

Thanks!

# cli/uci
uci set firewall.filter.enabled="0"

# cli/ubus
ubus call uci set \
"{'config':'firewall','section':'filter','values':{'enabled':'0'}}"

Seems like I have some reading to do, thanks for the help!

1 Like

So the commands I ended up using are these:

#block connection
uci set firewall.reject_toniebox.enabled=1 && fw3 reload && ubus call hostapd.wlan1 del_client "{'addr': '34:14:B5:C1:4C:7D', 'reason':5, 'deauth':true, 'ban_time':30000}"

#allow connection
uci set firewall.reject_toniebox.enabled=0 && fw3

firewall.reject_toniebox is the firewall rule that rejects new connections.

ubus call hostapd.wlan1 del_client "{'addr': '34:14:B5:C1:4C:7D', 'reason':5, 'deauth':true, 'ban_time':30000}
This kills all active connections by kicking the device off the network (wlan1 in my case) and banning it for 30sec so that by the time it reconnects all existing connections are closed.

Thanks for pointing me in the right direction @vgaetera !

1 Like

See also: Is there a way to script enabling / disabling a FW-Traffic Rule? - #4 by jow

also

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.