Saturday 15 June 2013

DHCP Server on OS X Server

No Apple code was harmed during the production of this utility.
Ever since Mac OS X Server was introduced, Apple have included a DHCP Server. This was and still is based on the open-source bootpd server.
This article is not intended to discuss the purpose of a DHCP server, for that you might want to read http://en.wikipedia.org/wiki/Dhcp.
While the original open-source bootpd server has the capability to define additional fields of information (via DHCP option fields) that can be provided via DHCP to clients, the version included with Mac OS X 10.4.11 Server and earlier did not support this. After several years of my and presumably others submitting requests for this feature, this was finally added to Mac OS X 10.5 Server. The overwhelming majority of router based DHCP servers do not have the ability to define DHCP option fields.
Note: This is a facility Microsoft have provided since at least Windows 2000 Server.
Probably the most common scenario that you would come across that needs DHCP option fields, is the use of a VoIP (Voice over IP) phone system. It was my experience that small to medium enterprises were earlier to adopt this type of phone system than big enterprises, and these smaller organisations are also more likely to use Macs and Mac servers - just like the company I run the IT for in fact.
So, Apple finally introducing the ability to define DHCP option fields in Mac OS X 10.5 Server was good news. Unfortunately, Apple did not and still does not even in OS X 10.8 Mountain Lion Server, provide a user friendly method for defining these values which are stored as Base64 encoded data values in the /etc/bootpd.plist configuration file. Thanks to the efforts of myself and others, the method of generating and encoding values has now been sufficiently deciphered that I am now able to create and provide a simple utility with a graphical user interface that mere mortals can use to generate any required DHCP option field. Here is what it looks like…
Screencapture
It can be downloaded free of charge from -
DHCP Option Code Utility
If you don’t feel comfortable editing Unix configuration files like /etc/bootpd.plist then I advise you don’t try doing this. If you have not already, I advise reading the Unix man page for “bootpd” on your Mac OS X 10.5, 10.6, 10.7, or 10.8 server. This is done in the Terminal.app by typing “man bootpd”.
Update: DHCP Option Code Utility 1.1 has the following improvements.
  • It now works under Mountain Lion properly (1.0 worked from Tiger to Lion), this was due to a change Apple made
  • It now can generate null-terminated strings as well as normal strings, null-terminated strings are used for example to define PXE boot servers in DHCP Option Code 67
  • It is now more forgiving on the format of text entered for hexadecimal values and will happily ignore spaces, colons, and dashes making it simpler to just paste a value in











8 comments:

  1. Thanks a lot for this utility. It's exactly what I needed to configure my DHCP server for option 128.

    ReplyDelete
  2. Thank you for providing this utility! Is this still compatible with Mavericks server 10.9?

    ReplyDelete
  3. I'm new to this issue, we had this all working in Lion, but I have been unable to implement it on our new Mavericks server.

    Here is my bootpd info:

    dhcp_option_66

    aHR0cDovLzEwLjAuNjUuNDAvcGM=


    I used the tool to add in our pxe server but when I run ipconfig getoption en3 66 nothing is returned.

    I confirmed that other options, 3 ad 6 are returning correctly based on the information in the bootpd.plist file.

    Any advise would be appreciated.

    ReplyDelete
  4. Managed to figure out option 121 (Classless Static Routes) on El Capitan:

    Used as starting point: https://ercpe.de/blog/advanced-dhcp-options-pushing-static-routes-to-clients

    Note that the destination network is trimmed to just the significant octets.

    When you enter the string in the DHCP Option Code Utility use "hexadecimal values" selection. It works!

    My case was:
    destination network: 10.1.0.0/16 with router 10.0.0.40
    Convert to hex: 10 : 0A:01 : 0A:00:00:28 (added some spaces so you get what I mean by trimming to the significant octets of the network - in my case the first two). Drop in booted.plist, unload & load and works.

    Awesome!

    ReplyDelete
    Replies
    1. Glad you got a working solution. I just looked at the article you linked to.

      As you got it working obviously the approach you used of choosing a Hex option is correct. However I could have interpreted that article as suggesting that a choice of String and then pasting in the Hex complete with colons would have been correct.

      I am guessing the difference is down to how the different DHCP server software processes the information i.e. whether it automatically translates the string contents to bytes. Apple's bootpd will in this case literally read the hex (byte) and send it as the same hex byte. If you use a string value in Apple's bootpd then it would send 31:30:3a:30:41:3a:30:31:3a:30:41:3a:30:30:3a:30:30:3a:32:38 as hex bytes rather than the needed 10:0a:01:0a:00:00:28

      Delete
  5. I can't get your utility to work- it crashes on launch on OSX 10.14.6 (Mojave) on a Mac Mini i5 with an illegal instruction message.

    ReplyDelete
    Replies
    1. Sorry, I no longer have access to such old systems and no longer maintain this tool. There was little point as Apple no longer provide a DHCP server.

      Delete