Home
Help
Search
Login
Register
OPNsense Forum
»
Archive
»
23.7 Legacy Series
»
How to configure static leases and dns entries programmatically?
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to configure static leases and dns entries programmatically? (Read 882 times)
gstrong
Newbie
Posts: 3
Karma: 0
How to configure static leases and dns entries programmatically?
«
on:
September 25, 2023, 04:03:34 am »
Hello, I'm brand new to OPNsense, but have been running PFSense for many years and never having to dig too deep. I'd like to be able to configure my static leases and dns entries programmatically so that I may version these configs and it's very reproducible. I see that there is an "advanced" means to set configuration within /usr/local/etc/dhcpd.opnsense.d, but I have no context for how these will be loaded in and I'd like to see the surrounding config to understand what would be valid. This has led to many questions:
* What would be the advised manner to programmatically configure static mappings for dhcp?
* When a static mapping is saved in the GUI, where is this persisted in the filesystem?
* What "service manager" a.la systemd is in usage with opnsense? I stumbled across configctl and pluginctl, would like to understand the difference. Are these how opnsense services like dhcp should be managed?
* How should I achieve a similar goal, but configure dns settings such as a wildcard? Is unbounce used by default? Where is this configured in the file system?
Logged
Maurice
Hero Member
Posts: 1213
Karma: 158
Re: How to configure static leases and dns entries programmatically?
«
Reply #1 on:
September 25, 2023, 01:10:36 pm »
You can use the API, if that's what you're looking for:
https://docs.opnsense.org/development/api.html
The entire config is stored in a single XML file, namely /conf/config.xml. OPNsense keeps a history of this file, see System: Configuration: History.
OPNsense then generates config files for all the services, based on the settings in the XML.
Cheers
Maurice
Logged
OPNsense virtual machine images
OPNsense aarch64 firmware repository
Commercial support & engineering available. PM for details (en / de).
gstrong
Newbie
Posts: 3
Karma: 0
Re: How to configure static leases and dns entries programmatically?
«
Reply #2 on:
September 25, 2023, 02:40:40 pm »
I read the api docs, can you point me to somewhere in the docs that describes how to create a static mapping? All I see are commands to manipulate leases, and to manage the service lifecycle.
Regarding the config file, is it a valid configuration method to edit that file directly? Will sense pick up changes automatically, or do I need to reload something? I am thinking the easiest way would be for me to download the file, inject my mappings into the xml, and then write it back and potentially reload the service?
Logged
Maurice
Hero Member
Posts: 1213
Karma: 158
Re: How to configure static leases and dns entries programmatically?
«
Reply #3 on:
September 25, 2023, 04:56:34 pm »
You're right, static mappings don't seem to be available in the API yet. Sorry, wasn't aware of this.
You can download, modify and restore the config.xml, yes. When restoring via the UI, manually reloading services shouldn't be required.
Logged
OPNsense virtual machine images
OPNsense aarch64 firmware repository
Commercial support & engineering available. PM for details (en / de).
Print
Pages: [
1
]
« previous
next »
OPNsense Forum
»
Archive
»
23.7 Legacy Series
»
How to configure static leases and dns entries programmatically?