OPNsense Forum

English Forums => Tutorials and FAQs => Topic started by: MAK3SN0sense on December 01, 2021, 05:36:05 pm

Title: Automatically create Unbound DNS entries over the API
Post by: MAK3SN0sense on December 01, 2021, 05:36:05 pm
Hello everybody,

to increase efficiancy in our network I am trying to automatically create DNS entries when my Ansible routines are creating new VMs. We are using the Unbound DNS module of OPNsense and I found this documentation:

https://docs.opnsense.org/development/api/core/unbound.html

Unfortunatelly, it's not very detailed and explains little, I managed to create a token for my OPNsense user and access the API to get some statistic information with Postman but there seems to be nothing which allows me to create overrides. My research of the last hours showed little, some refference to the above mentioned API, others say it's not supported and suggest to manipulate the configuration XML instead.

Does anybody know what the current state of the Unbound DNS API is and if I can archieve the following tasks?


Maybe there are helpful tutorials which I simply didn't find you know of?

I would like to avoid having to manipulate the XML configuration on a productive firewall or to parse the webinterface.

Thank you very much.
Title: Re: Automatically create Unbound DNS entries over the API
Post by: mimugmail on December 02, 2021, 07:25:48 am
Unbound is not API enabled, you could do this with bind plugin
Title: Re: Automatically create Unbound DNS entries over the API
Post by: MAK3SN0sense on December 02, 2021, 09:40:46 am
Good morning,

thank you for your answer mimugmail.

Unbound is not API enabled, you could do this with bind plugin

Was afraid so :(, but the bind module looks a lot better, will discuss this with our firewall department.

Also, maybe it helps someone else, I noticed that in the API documentation section, each controller has a model.xml attached to it which appears to describe the required POST request payloads. Guess XML is required interally by OPNsense, for documentation purposes though it is a little confusing that the API payloads are supposed to be in JSON and the explaination is in XML, potentially requiring a user to try out what works or not. JSON examples would help inexperienced users.

Again, thanks for your fast help  :D