Home
Help
Search
Login
Register
OPNsense Forum
»
English Forums
»
24.1 Legacy Series
»
[Solved]Python script converts Opnsense configuration file into kea reservations
« previous
next »
Print
Pages:
1
[
2
]
Author
Topic: [Solved]Python script converts Opnsense configuration file into kea reservations (Read 3831 times)
Monju0525
Jr. Member
Posts: 52
Karma: 6
Re: [Solved]Python script converts Opnsense configuration file into kea reservations
«
Reply #15 on:
February 25, 2024, 07:51:44 pm »
The script looks at the contents of
['dhcpd']['lan']['staticmap'] and essentially copies the contents into the kea section
[‘reservations’] starting as [‘reservation uuid’]
U will see what I migrated by running:
opnsense_isc_to_kea_reservations.py config-OPNsense.localdomain-20240218111111.xml
Diff the merge.xml and config-OPNsense.localdomain-20240218111111.xml
It does not do vlans but it something I can look into.
I am not familiar with vlans but tell me what you want to migrate from and to.
I need xml tags or gators🐊 and your sanitized config-OPNsense*.xml file.
Also, I need to know what the final populated xml should look like.
«
Last Edit: February 25, 2024, 08:16:32 pm by Monju0525
»
Logged
MoonbeamFrame
Jr. Member
Posts: 71
Karma: 2
Re: [Solved]Python script converts Opnsense configuration file into kea reservations
«
Reply #16 on:
February 25, 2024, 09:17:10 pm »
I did look at the contents of your merge output.
This will be the first time I've used Kea, so I'm not sure what the final result will need to be.
When I get time I'll run another machine with my firewall config on it and add additional subnets into Kea. Then see what the xml looks like.
I'll also dig out some old bash scripts I wrote which I used to migrate in ISC DHCP configs when I moved some clients from an external ISC DHCP server to OPNsense.
Logged
Monju0525
Jr. Member
Posts: 52
Karma: 6
Re: [Solved]Python script converts Opnsense configuration file into kea reservations
«
Reply #17 on:
February 26, 2024, 01:17:05 am »
If u enable kea, move one of the vlans to a kea reservation, save the new config and then diff the orig config vs the new kea config , u will see what actually moved with kea enabled.
Logged
randyg503
Newbie
Posts: 2
Karma: 0
Re: [Solved]Python script converts Opnsense configuration file into kea reservations
«
Reply #18 on:
March 09, 2024, 06:10:53 pm »
curious if/how this script might accommodate the below 24.1.3 change:
o kea-dhcp: add import/export as CSV on reservations
Logged
MoonbeamFrame
Jr. Member
Posts: 71
Karma: 2
Re: [Solved]Python script converts Opnsense configuration file into kea reservations
«
Reply #19 on:
March 09, 2024, 10:16:02 pm »
If export/import is added to the ISC DHCPv4/v6 using the same file format as the existing Kea export/import, then migration of reservations between the two becomes trivial.
Logged
Monju0525
Jr. Member
Posts: 52
Karma: 6
Re: [Solved]Python script converts Opnsense configuration file into kea reservations
«
Reply #20 on:
March 10, 2024, 12:50:53 am »
@randyg503
It does not. I wrote the script on 24.1.2 before they released kea csv import/export functionality. My use case was to move the current isc static leases into kea reservations. It assumes u have a working kea dhcp with one kea reservation created. No export/import needed since it automatically does the merges into a newly created merge.xml. Ur original config-OPNsense*.xml is never modified.
On 02252024, I made changes and now it supports a command line argument.
Install Python3 ( I installed python 3.12.1 on my W11 desktop)
>>> python3 opnsense_isc_to_kea_reservations.py <your_config-OPNsense*.xml>
Note: I regex check ur opnsense config file name format.
The migrated changes are in merge.xml
https://github.com/patrick0525/Python-Opn-isc-kea
«
Last Edit: March 10, 2024, 02:34:42 am by Monju0525
»
Logged
randyg503
Newbie
Posts: 2
Karma: 0
Re: [Solved]Python script converts Opnsense configuration file into kea reservations
«
Reply #21 on:
March 10, 2024, 02:52:20 am »
Thank you for your feedback regarding my question and for your work on this script.
Logged
Monju0525
Jr. Member
Posts: 52
Karma: 6
Re: [Solved]Python script converts Opnsense configuration file into kea reservations
«
Reply #22 on:
March 10, 2024, 03:20:15 am »
@randyg53
No problem. It really added to my Python, xml, ElementTree, Python dictionary, json object, json array, regex understanding and knowledge. It was challenging but it is not my day job.
Logged
Print
Pages:
1
[
2
]
« previous
next »
OPNsense Forum
»
English Forums
»
24.1 Legacy Series
»
[Solved]Python script converts Opnsense configuration file into kea reservations