Breaking News

Implement the DHCP Server

Implémenter le Serveur DHCP

 Implement the DHCP Server

Presentation and definitions :

The DHCP protocol was first used in 1993. It is defined by RFC1531 and was subsequently modified and supplemented by RFC1534, RFC2131 and RFC2132.

This protocol works in both IPv4 and IPv6. In this case, it is called DHCPv6 and the addresses can be auto-configured, without DHCP.

The protocol operates in client/server mode and relies essentially on a mechanism of DHCP requests, processed by the server and sent by the clients.
The main engine of this protocol is backed by BOOTP communication.
The client device only transmits a specific broadcast packet (destined for the address, mentioning other parameters, such as the type of request, connection ports, etc. Everything is sent over the local network.

Scope concept :

We speak of address ranges to define a range of IP addresses available for a specific lease.
Typically, a scope relies on the addresses of a particular subnet.

Address reservation:

We speak of reserving DHCP addresses when an IP address, within a scope is discarded to be used by a specific DHCP client.

The different Messages and requests :

Implémenter le Serveur DHCP

How do the DHCP server and client communicate?

The automatic assignment of addresses via the dynamic host configuration protocol (DHCP) takes place in four consecutive steps :

  1. To begin, the client sends a DHCPDISCOVER packet with the target address and the source address With this broadcast, it contacts all participants in the network to locate the available DHCP servers and inform them of the address request. Ideally, only one server exists, so there are no complications with attribution.
  2. All DHCP servers that listen for requests from port 67 respond to the client's request with a DHCPOFFER packet. This response, in addition to a possible free IP address and the MAC address of the client, also contains the subnet mask as well as the IP address and ID of the server.
  3. The DHCP client selects one from the address data received and informs the server concerned via DHCPREQUEST. All other servers also receive this message and thus know that the choice has been made in favor of another server. In addition, the client requests the server to activate the proposed data. DHCPREQUEST is also used to confirm the parameters received previously.
  4. Finally, the server confirms the TCP / IP parameters and transmits them again to the client using a DHCPACK packet (DHCP acknowledged, for "recognized"). It contains additional information, for example on DNS, SMTP or POP3 servers. The DHCP client now records all the data received locally and connects to the network. If the server is no longer available or if the IP address was assigned to another client during the configuration process, it then responds with DHCPNAK (DHCPnot acknowledged "not recognized").

Implémenter le Serveur DHCP

The automatically assigned address is saved in combination with the MAC address in the server database, which means that the configuration becomes permanent. The device always connects to the network with the assigned IP address, which is blocked for other clients.

However, this also has the disadvantage that new DHCP clients will not receive an address if the entire address range has already been assigned, even if some IP addresses are no longer actively used.

It is primarily for this reason that dynamic IP addresses and in some special cases manual assignment via the DHCP server, as discussed in the next section, are much more commonly used.

DHCP Client and Server installation :

To check the existence of the service :

# rpm –qa|grep DHCP

To install two methods :

# yum install DHCP*


[root@localhost dhcp]# rpm -ivh dhcp-3.0.2-12.i386.rpm

To delete a service :

# yum remove DHCP*

Implémenter le Serveur DHCP

Configuration file :  /etc/dhcp/dhcpd.conf

In the configuration file, you must declare the FQDN domain name as well as the address (or addresses) of the name server and their subnet mask :

option domain-name "" ;
option domain-name-server, ;
option subnet-mask

Then, we define the parameters of the leases :

default-lease-time 3600 ;
max-lease-time 86400 ;
ddns-update-style none ;

You must then declare the range of addresses, especially not omitting the main router in the event of a change of subnet:

subnet netmask
range ;
option routers ;

We can then systematically declare all stations or equipment in front of the shredder with a fixed address :

host mailbox {
hardware ethernet 00:56:bc:77:02:a2 ;
fixed-address ;

After configuration activate the service
#service DHCP restart

Relay agent :

The DHCP Relay :

(Dhcrelay), relays DHCP and BOOTP requests from a subnet with no DHCP server, to one or more subnets with such a service.

When a DHCP client requests information, the relay agent forwards the request to the list of DHCP servers it knows. So, in return, when a DHCP server responds to this kind of request, it is broadcast on the network that sent the original request.

The relay agent waits for DHCP requests on all of its interfaces unless one of them is privileged and mentioned in the
                                                        Dhcrelay file, with the INTERFACES directive.

The installation is integrated into the main DHCP package.

Implémenter le Serveur DHCP

Relay agent : /etc/sysconfig/dhcrelay 

a level of the machine hosting the Dhcrelay service, you must then fill in the file


By mentioning the following options:

# Server address

# Interface (s) used by the DHCP relay


and agent relies on the DHCP relay service which can be activated or deactivated from the machine using standard commands:
for a fedora distribution:

# service Dhcrelay {stop | start}

It is of course, possible to eliminate the functionality of the DHCP server and of relays, simultaneously on the same machine.

But, two prerequisites are then to be verified:

  • The machine has two network interfaces: one for the server and the other for the relay.
  • The server must then authorize the routing of packets


  • The DHCP Server role simplifies the configuration of clients within a network;
  • All options and parameters are accessible via assistant simplifying handling and start-up;
  • Microsoft is increasing security through the redundancy of two servers that act as DHCP servers.

Now, you know almost everything about the DHCP role! We hope you got this topic from the site  ==>  Computer Skills 



Aucun commentaire