This script takes a CSV file and converts its entries to an XML file containing entries compatible with pfSense.
- Make sure Ruby 2.7.0 is installed. Not familiar with Ruby? See RVM.
- Clone the repo locally.
- Run
gem install bundler && bundle
in the repo directory.
-
Create a CSV file with the data you want to import.
- See
example.csv
. Note that your CSV file requires a header line with the proper field names. ipaddr
andmac
are required fields.- Optional fields are:
CID HOSTNAME DESCR FILENAME ROOTPATH DEFAULTLEASETIME MAXLEASETIME GATEWAY DOMAIN DOMAINSEARCHLIST DDNSDOMAIN DDNSDOMAINPRIMARY DDNSDOMAINKEYNAME DDNSDOMAINKEY TFTP LDAP
- See
-
Create an XML backup of your pfSense installation.
- IMPORTANT: only select "DHCP Server" as your Backup Area.
-
Run the script against your CSV file.
./convert /path/to/dhcp.csv
- or
./convert /path/to/dhcp.csv /path/to/output.xml
-
Add the generated entries to your pfSense backup file.
- With your favorite text editor, open BOTH the generated XML file and the pfSense backup XML file.
- Copy all the
staticmap
entries from the generated XML file and replace the oldstaticmap
entries in your pfSense XML backup file. - If your pfSense XML file does not contain
staticmap
entries, simply paste the generated content belowdhcpleaseinlocaltime
.
-
In pfSense, import the modified backup file.
- IMPORTANT: only select "DHCP Server" as your Import Area.