DHCP Service introduction and service management configuration

Source: Internet
Author: User
Tags ack centos server port

1. Introduction to DHCP Service

DHCP is Dynamic host Configuration Protocol, which is a way to assign IP addresses to hosts in a physical network, distinguishing them from BOOTP, and assigning a lifetime use disadvantage.

The concept of a DHCP-proposed lease makes it possible to dynamically determine the IP address required by the host as needed, and the IP address can be reused.

2. DHCP structure

DHCP is a typical C/s structure, requires the server to start the daemon to ensure that requests from the client segment can be responded to, the principle of DHCP work as follows:

Can be remembered by Dora:

Client:dhcp DISCOVER #客户端向相同网络发送广播包, attempting to find a DHCP server

Server:dhcp offer# If the DHCP service segment receives a discover packet, reply to the client for an offer broadcast packet

CLIENT:DHCP request# Client receives an offer broadcast packet from DHCP, the DHCP server is determined to continue sending the request package to the DHCP server to request IP information

SERVER:DHCP ACK#DHCP server sends ACK packets to the client, carries IP and lease information to the client, and the DHCP discovery process ends

Note: DHCP is on the other side of the router across the network segment, the router needs to turn on DHCP relay to support forwarding the client Discover broadcast packets to the DHCP server, which are unicast via router forwarding

Because the connection between the router and DHCP has IP information.

DHCP Server Port UDP 67

DHCP Client Port UDP 68

DHCP Reservation: Address reservation:

Addresses that are specific to a particular client should not be used in the address pool, precedence over addresses in the address pool;

3. DHCP service installation configuration under Linux

Since the system management mechanism of CENTOS6/7 is different, the mode of boot-start service differs, but the configuration file, the Help document is very similar

3.1 CentOS 6 DHCP Installation:

#yum Install DHCP

#通过rpm-ql dhcp to query the files created by the HDCP package, we can analyze how he uses it:

Here are a few more important documents:




#服务脚本, control the start of DHCP service, shutdown, status inquiries, reload, etc.





#dhcp命令参数配置文件: This file content provides some extents for the dhcpd daemon to be used during system boot, and the DHCPD daemon automatically assigns IP addresses to the host using DHCP and BOOTP protocols








#dhcp的ip地址租约库, you can find the IP distribution



4.1 CentOS6 DHCP service profile management:

4.1.1 First edit the DHCP master configuration file:


Option Domain-name "richie.com"; #dhcp主机名

Option Domain-name-servers; #名称服务器的地址

Default-lease-time 600; #默认租约秒数

Max-lease-time 7200; #最大租约秒数

Log-facility Local7; #log级别

Subnet netmask {

Range; #可供分配的ip段

Option Routers,; #如果在最近配置的option routers then drink directly, if not, then automatically inherit the option at the top level

} #子网配置格式

When you finish editing, save exit, you can use this command to detect syntax errors:

Service DHCPD Configtest

4.1.2 Configure IP Address reservation:

Required within subnet {}, the configuration host{} format is as follows:

Subnet netmask {


Hardware Ethernet 00:0c:29:0:f3:44;


Option routers #这里可以针对这台机器设置option routers value without inheriting gateway information at the upper level



Finally, save the exit

Service DHCPD Force-reload

Test effect:

Linux client:

dhclient-d eth0

Window client:


4.1.3 Configuration boot from:

or the old command. Chkconfig dhcpd on, by default, the init level 2,3,4,5 is set to power on, or you can use Chkconfig--level 2,3,4 to specify the run level you want to boot

4.1.4 Manage DHCP Service

Service DHCPD {Start|stop|restart|force-reload|condrestart|try-restart|configtest|status}

DHCP service management under 4.2 CentOS 7

4.2.1 Configuration file:

Configuration on the same CentOS6, see 4.1.1

4.2.2 Configure IP Address reservation:

Configuration on the same CentOS6, see 4.1.2

4.2.3 Configuration boot from:

Because of the different CENTOS6/7 system service management mechanism, CENTOS7 introduced SYSTEMD to manage all the services, so it is no longer possible to use the Chkconfig command to set the:

# systemctl is-enabled daemon.service View DHCP service status, equivalent to C5 chkconfig--list

# Systemctl Enable Daemon.service enables the power-on from boot DHCP service, equivalent to C5 chkconfig dhcpd on

# systemctl Disable Daemon.service disables the power-on boot DHCP service, which is equivalent to C5 chkconfig dhcpd off

4.2.4 Manage DHCP Service

# systemctl {Start|stop|restart|status} daemon.service

5. DHCP Configuration Command Summary

A configuration file for a simple DHCP service needs to contain at least the following configuration information:


Option Domain-name

Option Domain-name-servers

Option routers

Subnet Network netmask MASK {

Range Start_ip end_ip;


Hardware Ethernet 00:11:22:33:44:55;

Fixed-address IP;






Option Domain-name "richie.com";

Option Domain-name-servers;

Default-lease-time 600;

Max-lease-time 7200;

Log-facility Local7;

Subnet netmask {


Option Routers,;


Hardware Ethernet 00:0c:29:30:f3:44;




Note : More wonderful tutorials Please pay attention to the triple computer tutorial section, triple Computer office group: 189034526 welcome you to join

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.