Running dhcpd

Under Red Hat Linux 7.2, the DHCP daemon is started by the /etc/init.d/dhcpd script. The script accepts the same arguments as the /etc/init.d/named script described in Chapter 4. The most commonly used arguments are start, stop, and restart. For example, the following command will start dhcpd:

[root]# service dhcpd start

Use a tool such as chkconfig or tksysv to ensure that the /etc/init.d/dhcpd startup script is run whenever the system reboots. On our sample Red Hat system, the following chkconfig commands cause the dhcpd script to run whenever the system reboots in runlevel 3 or 5:

[root]# chkconfig —list dhcpd dhcpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off

[root]# chkconfig —level 35 dhcpd on [root]# chkconfig —list dhcpd dhcpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off

The /etc/init.d/dhcpd script uses the dhcpd command to start the DHCP server. The syntax of the dhcpd command is dhcpd [-p port] [-f] [-d] [-q] [-cf file] [-lf file] [interface-list]

-p port Defines an alternate port. Normally, dhcpd listens for client requests on port 67, and responds on port 68. Use the -p option to change to non-standard ports. This is used only for testing.

-f Runs dhcpd as a foreground process. This is used only for debugging. -d Sends error messages to stderr instead of to syslogd. -q Prevents dhcpd from printing out its startup message.

-cf file Identifies the file from which dhcpd should read its configuration. By default, dhcpd reads its configuration from /etc/dhcpd.conf.

-lf file Identifies the file to which dhcpd should write address lease information. By default, dhcpd writes lease information to /var/lib/dhcp/dhcpd.leases.

interface-list Lists the names of the interfaces that dhcpd should monitor for client request. By default, dhcpd listens to all interfaces that support broadcasts.

To set dhcpd command-line arguments on a Red Hat system, store the arguments in the file /etc/ sysconfig/dhcpd. The /etc/init.d/dhcpd script reads arguments from that file before starting the DHCP daemon. For example, to make dhcpd read its configuration from a file named /var/dhcp/ test.conf, create a /etc/sysconfig/dhcpd file that contains the following:

[root]# cat /etc/sysconfig/dhcpd

# Command line options here DHCPDARGS=-cf /var/dhcp/test.conf

This causes dhcpd to read its configuration from /var/dhcp/test.conf, but the /etc/dhcpd.conf file is still required! The /etc/init.d/dhcpd script does not run dhcpd unless it finds both the /etc/ dhcpd.conf file and the /var/lib/dhcp/dhcpd.leases file.

Was this article helpful?

0 0

Post a comment