Updating a DHCP Configuration File

To configure DHCP, you need to edit the /etc/dhcpd.conf file (the daemon’s configuration file) as root, including at least the following stanza in the file:

ddns-update-style ad-hoc;
subnet 10.0.0.0 netmask 255.0.0.0 {

    host <name> {
        hardware ethernet 00:20:0c:10:75:0d;
        fixed-address 10.0.0.10;
        option root-path "<rfs_dir>";
    }
}

where <name> is used to identify the host, and <rfs_dir> is the path to the directory containing the RFS you want to use for your target. (The host name can be anything you want it to be, domain name included or not.)

The attached file includes DHCP information for four different root filesystems and kernels.

Note

If you use a Windows-provided editor to create text files, they might contain DOS-style line breaks. Use the dos2unix utility in Cygwin to convert the files for use in a UNIX-style system. Issue the command dos2unix --help for details about this utility.

Use values that are appropriate to your system; therefore, the MAC address should be the actual MAC address of the target. The hardware statement references the media access control (MAC) address of the target system; this is a unique value and must be changed for your hardware. Similarly, the subnet, netmask, and IP addresses you use might also be different.

You might be able to tell the hardware address of your target board when the bootloader starts. You can then enter the address in your dhcpd.conf file and restart the server.

In some network configurations, particularly in networks that already have DHCP servers, it might be necessary to add the following directive to the DHCP configuration stanza:

server-name "<IPaddress>";

The value you use should for <IPaddress> is the IP address of the host system that is acting as the DHCP server; in these examples, 10.0.0.2 is used.

You can also include the name of the kernel image file for the target to download and boot. If you specify the file here, you do not have to include it as a boot argument when you boot the board; the DHCP server will provide the necessary information. To specify the boot file, add the following directive to the DHCP configuration stanza:

filename "<kernel_image>";

A complete stanza would resemble the following:

ddns-update-style ad-hoc;
subnet 10.0.0.0 netmask 255.0.0.0 {

    host <name> {
        hardware ethernet 00:20:0c:10:75:0d;
        fixed-address 10.0.0.10;
        option root-path "<rfs_dir>";
        server-name "10.0.0.2";
        filename "<kernel_image>";
    }
}

Note

The <kernel_image> and <rfs_dir> depend on the distribution you are using. If you are using a TimeSys reference distribution, refer to the Getting Started guide that came with the distribution for the exact names and paths used for the kernel and RFS.

Each declaration in the host section ends with a semicolon. The commands in this stanza have the following meaning:

  • A ddns-update-style declaration is used if your site uses a dynamic name server that can be automatically updated as addresses are assigned by the DHCP server.
  • The subnet line identifies a subnet whose IP number is 10.0.0.0, whose netmask is 255.0.0.0, and which contains one or more host entries, enclosed within a pair of curly braces.
  • The host entry uniquely identifies the values for the host named <name>, enclosed within curly braces. The host entry for this example contains the following statements:
    • The hardware ethernet declaration specifies the hardware networking information for the DHCP client (the board). In this case, the networking protocol used is Ethernet and the address shown is the hardware (MAC) address of the board’s Ethernet hardware.
    • The fixed-address declaration tells the DHCP server to assign the specified IP address to the MAC address for this client.
    • The option root-path declaration tells the DHCP server the path to the root filesystem that the target will need to mount when the kernel boots. This is the filesystem you are exporting when you use NFS.
    • The server-name declaration specifies the default TFTP server.
    • The filename declaration specifies the kernel file you make available via TFTP, generally by copying it to the /tftpboot directory on your host.

Be careful to avoid conflicts with other DHCP servers. If your host system participates in a network other than the network for communicating with the target system, you must restrict the DHCP server so that it does not attempt to satisfy address requests from the other network. The easiest method for avoiding these conflicts is to restrict the DHCP server to one particular network interface, and to only use that interface for communication with the target system.

On Windows, use the cygrunsrv.exe command to restrict the server to a specific network interface card.

Optional DHCP Server Configuration Entries

In addition to the DHCP configuration statements given in the previous section, you can specify a number of other options in the dhcpd.conf file. Using these other options can provide your target with additional configuration information when it boots. Although these statements are optional, you might find them useful.

Additional dhcpd.conf statements that you might find useful are described below.

  • A next-server declaration specifies the address of the NFS or TFTP server if the server has a different IP address than the DHCP server. Do not use the quotes in this declaration if your host is Fedora Core 5 or later.
  • A domain-name declaration sets the domain name associated with the hosts that are obtaining configuration information from this DHCP server.
  • A domain-name-servers declaration specifies the IP address of a host that serves as a domain name server for hosts that obtain configuration information from this DHCP server.
  • A subnet-mask declaration specifies the mask used when calculating the range of IP addresses available on each subnet for which a stanza is present. If you specify this value, you do not have to specify a netmask value for any subnet that uses the specified default.
  • Within the subnet stanza:
    • A routers declaration specifies the IP addresses of hosts that route packets to other networks.
    • A host-name declaration within a host specification specifies the host name to be associated with an IP address assigned by this DHCP server.

A dhcpd.conf file using all these commands is illustrated in the following example:

option domain-name "timesys.com";
option domain-name-servers 192.168.2.1;
option subnet-mask 255.255.255.0;
ddns-update-style ad-hoc;
    
subnet 192.168.2.0 netmask 255.0.0.0 {
    host <name> {
        hardware ethernet 00:20:0c:10:75:0d;
        fixed-address 10.0.0.10;
        server-name "10.0.0.2";
        next-server "10.0.0.20"; Do not use the quotes on Fedora Core 5 or later.
        option root-path "<rfs_dir>;";
        option routers 10.0.0.2;
        option host-name "<name>";
        filename "<kernel_image>";
    }
}

Note

The IP addresses in this example differ from those in the previous section to highlight the fact that these values should be configured to match the organization of the network at the site where you are installing, hosting, and running this Linux distribution.