Chapter 4. DHCP server

Table of Contents

4.1. Why use a DHCP server
4.2. Dhcpd.conf Options
4.2.1. Classical options
4.2.1.1. Allow booting
4.2.1.2. Not authoritative
4.2.1.3. DHCPD_INTERFACE
4.2.1.4. Pool
4.2.2. Specific options
4.2.2.1. Class
4.2.2.2. Option vendor-class-identifier
4.2.2.3. Vendor-encapsulated-options
4.2.2.4. Vendor-option-space
4.2.2.5. Filename
4.2.2.6. Next-server
4.2.2.7. Match if substring(option vendor-class-identifier, 0, 9)="PXEClient"
4.2.2.8. Set vendor_class_identifier
4.3. Sample dhcpd.conf file

4.1. Why use a DHCP server

This server will answer the DHCP requests for the PXE client, depending on the PXE client class. Logs files location on the server depends on your configuration, on Mandrake Linux 8.x you can find them in /var/log/messages. Default configuration file is stored in /etc/ directory.

4.2. Dhcpd.conf Options

4.2.1. Classical options

4.2.1.1. Allow booting

The booting flag is used to tell dhcpd whether or not to answer queries from a particular client. This keyword is useful only when it appears in a host declaration. By default, booting is allowed, but if it is disabled for a particular client, that client will not be able to get and address from the DHCP server.

4.2.1.2. Not authoritative

If the server is not valid for that particular segment it will send a DHCPNACK message. Very useful if you have another DHCP server.

4.2.1.3. DHCPD_INTERFACE

Define which interface to use with your DHCP server. Useful if you have a router and you don't want to answer dhcp requests only on a specific interface.

4.2.1.4. Pool

This section of /etc/dhcpd.conf defines a pool which contains a range of IP addresses. In our example, the DHCP server allows member of the PXE Class, and denies member of any other class.

4.2.2. Specific options

4.2.2.1. Class

In our example we create two classes : PXE, Etherboot. Class is used to define specific options.

4.2.2.2. Option vendor-class-identifier

If the vendor-class-identifieroption is set to Etherboot-5.0, it will look in the class Etherboot for options and the filename of the bootstrap.

4.2.2.3. Vendor-encapsulated-options

Used by Etherboot to detect a valid PXE dhcp server. In our example, it is used for the Etherboot Class. This value must be set to 3c:09:45:74:68:65:72:62:6f:6f:74:ff for Etherboot 5.0 and later.

4.2.2.4. Vendor-option-space

Used to define specific options for the current class.

4.2.2.5. Filename

Option filename defines the file to retrieve for the client. Our tftp is chrooted so it's just the path to the file. If you want to use the grub boot method, use a specific pxegrub compiled for your ethernet card.

4.2.2.6. Next-server

Defines the IP of your TFTP server.

4.2.2.7. Match if substring(option vendor-class-identifier, 0, 9)="PXEClient"

This is a test to check if the nineth first chars of the vendor-class-identifier option match PXEClient.

4.2.2.8. Set vendor_class_identifier

Set the vendor-class-identifier field to PXEClient in the dhcp answer. If this field is not set properly, the PXE client will ignore the answer !

4.3. Sample dhcpd.conf file


ddns-update-style ad-hoc;
allow booting;
allow bootp;
not authoritative;
DHCPD_INTERFACE = "eth1";

# Definition of PXE-specific options
# Code 1: Multicast IP address of bootfile
# Code 2: UDP port that client should monitor for MTFTP responses
# Code 3: UDP port that MTFTP servers are using to listen for MTFTP requests
# Code 4: Number of secondes a client must listen for activity before trying
#         to start a new MTFTP transfer
# Code 5: Number of secondes a client must listen before trying to restart
#         a MTFTP transfer
option space PXE;
option PXE.mtftp-ip code 1 = ip-address;
option PXE.mtftp-cport code 2 = unsigned integer 16;
option PXE.mtftp-sport code 3 = unsigned integer 16;
option PXE.mtftp-tmout code 4 = unsigned integer 8;
option PXE.mtftp-delay code 5 = unsigned integer 8;
option PXE.discovery-control code 6 = unsigned integer 8;
option PXE.discovery-mcast-addr code 7 = ip-address;

class "Etherboot" {
match if substring (option vendor-class-identifier, 0, 13) = "Etherboot-5.0";
filename "/etherboot/nbgrub";
option vendor-encapsulated-options 3c:09:45:74:68:65:72:62:6f:6f:74:ff;
option vendor-class-identifier "Etherboot-5.0";
vendor-option-space PXE;
option PXE.mtftp-ip 0.0.0.0;
next-server 192.168.200.1;
}

class "PXE" {
match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
#filename "/PXEClient/pxegrub";
filename "/PXEClient/pxelinux.0";
option vendor-class-identifier "PXEClient";
vendor-option-space PXE;
option PXE.mtftp-ip 0.0.0.0;
next-server 192.168.200.1;
}

class "known" {
  match hardware;
  one-lease-per-client on;
  ddns-updates on;
  ddns-domainname = "mandrakesoft.com";
  ddns-hostname = pick-first-value(ddns-hostname, option host-name);
  option fqdn.no-client-update on;
  set vendor_class_identifier = option vendor-class-identifier;
}

shared-network "mynetwork" {
  subnet 192.168.200.0 netmask 255.255.255.0 {
  option subnet-mask 255.255.255.0;
  option routers 192.168.200.1;
  default-lease-time 28800;
  max-lease-time 86400;
   
    pool { 
       range 192.168.200.50 192.168.200.99;
       deny members of "PXE";
       deny members of "Etherboot";
    }

    pool {
      range 192.168.200.200 192.168.200.254;
        allow members of "PXE";
        deny members of "known";
        allow members of "Etherboot";
         }
  }
}