API or any remote method to activate rules?

Started by ikkeT, November 19, 2017, 08:15:58 PM

Previous topic - Next topic
Hi,

I fancy a physical button at home, which would kill certain devices network connectivity. Think of kid not stopping playing after several mentions about dinner.... :)

So I could use my BT button which controls rules in my OpenHAB home automation box. That could then call API of OPNSense to toggle certain FW group on/off.

Is there such API, or any samples doing it e.g. using curl? I didn't find API in docs.

BR,
ikke

Hi Ikke,

For the firewall not yet. We've been working on making rules fully pluggable for plugins, but this is still missing NAT support. This and hopefully API support for alias updates is all we will be able to finish for 18.1.


Cheers,
Franco

Hello Franco,

what does "for the firewall not yet" mean? Could you say please, if the feature for activaing/deactivating firewall rules via api is on the roadmap?

Thank you
   Bodo

Quote from: ikkeT on November 19, 2017, 08:15:58 PM
Hi,

I fancy a physical button at home, which would kill certain devices network connectivity. Think of kid not stopping playing after several mentions about dinner.... :)

So I could use my BT button which controls rules in my OpenHAB home automation box. That could then call API of OPNSense to toggle certain FW group on/off.

Is there such API, or any samples doing it e.g. using curl? I didn't find API in docs.

Have you looked at the Firewall->Settings->Schedule config? Maybe a different way to accomplish your objective, but of course would require that you eat dinner at the same time  :)

February 23, 2018, 10:52:08 AM #4 Last Edit: February 23, 2018, 11:05:39 AM by ikkeT
I have schedules set. Is there a way to update them over API?

Have you looked at this?: https://docs.opnsense.org/development/how-tos/api.html

It doesn't provide many details, but it states that "All components... receive API capabilities", so that would mean you should be able to do what you want... except for maybe the "physical button" part - but I guess you have a plan for that. 

Bumping this thread from 2.5 years ago.

Was the functionality to enable/disable firewall rules via API ever implemented? If not, does anyone know if it's on the roadmap ?

Thanks!


Thank you! Do you know what API command can be used to enable certain rule and to disable it?

Tried reading the documentation at https://docs.opnsense.org/development/api/core/firewall.html but it's very limited.

October 26, 2020, 02:44:58 PM #9 Last Edit: October 26, 2020, 05:07:23 PM by lassieee
Stumbled upon this thread. Looking to implement this as well. Found this thread which seems to have the appropriate commands: https://forum.opnsense.org/index.php?topic=16943.0

edit: tried it, works like a charm :-)
docs: https://docs.opnsense.org/development/api/plugins/firewall.html