MRKAVANA (mrkavana@gmail.com) - www.facebook.com/kavanathai

Jul 28, 2011

HOW DO I INSTALL DHCP ON Redhat Server

First off, a definition. DHCP is the Dynamic Host Configuration Protocol and rather than use the default DHCP server included with your Red Hat / Fedora Linux system, I recommend that you pop over to theInternet Software Consortium and Download the latest version of the DHCP Server. As I write this, it's at version 3.0.3.
Why is it important to have the latest version? In a word, security. As with any software that you're going to run on your server, it's critically important that you have the very latest version of this 'daemon' (as we Linux geeks call programs that run on the server without intervention) on your system. It's also very important to shut off any services you aren't using (a process I detail in my popular book Teach Yourself Unix System Administration in 24 Hours, by the way).
So once you've downloaded the latest version of the software, you'll want to unpack it with:
tar xzf ./dhcp-303-tar.gz
Now, move to the new directory that contains all the source and type in the following commands (the tons of output these commands have has been deleted to save our sanity here):
./configure
make
Assuming all has gone well, switch to root by using the sudo command and install the new server:
sudo make install
you'll be prompted for the root password, then, if you typed it in correctly, the new DHCP server will be installed onto your system.
Good. Now you have the latest DHCP server it's time to configure it properly for your environment. This is best done by copying the file server/dhcp.conf from the installation directory into your /etc directory, like this:
sudo cp server/dhcp.conf /etc
This time, since you just did a sudo command a few seconds ago, you won't be prompted for your password (an exceedingly slick feature of sudo, actually!)
Now, again using sudo, it's time to edit the configuration file to match your system configuration. Here's what the dhcp.conf file looks like:
ddns-update-style interim # Redhat Version 8.0+subnet 192.168.1.0 netmask 255.255.255.0 {
# The range of IP addresses the server will issue to
# DHCP enabled PC clients booting up on the network

range 192.168.1.201 192.168.1.220;
# Set the amount of time in seconds that
# a client may keep the IP address

default-lease-time 86400;
max-lease-time 86400;

# Set the default gateway to be used by
# the PC clients

option routers 192.168.1.1;

# Don't forward DHCP requests from this NIC interface
# to any other NIC interfaces

option ip-forwarding off;

# Set the broadcast address and subnet mask
# to be used by the DHCP clients

option broadcast-address 192.168.1.255;
option subnet-mask 255.255.255.0;

# Set the DNS server to be used by the
# DHCP clients

option domain-name-servers 192.168.1.100;

# Set the NTP server to be used by the
# DHCP clients

option nntp-server 192.168.1.100;

# If you specify a WINS server for your Windows clients,
# you need to include the following option in the dhcpd.conf file:

option netbios-name-servers 192.168.1.100;
}
# List an unused interface here
#
subnet 192.168.2.0 netmask 255.255.255.0 {
}

# You can also assign specific IP addresses based on the clients'
# ethernet MAC address as follows (Host's name is "smallfry":

host smallfry {
hardware ethernet 08:00:2b:4c:59:23;
fixed-address 192.168.1.222;
}
As with many Linux configuration files, this is actually fairly well documented, especially since you should be able to type man dhcp-options to get an exhaustive explanation of each and every configuration option.
In particular, make sure you set the domain name properly, identify your set of DNS servers by name, and define the subnet range for which you want to provide services via DHCP.
Once that's all configured to your liking, a little bit more tweaking is required to get everything checked and started properly:
sudo touch /var/lib/dhcp/dhcp.leases
Will make sure that you have a 'leases' file, a critical part of how the DHCP server tracks what systems it's seen and serviced.
sudo chkconfig --level 35 dhcpd on
This will check your configuration and make sure it will be added to the list of daemons to start up at boot time from now on. Very useful if you don't want to remember to restart it each time!
/etc/init.d/dhcp restart
Now you should be running a DHCP server on your system. Check to make sure it's running by using ps aux | grep dhcp but you should be -- hopefully -- good to go!


1 comment:

  1. I have just installed DHCP on my Redhat, thank you for this install guide.

    ReplyDelete