OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • General Discussion »
  • API or any remote method to activate rules?
« previous next »
  • Print
Pages: [1]

Author Topic: API or any remote method to activate rules?  (Read 10264 times)

ikkeT

  • Jr. Member
  • **
  • Posts: 58
  • Karma: 1
    • View Profile
API or any remote method to activate rules?
« 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.

BR,
ikke
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17707
  • Karma: 1618
    • View Profile
Re: API or any remote method to activate rules?
« Reply #1 on: November 20, 2017, 07:43:04 am »
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
Logged

buergeb

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
Re: API or any remote method to activate rules?
« Reply #2 on: February 20, 2018, 10:45:06 pm »
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
Logged

seamus

  • Jr. Member
  • **
  • Posts: 80
  • Karma: 1
    • View Profile
Re: API or any remote method to activate rules?
« Reply #3 on: February 23, 2018, 10:23:20 am »
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  :)
Logged

ikkeT

  • Jr. Member
  • **
  • Posts: 58
  • Karma: 1
    • View Profile
Re: API or any remote method to activate rules?
« Reply #4 on: February 23, 2018, 10:52:08 am »
I have schedules set. Is there a way to update them over API?
« Last Edit: February 23, 2018, 11:05:39 am by ikkeT »
Logged

seamus

  • Jr. Member
  • **
  • Posts: 80
  • Karma: 1
    • View Profile
Re: API or any remote method to activate rules?
« Reply #5 on: February 23, 2018, 08:52:42 pm »
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. 
Logged

nycaleksey

  • Newbie
  • *
  • Posts: 24
  • Karma: 3
    • View Profile
Re: API or any remote method to activate rules?
« Reply #6 on: October 12, 2020, 09:13:09 pm »
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!
Logged

fabian

  • Hero Member
  • *****
  • Posts: 2769
  • Karma: 200
  • OPNsense Contributor (Language, VPN, Proxy, etc.)
    • View Profile
    • Personal Homepage
Re: API or any remote method to activate rules?
« Reply #7 on: October 13, 2020, 06:23:10 am »
It is already there.
Logged

nycaleksey

  • Newbie
  • *
  • Posts: 24
  • Karma: 3
    • View Profile
Re: API or any remote method to activate rules?
« Reply #8 on: October 14, 2020, 10:06:12 pm »
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.
Logged

lassieee

  • Newbie
  • *
  • Posts: 2
  • Karma: 1
    • View Profile
Re: API or any remote method to activate rules?
« Reply #9 on: October 26, 2020, 02:44:58 pm »
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
« Last Edit: October 26, 2020, 05:07:23 pm by lassieee »
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • English Forums »
  • General Discussion »
  • API or any remote method to activate rules?
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2