Migrate DHCP Server static leases

Hi

We are currently using an old Mac Pro as a DHCP Server, using the latest El Capitan Server version. Now we would like to copy all the static DHCP leases we set up (around 120 static leases), so that we can put them on a separate Mac mini, that then takes over half of the leases for a different subnet.


I know that DHCP leases, temporary ones, are saved in a file that you can delete to clear the leases, but i haven't found the location where the static leases are saved. I know that you can edit them over the Directory Manager application, but i need to export them somehow, so that we can easily migrate them. A Time Machine backup is not an option.


Thanks in advance!


Cheers

iMac, OS X El Capitan (10.11), Profilemanager, Netinstall, NetBoot

Posted on Apr 6, 2016 1:43 AM

Reply
12 replies

Apr 6, 2016 2:06 AM in response to timo.schaffner

The configuration file for Apple's DHCP server is /etc/bootpd.plist


The file you are looking for is /etc/bootptab however it is also possible to define static IP maps in Open Directory itself under the section Computers. If a map is defined in /etc/bootptab it takes precedence over the setting in Open Directory.


You might want to do the following in Terminal.app to get more information


man bootpd

man bootptab


The file that contains the list of dynamic leases is /var/db/dhcpd_leases


It is a bit ironic that Apple use the name dhcpd_leases as dhcpd is a different competing DHCP server program to the bootpd program Apple use. Apple's bootpd is heavily customised over the original open-source version to add for example support for NetBoot.

Apr 6, 2016 4:40 AM in response to timo.schaffner

No the bootpd.plist is the configuration file.


If the /etc/bootptab file is empty this implies that the static maps are defined in Open Directory. You can run the Directory Utility to view this, the easiest way is to launch it by searching for it in Spotlight however the program itself is located at /System/Library/CoreServices/Applications/Directory Utility.app


You could also try the following on the Mac server. I don't know if this method will list static DHCP maps.


sudo serveradmin settings dhcp


If it does list them then you can 'save' them to a text file like this


sudo serveradmin settings dhcp > dhcpstuff.txt


Then on the other server you can import them like this


sudo serveradmin settings < dhcpstuff.txt


In between you could edit the dhcpstuff.txt file to remove unwanted entries and settings.

Apr 6, 2016 4:39 AM in response to John Lockwood

This is pretty amazing, it let's me export the list of the static leases, but it doesn't let me import them back again.


It is true that everything is set up using directory utility. I have set up around 100 of the leases through OS X Serveradmin, and the rest, around 20 of them directly inside Directory Utility, because of same IP asignings for Ethernet and WiFi and stuff like that, worked like a charm.


However now as i said i can export the leases and it gives me a file, but when i try to import that file on another computer, it just seems to be ignoring the stuff, and only imports some stuff, but i don't exactly know what. It seems to import the static lease arrays as empty arrays:

dhcp:static_maps = _empty_array

dhcp:subnets = _empty_array

Apr 6, 2016 8:19 AM in response to timo.schaffner

I found a tip form someone who claims it worked for them doing it the following slightly different way.


Rather than trying to import the saved settings as I described i.e. serveradmin settings < dhcpstuff.txt try the following.


serveradmin settings


This puts you in to serveradmin in interactive mode. Now paste the content of the saved settings i.e. dhcpstuff.txt in to the Terminal window. Then type Control-D on a blank line to complete the process and return to the command prompt.

Apr 6, 2016 8:24 AM in response to John Lockwood

Hi John


Thanks for the tip, sadly it didn't work. It let me copy and paste the text and it seemed to process it slowly, and then on ctrl+d it exited the prompt, but i still can't see any static leases in Server or in Directory Manager. I also tried to first set up the DHCP manually identically as it has been before and then import just the leases but this hasn't worked aswell. Is there some way to export directly from directory manager and then import back into directory manager? Maybe we are taking the wrong route here by trying to import and export from Server directly... Maybe we can find a way over Directory Utility...


Cheers

Apr 6, 2016 9:42 AM in response to timo.schaffner

I no longer use Apple's DHCP server myself and even when I did I did not use any static maps. However I suppose one could assume that if the data is in Open Directory and you have a Replica Open Directory server it would be easier to get that Replica up and running as a replacement DHCP server if the master failed. The bootptab approach would require backing up and restoring that file, whereas OD replication is continuous and automatic.


I am sure there is a way to export and import from/to OD as well in fact I found the following article which confirms this and if you follow this approach and modify it to export the Computers entries that should do the job.


See http://www.amsys.co.uk/2015/01/exporting-users-os-x-server-yosemite/


In fact the following seems to work, you would run it on the OD master.


dsexport exportcomputers.txt /LDAPv3/127.0.0.1 dsRecTypeStandard:Computers


It is however more like the old method of using Workgroup Manager to export and import records. It therefore includes a lot of additional information besides presumably any DHCP maps. The resulting file is an XML file you can view.


Another similar approach would be to use an LDAP tool to browse to the relevant section and export records.

Apr 7, 2016 12:55 AM in response to John Lockwood

For me the correct terminology would be as follows:

dsexport exportcomputers.txt /Local/Default dsRecTypeStandard:Computers


It works! It has exported, and now imported them back again. This is amazing, this is what i was looking for. I can also change different stuff such as IP's by search and replace with TextEdit, since this gives me a simple text file.

Thank you so much John!


Cheers

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Migrate DHCP Server static leases

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.