Configuration method of DHCP server under Linux system

Time:2022-5-26

1、 installDHCP server software

The rhel4 system CD contains the DHCP server software package in RPM format. The package name is dhcp-3.0.1-12_ EL. i386.rpm

#rpm –ivh dhcp-3.0.1-12_EL.I386.rpm

2、 dhcpd. Conf configuration file parsing
(1)       dhcpd. Conf configuration file
The configuration file name of dhcpd is dhcpd Conf, which should be located in the “/ etc” subdirectory, but this file is not included in the DHCP package and needs to be created manually. However, in order to facilitate people’s use, it provides a configuration sample file dhcpd Conf.sample is located in the “/ usr / share / Doc / dhcp-3.0.1 /” directory
(2)       Create profile
To manage the DHCP server, the administrator needs to establish DHCP PD Conf, you can usually copy the sample file dhcpd Conf.sample to “/ etc” directory as dhcpd Conf, and then modify the configuration file using the VI editor

#cp /usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample /etc/dhcpd.conf
#vi /etc/dhcpd.conf

(3)       Basic format of configuration file
In DHCP The conf configuration file can include three basic formats: declaration, parameter and option.
The declaration is used to describe the pair in the dhcpd servernetworkThe division of layout isnetworkset upLogical range of

Subnet 192.168.1.0 netmask 255.255.255.0 {
         ranga 192.168.1.2   192.168.1.128 ;
……..
}

Parameter byset upItem andset upValue composition: the value of the parameter depends on the location of the parameterset upDeclarations that can be applied globally or formulated. Parameters always start with ‘;’ It’s over.

default—lease—time 21600;
max—lease—time   43200;

Options are always guided by the option keyword, followed by specific options and optionsset upValue. Options can be applied globally or in a declaration depending on the location. Options are also preceded by ” It’s over.

option routers 192.168.1.1;
option subnet-mask 255.255.255.0;

3. ManynetworkInterfaces are files that require configuration
A host used as a DHCP server usually has multiple hostsnetworkInterface, and dhcpp service may only need to be in one of themnetworkProvided on the interfaceserviceAt this time, you can specify the DHCP service to be provided in the “/ etc / sysconfig / DHCP PD” filenetworkInterface.

#cat /etc/sysconfig/dhcpd
#Command line options here
DHCPDARGS=

The default dhcpdargs setting item in the dhcpd file is empty and can be modified to the specified valuenetworkInterface name, such as etch0, so that dhcpd will only provide dhcpfuw on eth0 network interface

DHCPDARGD=eth0

4. Start and stop of dhcpd service
The startup script of dhcpd service is located in the “/ etc / init. D /” directory and is named dhcpd. The startup, stop and restart functions of dhcpd service are realized by this script.
Start dhcpd service

service dhcpd restart