Updated 1 January 2020 © 2020 Logiqwest, Inc. All rights reserved.
Linux Logo

DHCP Server Setup

Introduction
Edit section

A quickstart server needs a PXE server to respond and provide an IP address and allow a boot image to be executes. The first part in setting up a quickstart server is to create a very basic DHCP server to direct the boot form a PXE server. The folliwing describes how to install and configure the DHCP services for the PXE server.

Steps
Edit section

  • Install dhcp software ( # yum install dhcp)
  • Define an ethernet port to support the PXE boots
  • Edit Two files (/etc/dhcpd.conf and /etc/sysconfig/dhcpd).
  • Replace dhcpd.conf file with basic configuration below.
  • Add ethernet device named to the dhcpd file.

Install dhcp software
Edit section

Use yum to intall dhcp

[root@kickstart ~]# yum install dhcp
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: mirror.hmc.edu
 * extras: mirrors.easynews.com
 * updates: mirror.5ninesolutions.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:3.0.5-31.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================
 Package               Arch     Version          Repository      Size
=======================================================================
Installing:
 dhcp                  x86_64   12:3.0.5-31.el5  base            889 k
Transaction Summary
=======================================================================
Install       1 Package(s)
Upgrade       0 Package(s)
Total download size: 889 k
Is this ok [y/N]: y
Downloading Packages:
dhcp-3.0.5-31.el5.x86_64.rpm                          | 889 kB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : dhcp                                              1/1 
Installed:
  dhcp.x86_64 12:3.0.5-31.el5                                                            
Complete!
[root@kickstart ~]# 
 
Add DHCP Subnet Device
 
Create another network interface either by hand or using the system-config-network GUI:
 
ConfigNetwork.png
We have created a network on anohter netwok interface eth1 in a subnet 192.168.201.0 who is itself its own router.
NetworkConfig.png
 

Edit Two Files 
Edit section

  1. /etc/dhcpd.conf
  2. /etc/sysconfig/dhcpd

Replace the contents of the /etc/dhcpd.conf file with 

ddns-update-style interim;
not authoritative;

option option-128 code 128 = string;
option option-129 code 129 = text;

#option domain-name "logiqwest.com";
#option domain-name-servers 192.168.1.74, 68.238.64.12, 68.238.96.12;
option subnet-mask 255.255.255.0;
subnet 192.168.201.0 netmask 255.255.255.0 {
        authoritative;
        range 192.168.201.2 192.168.201.25;
        option routers 192.168.201.1;
        allow unknown-clients;
        allow booting;
        allow bootp;
        next-server 192.168.201.1;
        filename "pxelinux.0";
}
 
Note:
  1. The "next-server" entry must match the server where you pxe boot files are located. See TFTP Setup for documentation as to how to create this server. In this case this is the same server that is serving up dhcp.

Edit the /etc/sysconfig/dhcp file and assign the physical interface

# Command line options here
DHCPDARGS=eth1

Start the Service

Perform service dhcpd start

[root@kickstart ~]# service dhcpd start
Starting dhcpd:                                            [  OK  ]
[root@kickstart ~]# 

Notes:

  1. In this case we have not added dhcpd to automatic service restart. It is preferred that we start the service only when needed and disable is when we do not (e.g. service dhcpd stop).
  2. If there is an issue with it starting properly, check to make sure that the subnet values in /etc/dhcpd.conf are corrected (e.g. 192.168.201) and that you do have an interface assigned to that network with a valid IP address that is not in the range (e.g. 192.168.201.2 to 192.168.201.25 does not contain 192.168.201.1).
  3. Make sure that /etc/sysconfig/dhcp matches an active network interface (DHCPDARGS=eth1).
  4. Use the tail command in background to see what is going on when the service is started

# tail -f /var/log/message | grep dhcp &

You can move back to the tail copmmnad by using "fg" at the command line.

Click for more info