Product SiteDocumentation Site

9.2.3. Starting and Stopping the Server

Starting the DHCP Server for the First Time

When the DHCP server is started for the first time, it fails unless the dhcpd.leases file exists. You can use the command touch /var/lib/dhcpd/dhcpd.leases to create the file if it does not exist. If the same server is also running BIND as a DNS server, this step is not necessary, as starting the named service automatically checks for a dhcpd.leases file.
Do not create a new lease file on a system that was previously running. If you do, all old leases are lost which causes many problems. The correct solution is to rename the dhcpd.leases~ backup file to dhcpd.leases and then start the daemon.
To start the DHCP service, use the following command:
systemctl start dhcpd.service
To stop the DHCP server, type:
systemctl stop dhcpd.service
By default, the DHCP service does not start at boot time. To configure the daemon to start automatically at boot time, run:
systemctl enable dhcpd.service
If more than one network interface is attached to the system, but the DHCP server should only listen for DHCP requests on one of the interfaces, configure the DHCP server to listen only on that device. The DHCP daemon will only listen on interfaces for which it finds a subnet declaration in the /etc/dhcp/dhcpd.conf file.
This is useful for a firewall machine with two network cards. One network card can be configured as a DHCP client to retrieve an IP address to the Internet. The other network card can be used as a DHCP server for the internal network behind the firewall. Specifying only the network card connected to the internal network makes the system more secure because users can not connect to the daemon via the Internet.
To specify command-line options, copy and then edit the dhcpd.service file as the root user. For example, as follows:
~]# cp /usr/lib/systemd/system/dhcpd.service /etc/systemd/system/
~]# vi /etc/systemd/system/dhcpd.service
Edit the line under section [Service]:
ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid your_interface_name(s)
Then, as the root user, restart the service:
~]# systemctl --system daemon-reload
~]# systemctl restart dhcpd
Command line options can be appended to ExecStart=/usr/sbin/dhcpd in the /etc/systemd/system/dhcpd.service unit file under section [Service]. They include: