DHCP
server. Install the package as root
:
~]# yum install dhcp
/etc/dhcp/dhcpd.conf
, which is merely an empty configuration file. As root
, issue the following command:
~]# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
/usr/share/doc/dhcp/dhcpd.conf.example
. You should use this file to help you configure /etc/dhcp/dhcpd.conf
, which is explained in detail below.
DHCP
also uses the file /var/lib/dhcpd/dhcpd.leases
to store the client lease database. Refer to Section 9.2.2, “Lease Database” for more information.
DHCP
server is to create the configuration file that stores the network information for the clients. Use this file to declare options for client systems.
#
) are considered comments.
DHCP
options; whereas, parameters configure values that are not optional or control how the DHCP
server behaves.
{ }
) are considered global parameters. Global parameters apply to all the sections below it.
Restart the DHCP Daemon for the Changes to Take Effect
DHCP
daemon is restarted with the command systemctl restart dhcpd
.
Use the omshell Command
DHCP
configuration file and restarting the service each time, using the omshell
command provides an interactive way to connect to, query, and change the configuration of a DHCP
server. By using omshell
, all changes can be made while the server is running. For more information on omshell
, see the omshell
man page.
routers
, subnet-mask
, domain-search
, domain-name-servers
, and time-offset
options are used for any host
statements declared below it.
DHCP
server is connected, there must be one subnet
declaration, which tells the DHCP
daemon how to recognize that an address is on that subnet. A subnet
declaration is required for each subnet even if no addresses will be dynamically allocated to that subnet.
DHCP
client in the subnet and a range
declared. Clients are assigned an IP
address within the range
.
Example 9.1. Subnet Declaration
subnet 192.168.1.0 netmask 255.255.255.0 { option routers 192.168.1.254; option subnet-mask 255.255.255.0; option domain-search "example.com"; option domain-name-servers 192.168.1.1; option time-offset -18000; # Eastern Standard Time range 192.168.1.10 192.168.1.100; }
DHCP
server that leases a dynamic IP
address to a system within a subnet, modify the example values from Example 9.2, “Range Parameter”. It declares a default lease time, maximum lease time, and network configuration values for the clients. This example assigns IP
addresses in the range
192.168.1.10
and 192.168.1.100
to client systems.
Example 9.2. Range Parameter
default-lease-time 600; max-lease-time 7200; option subnet-mask 255.255.255.0; option broadcast-address 192.168.1.255; option routers 192.168.1.254; option domain-name-servers 192.168.1.1, 192.168.1.2; option domain-search "example.com"; subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.10 192.168.1.100; }
IP
address to a client based on the MAC address of the network interface card, use the hardware ethernet
parameter within a host
declaration. As demonstrated in Example 9.3, “Static IP Address Using DHCP”, the host apex
declaration specifies that the network interface card with the MAC address 00:A0:78:8E:9E:AA
always receives the IP
address 192.168.1.4
.
host-name
to assign a host name to the client.
Example 9.3. Static IP Address Using DHCP
host apex { option host-name "apex.example.com"; hardware ethernet 00:A0:78:8E:9E:AA; fixed-address 192.168.1.4; }
shared-network
declaration as shown in Example 9.4, “Shared-network Declaration”. Parameters within the shared-network
, but outside the enclosed subnet declarations, are considered to be global parameters. The name assigned to shared-network
must be a descriptive title for the network, such as using the title “test-lab” to describe all the subnets in a test lab environment.
Example 9.4. Shared-network Declaration
shared-network name { option domain-search "test.redhat.com"; option domain-name-servers ns1.redhat.com, ns2.redhat.com; option routers 192.168.0.254; #more parameters for EXAMPLE shared-network subnet 192.168.1.0 netmask 255.255.252.0 { #parameters for subnet range 192.168.1.1 192.168.1.254; } subnet 192.168.2.0 netmask 255.255.252.0 { #parameters for subnet range 192.168.2.1 192.168.2.254; } }
group
declaration is used to apply global parameters to a group of declarations. For example, shared networks, subnets, and hosts can be grouped.
Example 9.5. Group Declaration
group { option routers 192.168.1.254; option subnet-mask 255.255.255.0; option domain-search "example.com"; option domain-name-servers 192.168.1.1; option time-offset -18000; # Eastern Standard Time host apex { option host-name "apex.example.com"; hardware ethernet 00:A0:78:8E:9E:AA; fixed-address 192.168.1.4; } host raleigh { option host-name "raleigh.example.com"; hardware ethernet 00:A1:DD:74:C3:F2; fixed-address 192.168.1.6; } }
Using the Example Configuration File
root
:
~]# cp /usr/share/doc/dhcp-version_number/dhcpd.conf.example /etc/dhcp/dhcpd.conf
DHCP
version number.
dhcp-options(5)
man page.