2 Replies Latest reply: Apr 15, 2011 9:13 AM by John Lockwood
John Lockwood Level 5 Level 5 (6,700 points)
I am able to successfully define various DHCP Option codes for use with Apple's DHCP server and indeed I am the person who wrote a GUI utility to make it much easier to generate the data values needed to do this. The following is a typical example of what you need to (manually) add to /etc/bootpd.plist


<key>dhcpoption66</key>
<data>
CgBklg==
</data>

I am also able to query specific DHCP option codes (as provided by Apple's DHCP server as above) using IPNetMonitorX from Sustainable Softworks. However it should I believe be possible to do the same tests via the command line in Terminal using the ipconfig getoption command, please see the "man ipconfig" page.

While as an example "ipconfig getoption en0 router" works fine, I cannot seem to get the right syntax for querying a specific DHCP option code, despite the man page suggesting this should be possible. Unfortunately like nearly all man pages, the information is very skimpy and the examples practically non-existant.

Could anyone reply with the correct syntax to query as an example DHCP option code 66?

I suppose (gasp!) Apple could have a bug in ipconfig preventing the ability to query option codes. (Shock, horror!)

MacBook Pro, Mac OS X (10.6.5)
  • MrHoffman Level 6 Level 6 (13,265 points)
    When in doubt, use the source.

    The DHCP [client.c source code|http://www.opensource.apple.com/source/bootp/bootp-198.2/ipconfig.tproj/cl ient.c] might be interesting here.

    The core of the option-related code looks to be over in the [dhcp_options.c source code|http://www.opensource.apple.com/source/bootp/bootp-198.2/bootplib/dhcp_opt ions.c?txt] and what looks to be the option tag table mapping is over in the [gendhcp_parsetable.h source code|http://www.opensource.apple.com/source/bootp/bootp-198.2/bootplib/gendhcp_parsetable.h].

    A quick read of the source files and particularly the routines command_info and Sgetoption and the tag table implies that the +ipconfig getoption en0 66+ command might work. Or maybe +ipconfig getoption en0 tftpservername+ will work.

    When I test this syntax, I get +ipconfiggetoption failed, (os/kern) failure+ and which obviously doesn't bode well for this syntax, but then I likely don't have any of the related stuff enabled on this test network. (And I'm only very quickly reading the C code here...)
  • John Lockwood Level 5 Level 5 (6,700 points)
    MrHoffman wrote:
    When in doubt, use the source.

    The DHCP [client.c source code|http://www.opensource.apple.com/source/bootp/bootp-198.2/ipconfig.tproj/client.c] might be interesting here.

    The core of the option-related code looks to be over in the [dhcp_options.c source code|http://www.opensource.apple.com/source/bootp/bootp-198.2/bootplib/dhcp_options.c ?txt] and what looks to be the option tag table mapping is over in the [gendhcp_parsetable.h source code|http://www.opensource.apple.com/source/bootp/bootp-198.2/bootplib/gendhcp_parsetable.h].

    A quick read of the source files and particularly the routines command_info and Sgetoption and the tag table implies that the +ipconfig getoption en0 66+ command might work. Or maybe +ipconfig getoption en0 tftpservername+ will work.

    When I test this syntax, I get +ipconfiggetoption failed, (os/kern) failure+ and which obviously doesn't bode well for this syntax, but then I likely don't have any of the related stuff enabled on this test network. (And I'm only very quickly reading the C code here...)


    I have not found and viewed the source but I had tried that exact syntax (as per your example) and got the exact same error hence my comment that maybe (gasp!) there is a bug here.

    I have submitted a bugreporter entry and will have to wait and see if Apple reply.

    Thanks for the apparent confirmation.