The Dynamic Host Configuration Protocol (DHCP) provides a method for hosts on a network to request, and be granted, configuration information including the addresses of routers and name servers. Usually, there is a single DHCP server per network segment, but in some cases there may be more than one. IP addresses assigned from a range of addresses i.e. pool by DHCP. The assignments are made for a configurable amount of time i.e. lease period and may be renewed by the client after lease expires. If desired, the server can be configured to accept requests from a specific set of MAC addresses.
Typically, the server supplies information about the network’s subnet address and netmask, its default gateway, domain name and DNS server, time servers and location of kickstart configuration files as per required.
In Red Hat Enterprise Linux, the DHCP service is performed by the dhcpd daemon.
Service Profile: DHCP
· Type: SystemV-managed service
· Package: dhcp
· Daemon: /usr/sbin/dhcpd
· Script: /etc/init.d/dhcpd
· Ports: 67, 68
· Configuration:
o /etc/dhcpd.conf
o /var/lib/dhcpd/dhcpd.leases
DHCP Server Configuration
Installing RPMs
First, the required RPM dhcp* has to be installed. As the YUM server is installed, this can be done by running the command-
[root@prime ~]#yum install dhcp
Preparing the Configuration Files
1. The configuration file /etc/dhcpd.conf is a blank file after installing the RPM. We copy a sample file from /usr/share/doc/dhcp-*/dhcpd.conf.sample into the /etc directory.
#cp /usr/share/doc/dhcp-*/dhcpd.conf.sample /etc/dhcpd.conf
2. The configuration file must be modified as per requirement. A sample file can be seen below. The text in italic have been added/modified by the user-
#/etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 192.168.10.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.10.1;
option subnet-mask 255.255.255.0;
option domain-name "example.org";
option domain-name-servers 192.168.10.1;
option time-offset -18000; # Eastern Standard Time
#the range can be set as per requirements
range dynamic-bootp 192.168.10.10 192.168.10.254;
default-lease-time 21600;
#max-lease-time 43200;
}
Binding IP addresses into MAC addresses
The configuration file can be modified to bind specific IP addresses to specific MAC addresses. This causes specific MAC addresses to obtain fixed IPs every time that client requests the DHCP. This can be done in the following procedure-
1. If an IP address can be pingedsuccessfully, it is possible to obtain the MAC address of that host with the command arp.
#ping 192.168.10.5
#arp 192.168.10.5
2. The following lines should be added withinthe subnet section of a network definition in /etc/dhcpd.conf-
#/etc/dhcpd.conf
#following section can bind IP addresses to specific MAC #addresses
#the name of the host section is user defined and does #not affect configuration
host station10.example.org {
hardware ethernet 08:00:27:0C:2A:14;
fixed-address 192.168.10.10;
}
host station20.example.org {
hardware ethernet 00:10:33:0E:C6:1B;
fixed-address 192.168.10.20;
}
Initiating the DHCP Service
1. The syntax of the configuration file can be checked using the command-
[root@prime ~]# service dhcpd configtest
2. Now that the configuration file is ready, the dhcpd service can be initialized and put to startup. This can be done by-
[root@prime ~]#service dhcpd restart
[root@prime ~]#chkconfig dhcpd on
3. All IP lease information can be found in /usr/lib/dhcpd/dhcpd.leases file.
0 comments:
Post a Comment