Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Create a configurable DHCPd that is NetBoot aware Network
I'm working on a Mac OS X port of SystemImager, an automated software installation and distribution tool.

The first thing I needed was a configurable DHCP server that supports NetBooting.
I suspect bootp (aka DHCP) on Mac OS X Server does this, but I've never been able to figure out how to create statically assigned IP addresses assigned by MAC address. Gave up and replaced the built in bootp with the standards-based dhcpd from ISC, modified to support NetBoot, configured to sit cozy on Mac OS X.

Below are the directions, for anyone that might find it useful.

[Editor's note: I have not tested this hint myself, as it's well beyond my skill set! However, I don't see anything malicious in the script, and it might prove useful to some of you, so here it is...]

  1. Download dhcp-3.0pl1.tar.gz from Internet Software Consortium:
     % curl -O ftp://ftp.isc.org/isc/dhcp/dhcp-3.0pl1.tar.gz
  2. Unarchive the source:
     % tar zxvf dhcp-3.0pl1.tar.gz
  3. Downlaod the patch to make dhcpd netboot aware from Ron Lineweaver:
     % curl -O http://software.harrisonburg.k12.va.us/linux/
    src/dhcp-3.0-macnb-0.4.patch
    The above is shown on two lines; enter it as one with no spaces.

  4. Patch ISC's DHCP (enter the appropriate path for each file to patch):
     % mv dhcp-3.0pl1 dhcp-3.0-new
    % patch -p1 < dhcp-3.0-macnb-0.4.patch
  5. Configure, Build and Install modified DHCPd:
     % cd dhcp-3.0-new
    % ./configure
    % make
    % sudo make install
  6. Create an empty dhcpd leases file
     % touch /var/db/dhcpd.leases
  7. Add DHCP=-YES- to /etc/hostconfig entry

  8. Make StartupItem folders:
     % mkdir /Library/StartupItems
    % mkdir /Library/StartupItems/DHCP
    % mkdir /Library/StartupItems/DHCP/Resources
    % mkdir /Library/StartupItems/DHCP/Resources/English.lproj
  9. Make /Library/StartupItems/DHCP/DHCP. On my network, DHCP is being served by en0; modify "/usr/sbin/dhcpd en0" to taste:
    #!/bin/sh

    ##
    # DHCP
    ##

    . /etc/rc.common

    StartService ()
    {
    if [ "${DHCP:=-NO-}" = "-YES-" ]; then
    if ! pid=$(GetPID dhcpd); then
    ConsoleMessage "Starting DHCP services"
    /usr/sbin/dhcpd en0
    fi
    fi
    }

    StopService ()
    {
    if pid=$(GetPID dhcpd); then
    ConsoleMessage "Stopping DHCP services"
    kill -TERM "${pid}"
    else
    echo "dhcpd is not running."
    fi
    }

    RestartService ()
    {
    if pid=$(GetPID sendmail); then
    ConsoleMessage "Restarting DHCP services"
    kill -HUP "${pid}"
    else
    StartService
    fi
    }

    RunService "$1"
  10. Make /Library/StartupItems/DHCP/StartupParameters.plist:

    {
    Description = "DHCP server";
    Provides = ("DHCP");
    Requires = ("Network");
    Uses = ("Disks", "Network Time");
    OrderPreference = "None";
    }
  11. Make /Library -> StartupItems -> DHCP -> Resources -> English.lproj -> Localizable.strings:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist SYSTEM "file://localhost/System/
    Library/DTDs/PropertyList.dtd">
    <plist version="0.9">
    <dict>
    <key>Starting DHCP services</key>
    <string>Starting DHCP services</string>
    <key>Stopping DHCP services</key>
    <string>Stopping DHCP services</string>
    <key>Restarting DHCP services</key>
    <string>Restarting DHCP services</string>
    </dict>
    </plist>
    The "Doctype" line has been split in two for easier display; enter it as one line with no spaces.

  12. Set ownership and permissions:
     % chown -R root.wheel /Library/StartupItems/DHCP
    % chmod -R 755 /Library/StartupItems/DHCP
    % chmod 644 /Library/StartupItems/DHCP/StartupParameters.plist
  13. Make /etc/dhcpd.conf file (see man dhcpd.conf for details):
    default-lease-time 2592000;
    max-lease-time 2592000;
    ddns-update-style ad-hoc;
    option subnet-mask 255.255.255.0;
    option broadcast-address 192.168.2.255;
    option routers 192.168.2.1;
    option domain-name-servers 192.168.2.1, 204.127.202.19;
    option domain-name "home.com";

    subnet 192.168.2.0 netmask 255.255.255.0 {
    range 192.168.2.2 192.168.2.100;
    }

    group {
    host tibook {
    hardware ethernet 00:30:65:10:76:0c;
    fixed-address 192.168.2.4;
    }
    }
  14. Finally, start the DHCP services:
     % sudo SystemStarter start DHCP
That's it!
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[15,297 views]  

Create a configurable DHCPd that is NetBoot aware | 3 comments | Create New Account
Click here to return to the 'Create a configurable DHCPd that is NetBoot aware' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Typo on /Library/StartupItems/DHCP/DHCP
Authored by: vanetten on Oct 17, '02 11:01:44AM

Ooops!

I used the Sendmail StartupItem as a template for the DHCP StartupItem and accidentally left sendmail as the process to restart.

Within the file /Library/StartupItems/DHCP/DHCP

RestartService ()
{
if pid=$(GetPID sendmail); then
ConsoleMessage "Restarting DHCP services"
kill -HUP "${pid}"
else
StartService
fi
}

Shoudl be:

RestartService ()
{
if pid=$(GetPID dhcpd); then
ConsoleMessage "Restarting DHCP services"
kill -HUP "${pid}"
else
StartService
fi
}



[ Reply to This | # ]
OS X's built-in bootpd actually works fine...
Authored by: daveschroeder on Oct 17, '02 07:10:45PM

It's easy to assign fixed addresses via DHCP using the built-in services on Mac OS X...it's just that they're done in NetInfo rather than a text config file. Look at "man bootpd". You're basically just adding entries to the /machines tree in NetInfo. They each get a property for ethernet address, machine name, and the fixed IP to be assigned; basically the same stuff you put into a text config file. That's it!

(And yes, this does actually work; I use it on a server myself.)



[ Reply to This | # ]
OS X's built-in bootpd actually works fine...
Authored by: gsgm on Oct 21, '02 10:27:57AM

I installed the files this weekend including the correction for the restart script.

However, when I try to start the daemon, I recieve a message that it was unable to find a socket.

I thought it might have been brickhouse, but I retried it with it turned off with the same result.



[ Reply to This | # ]