• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

CentOS / RHEL 7 : How to specify command-line arguments and options when the dhcpd service is started

by admin

Dynamic Host Configuration Protocol (DHCP) allows client machines to automatically obtain network configuration information from a DHCP server each time they connect to the network. The DHCP server is configured with a range of IP addresses and other network configuration parameters.

When the client machine is configured to use DHCP, the client daemon, dhclient, contacts the server daemon, dhcpd, to obtain the networking parameters. Because DHCP is broadcast based, both the client and the server must be on the same subnet.

Specifying command-line arguments and options while starting dhcpd service

1. To specify command-line arguments and options when the dhcpd service is started, copy the /usr/lib/systemd/system/dhcpd.service file to the /etc/systemd/system/ directory:

# cp /usr/lib/systemd/system/dhcpd.service /etc/systemd/system/

2. You can then edit the /etc/systemd/system/dhcpd.service file and append command-line arguments and options to the ExecStart line. For example, if your DHCP server has multiple network interfaces (eth0, eth1, eth2) but you want only the dhcpd service to listen for DHCP requests on eth2, include eth2 as a command-line argument:

# vi /etc/systemd/system/dhcpd.service ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user
dhcpd -group dhcpd --no-pid eth2

3. When you enable the service to start at boot time, a symbolic link is created to the dhcpd.service file in the /etc/systemd/system/ directory rather than the file in the /usr/lib/systemd/system/ directory:

# systemctl enable dhcpd
ln –s ‘/etc/systemd/system/dhcpd.service’ ‘/etc/systemd/system/multi-user.target.wants/dhcpd.service’

Refer to the dhcpd man page for additional command-line options and arguments. Some of the most commonly available options are described below:

  • -p [port]: Specifies the UDP port number on which dhcpd listens. The default is port 67.
  • -f: Runs the dhcpd as a foreground process instead of a background daemon. This is helpful when debugging a problem.
  • -d: Logs the DHCP server daemon to the standard error descriptor. This is helpful when debugging. If this is not specified, dhcpd logs all output using syslog.
  • -cf [filename]: Specifies the location of the configuration file. The default configuration file is /etc/dhcp/dhcpd.conf.
  • -lf [filename]: Specifies the location of the lease database file. The default lease file is /var/lib/dhcpd/dhcpd.leases.
  • -q: Specifies to be quiet at startup. This suppresses printing of the entire copyright message when starting the daemon.
  • –no-pid: Disables writing pid (Process ID) files. With this option, the service does not check for an existing server process.

Filed Under: CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. Understanding /etc/profile Configuration File in Linux
  2. lsb_release: command not found
  3. lvs Command Examples in Linux
  4. pvck Command Examples in Linux
  5. CentOS / RHEL : How to identify/match LUN presented from SAN with underlying OS disk
  6. useradd: command not found
  7. ldconfig: command not found
  8. How to uninstall lammps package from Ubuntu
  9. e2image Command Examples in Linux
  10. LVM ISCSI Physical Volume Not Available After Server Reboot

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright