Hi OPNsense Forum,
I have read up on the both the Core API and the "Firewall" plugin API, and can only find the controller for "source_nat" that is documented.
I am wanting to dynamically control the the NAT -> Port Forward table via the API.
Also when I call the /api/firewall/filter_base/get
API, it returns an API exception error: [internal function]: Phalcon\\Di\\Di->get('OPNsense\\\\Firewa...', NULL)
Has someone any domain knowledge in this area or can help me with this please?
For those who find this post and are having difficulty calling an OPNsense API, below is a full curl command posting data for reference:
curl \
-XPOST \
-H "Content-Type: application/json" \
-d '{"host": {"enabled":"1","hostname":"test","domain":"example.com","rr":"A","server":"1.2.3.4","description":"A test"}}' \
-k \
-u "yourAPIkey":"yourAPIsecret" \
https://opnsense.ip.address.or.dns.name/api/unbound/settings/addHostOverride/
The response you should get states:
{
"result":"saved",
"uuid":"guid_id_of_object_created"
}
Lots of people refer to it, but never in its full form in this forum. Hopefully will help others over time.
Hi.
FYI: If you have trouble using some OPNSense API - I've implemented many of the available ones in my project => https://github.com/ansibleguy/collection_opnsense
One could use the Ansible modules directly or read into (the code) how to use the APIs. :D
- AnsibleGuy